1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 05:43:41 +00:00

safari api implementations. hide popout

This commit is contained in:
Kyle Spearrin
2018-01-12 20:57:25 -05:00
parent 4fc21767be
commit 7467c220e1
11 changed files with 33 additions and 13 deletions

View File

@@ -129,17 +129,24 @@ class BrowserApi {
if (BrowserApi.isChromeApi) { if (BrowserApi.isChromeApi) {
return chrome.extension.getViews({ type: 'popup' }).length > 0; return chrome.extension.getViews({ type: 'popup' }).length > 0;
} else if (BrowserApi.isSafariApi) { } else if (BrowserApi.isSafariApi) {
return true; // TODO return safari.extension.popovers && safari.extension.popovers.length &&
safari.extension.popovers[0].visible;
} else { } else {
return null; return null;
} }
} }
static createNewTab(url: string): void { static createNewTab(url: string, extensionPage: boolean = false): void {
if (BrowserApi.isChromeApi) { if (BrowserApi.isChromeApi) {
chrome.tabs.create({ url: url }); chrome.tabs.create({ url: url });
} else if (BrowserApi.isSafariApi) { } else if (BrowserApi.isSafariApi) {
return; // TODO if (extensionPage && url.indexOf('/') === 0) {
url = BrowserApi.getAssetUrl(url);
}
const tab = safari.application.activeBrowserWindow.browserWindow.openTab();
if (tab) {
tab.url = url;
}
} else { } else {
return; return;
} }
@@ -149,7 +156,10 @@ class BrowserApi {
if (BrowserApi.isChromeApi) { if (BrowserApi.isChromeApi) {
return chrome.extension.getURL(path); return chrome.extension.getURL(path);
} else if (BrowserApi.isSafariApi) { } else if (BrowserApi.isSafariApi) {
return './' + path; // TODO? if (path.indexOf('/') === 0) {
path = path.substr(1);
}
return safari.extension.baseURI + path;
} else { } else {
return null; return null;
} }

View File

@@ -183,8 +183,9 @@ angular
params = providers[constants.twoFactorProvider.email]; params = providers[constants.twoFactorProvider.email];
$scope.twoFactorEmail = params.Email; $scope.twoFactorEmail = params.Email;
if (BrowserApi.isPopupOpen() && !popupUtilsService.inSidebar($window) && if (!platformUtilsService.isSafari() && BrowserApi.isPopupOpen() &&
!popupUtilsService.inTab($window) && !popupUtilsService.inPopout($window)) { !popupUtilsService.inSidebar($window) && !popupUtilsService.inTab($window) &&
!popupUtilsService.inPopout($window)) {
SweetAlert.swal({ SweetAlert.swal({
title: i18nService.twoStepLogin, title: i18nService.twoStepLogin,
text: i18nService.popup2faCloseMessage, text: i18nService.popup2faCloseMessage,
@@ -193,7 +194,7 @@ angular
cancelButtonText: i18nService.no cancelButtonText: i18nService.no
}, function (confirmed) { }, function (confirmed) {
if (confirmed) { if (confirmed) {
BrowserApi.createNewTab('/popup/index.html?uilocation=tab#!/login'); BrowserApi.createNewTab('/popup/index.html?uilocation=tab#!/login', true);
return; return;
} }
else if (Object.keys(providers).length > 1) { else if (Object.keys(providers).length > 1) {

View File

@@ -1,5 +1,7 @@
import * as template from './pop-out.component.html'; import * as template from './pop-out.component.html';
import { BrowserApi } from '../../../browser/browserApi';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import PopupUtilsService from '../services/popupUtils.service'; import PopupUtilsService from '../services/popupUtils.service';
@@ -52,7 +54,7 @@ export class PopOutController implements ng.IController {
url: href, url: href,
}); });
} else if ((typeof safari !== 'undefined')) { } else if ((typeof safari !== 'undefined')) {
// TODO? // Safari can't open popup in full page tab :(
} }
} }
} }

View File

@@ -1,5 +1,5 @@
<div class="header header-search"> <div class="header header-search">
<pop-out ng-if="!$ctrl.inSidebar" class="left"></pop-out> <pop-out ng-if="$ctrl.showPopout" class="left"></pop-out>
<div class="left" ng-if="$ctrl.inSidebar"> <div class="left" ng-if="$ctrl.inSidebar">
<a href="" ng-click="$ctrl.refresh()" title="{{::$ctrl.i18n.refresh}}"><i class="fa fa-refresh fa-lg"></i></a> <a href="" ng-click="$ctrl.refresh()" title="{{::$ctrl.i18n.refresh}}"><i class="fa fa-refresh fa-lg"></i></a>
</div> </div>

View File

@@ -24,6 +24,7 @@ export class CurrentController {
canAutofill: boolean = false; canAutofill: boolean = false;
searchText: string = null; searchText: string = null;
inSidebar: boolean = false; inSidebar: boolean = false;
showPopout: boolean = true;
disableSearch: boolean = false; disableSearch: boolean = false;
constructor($scope: any, private cipherService: CipherService, private platformUtilsService: PlatformUtilsService, constructor($scope: any, private cipherService: CipherService, private platformUtilsService: PlatformUtilsService,
@@ -32,6 +33,7 @@ export class CurrentController {
private $analytics: any, private i18nService: any, private $filter: ng.IFilterService) { private $analytics: any, private i18nService: any, private $filter: ng.IFilterService) {
this.i18n = i18nService; this.i18n = i18nService;
this.inSidebar = PopupUtilsService.inSidebar($window); this.inSidebar = PopupUtilsService.inSidebar($window);
this.showPopout = !this.inSidebar && !platformUtilsService.isSafari();
this.disableSearch = platformUtilsService.isEdge(); this.disableSearch = platformUtilsService.isEdge();
$scope.$on('syncCompleted', (event: any, successfully: boolean) => { $scope.$on('syncCompleted', (event: any, successfully: boolean) => {

View File

@@ -1,5 +1,5 @@
<div class="header"> <div class="header">
<pop-out class="left"></pop-out> <pop-out ng-if="$ctrl.showPopout" class="left"></pop-out>
<div class="title">{{$ctrl.i18n.settings}}</div> <div class="title">{{$ctrl.i18n.settings}}</div>
</div> </div>
<div class="content content-tabs"> <div class="content content-tabs">

View File

@@ -27,13 +27,14 @@ const RateUrls = {
[DeviceType.Vivaldi]: [DeviceType.Vivaldi]:
'https://chrome.google.com/webstore/detail/bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb/reviews', 'https://chrome.google.com/webstore/detail/bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb/reviews',
[DeviceType.Safari]: [DeviceType.Safari]:
'https://itunes.com', // TODO 'https://itunes.apple.com/app/bitwarden-password-manager/id1137397744',
}; };
export class SettingsController { export class SettingsController {
lockOption = ''; lockOption = '';
i18n: any; i18n: any;
showOnLocked: boolean; showOnLocked: boolean;
showPopout: boolean = true;
constructor(private $state: any, private SweetAlert: any, constructor(private $state: any, private SweetAlert: any,
private platformUtilsService: PlatformUtilsService, private $analytics: any, private platformUtilsService: PlatformUtilsService, private $analytics: any,
@@ -42,6 +43,7 @@ export class SettingsController {
private storageService: StorageService, public messagingService: MessagingService, private storageService: StorageService, public messagingService: MessagingService,
private $timeout: ng.ITimeoutService) { private $timeout: ng.ITimeoutService) {
this.i18n = i18nService; this.i18n = i18nService;
this.showPopout = !platformUtilsService.isSafari();
$timeout(() => { $timeout(() => {
PopupUtilsService.initListSectionItemListeners(document, angular); PopupUtilsService.initListSectionItemListeners(document, angular);

View File

@@ -1,5 +1,5 @@
<div class="header"> <div class="header">
<pop-out class="left"></pop-out> <pop-out ng-if="$ctrl.showPopout" class="left"></pop-out>
<div class="title">{{$ctrl.i18n.tools}}</div> <div class="title">{{$ctrl.i18n.tools}}</div>
</div> </div>
<div class="content content-tabs"> <div class="content content-tabs">

View File

@@ -7,6 +7,7 @@ import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
export class ToolsController { export class ToolsController {
showExport: boolean; showExport: boolean;
showPopout: boolean = true;
i18n: any; i18n: any;
private webVaultBaseUrl: string = 'https://vault.bitwarden.com'; private webVaultBaseUrl: string = 'https://vault.bitwarden.com';
@@ -15,6 +16,7 @@ export class ToolsController {
private environmentService: EnvironmentService) { private environmentService: EnvironmentService) {
this.i18n = i18nService; this.i18n = i18nService;
this.showExport = !platformUtilsService.isEdge(); this.showExport = !platformUtilsService.isEdge();
this.showPopout = !platformUtilsService.isSafari();
if (environmentService.baseUrl) { if (environmentService.baseUrl) {
this.webVaultBaseUrl = environmentService.baseUrl; this.webVaultBaseUrl = environmentService.baseUrl;
} else if (environmentService.webVaultUrl) { } else if (environmentService.webVaultUrl) {

View File

@@ -10,6 +10,7 @@ angular
$scope.i18n = i18nService; $scope.i18n = i18nService;
$scope.showGroupingCounts = !platformUtilsService.isEdge(); $scope.showGroupingCounts = !platformUtilsService.isEdge();
$scope.disableSearch = platformUtilsService.isEdge(); $scope.disableSearch = platformUtilsService.isEdge();
$scope.showPopout = !platformUtilsService.isSafari();
document.getElementById('search').focus(); document.getElementById('search').focus();
var syncOnLoad = $stateParams.syncOnLoad; var syncOnLoad = $stateParams.syncOnLoad;

View File

@@ -1,5 +1,5 @@
<div class="header header-search"> <div class="header header-search">
<pop-out class="left"></pop-out> <pop-out ng-if="showPopout" class="left"></pop-out>
<div class="search" ng-style="{'visibility': disableSearch ? 'hidden' : 'visible'}"> <div class="search" ng-style="{'visibility': disableSearch ? 'hidden' : 'visible'}">
<input type="search" placeholder="{{::i18n.searchVault}}" id="search" ng-model="searchText" /> <input type="search" placeholder="{{::i18n.searchVault}}" id="search" ng-model="searchText" />
<i class="fa fa-search"></i> <i class="fa fa-search"></i>