Skip to content

Commit

Permalink
Added support for Brave browser (resolves #100).
Browse files Browse the repository at this point in the history
  • Loading branch information
nero120 committed Sep 5, 2020
1 parent 93b3c70 commit bac3cb7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ interface CordovaPlugins {
}

interface Navigator {
brave: any;
globalization: any;
}
1 change: 1 addition & 0 deletions src/modules/shared/global-shared.enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
enum BrowserName {
Brave = 'brave',
Edge = 'edge-chromium'
}

Expand Down
4 changes: 4 additions & 0 deletions src/modules/shared/utility/utility.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ export default class UtilityService {
}
}

isBraveBrowser(): boolean {
return !angular.isUndefined(window.navigator.brave);
}

isMobilePlatform(platformName: string): boolean {
return platformName === PlatformType.Android;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export default class ChromiumPlatformService extends WebExtPlatformService imple
platformName = PlatformType.Chromium;

getNewTabUrl(): string {
switch (detectBrowser.detect().name) {
const browser = this.utilitySvc.isBraveBrowser() ? BrowserName.Brave : detectBrowser.detect().name;
switch (browser) {
case BrowserName.Brave:
return 'brave://newtab/';
case BrowserName.Edge:
return 'edge://newtab/';
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import AlertService from '../../shared/alert/alert.service';
import BookmarkHelperService from '../../shared/bookmark/bookmark-helper/bookmark-helper.service';
import * as Exceptions from '../../shared/exception/exception';
import Globals from '../../shared/global-shared.constants';
import { MessageCommand } from '../../shared/global-shared.enum';
import { BrowserName, MessageCommand } from '../../shared/global-shared.enum';
import { Message, PlatformService } from '../../shared/global-shared.interface';
import LogService from '../../shared/log/log.service';
import NetworkService from '../../shared/network/network.service';
Expand Down Expand Up @@ -252,23 +252,24 @@ export default class WebExtBackgroundService {
this.platformSvc.getAppVersion(),
this.settingsSvc.all(),
this.storeSvc.get([StoreKey.LastUpdated, StoreKey.SyncId, StoreKey.SyncVersion]),
this.upgradeSvc.checkIfUpgradeRequired(this.getCurrentVersion()),
this.utilitySvc.getServiceUrl(),
this.utilitySvc.isSyncEnabled(),
this.upgradeSvc.checkIfUpgradeRequired(this.getCurrentVersion())
this.utilitySvc.isSyncEnabled()
])
.then((data) => {
const appVersion = data[0];
const settings = data[1];
const storeContent = data[2];
const serviceUrl = data[3];
const syncEnabled = data[4];
const upgradeRequired = data[5];
const upgradeRequired = data[3];
const serviceUrl = data[4];
const syncEnabled = data[5];

// Add useful debug info to beginning of trace log
const debugInfo = angular.copy(storeContent) as any;
debugInfo.appVersion = appVersion;
debugInfo.checkForAppUpdates = settings.checkForAppUpdates;
debugInfo.platform = detectBrowser.detect();
debugInfo.platform.name = this.utilitySvc.isBraveBrowser() ? BrowserName.Brave : debugInfo.platform.name;
debugInfo.serviceUrl = serviceUrl;
debugInfo.syncBookmarksToolbar = settings.syncBookmarksToolbar;
debugInfo.syncEnabled = syncEnabled;
Expand Down

0 comments on commit bac3cb7

Please sign in to comment.