Open howto when extension needs access to private windows

This commit is contained in:
ilyaigpetrov 2020-10-17 10:25:16 +00:00
parent 99a4ff9d24
commit 73485e8be4
5 changed files with 25 additions and 11 deletions

View File

@ -232,6 +232,15 @@ console.log('Extension started.');
}, },
openAndFocus(url) {
chrome.tabs.create(
{url: url},
(tab) => chrome.windows.update(tab.windowId, {focused: true})
);
},
}; };
const max = 2**16; const max = 2**16;

View File

@ -53,15 +53,6 @@
}; };
const openAndFocus = function openAndFocus(url) {
chrome.tabs.create(
{url: url},
(tab) => chrome.windows.update(tab.windowId, {focused: true})
);
};
const ifPrefix = 'if-on-'; const ifPrefix = 'if-on-';
const extName = chrome.runtime.getManifest().name; const extName = chrome.runtime.getManifest().name;
const extVersion = window.apis.version.build; const extVersion = window.apis.version.build;
@ -75,7 +66,7 @@
const errors = err ? {[type]: err} : this.idToError; const errors = err ? {[type]: err} : this.idToError;
const json = JSON.stringify(errors, errorJsonReplacer, 0); const json = JSON.stringify(errors, errorJsonReplacer, 0);
openAndFocus( window.utils.openAndFocus(
'https://rebrand.ly/ac-error/?json=' + encodeURIComponent(json) + 'https://rebrand.ly/ac-error/?json=' + encodeURIComponent(json) +
(type ? '&type=' + encodeURIComponent(type) : '') + (type ? '&type=' + encodeURIComponent(type) : '') +
'&version=' + chrome.runtime.getManifest().version + '&version=' + chrome.runtime.getManifest().version +
@ -242,7 +233,7 @@
chrome.notifications.clear(notId); chrome.notifications.clear(notId);
if(notId === 'no-control') { if(notId === 'no-control') {
return openAndFocus( return window.utils.openAndFocus(
window.utils.messages.searchSettingsForUrl('proxy') window.utils.messages.searchSettingsForUrl('proxy')
); );
} }

View File

@ -105,6 +105,14 @@
chrome.proxy.settings.set( { value: config }, chromified((err) => { chrome.proxy.settings.set( { value: config }, chromified((err) => {
if (err) { if (err) {
if (err.message === 'proxy.settings requires private browsing permission.') {
window.utils.openAndFocus('https://rebrand.ly/ac-allow-private-windows');
clarifyThen(
chrome.i18n.getMessage('AllowExtensionToRunInPrivateWindows'),
cb,
)(err);
return;
}
return cb(err); return cb(err);
} }
handlers.updateControlState( () => { handlers.updateControlState( () => {

View File

@ -136,5 +136,8 @@
}, },
"noOwnProxiesError": { "noOwnProxiesError": {
"message": "Proxying of OWN sites is possible only via OWN proxies. No own proxies found that satisfy your requirements." "message": "Proxying of OWN sites is possible only via OWN proxies. No own proxies found that satisfy your requirements."
},
"AllowExtensionToRunInPrivateWindows": {
"message": "For the extension to work it is required to allow it to run in private windows, see <a href='https://rebrand.ly/ac-allow-private-windows'>howto</a>."
} }
} }

View File

@ -136,5 +136,8 @@
}, },
"noOwnProxiesError": { "noOwnProxiesError": {
"message": "Проксировать СВОИ сайты можно только при наличии СВОИХ прокси. Нет своих прокси, удовлетворяющих вашим требованиям." "message": "Проксировать СВОИ сайты можно только при наличии СВОИХ прокси. Нет своих прокси, удовлетворяющих вашим требованиям."
},
"AllowExtensionToRunInPrivateWindows": {
"message": "Для работы расширения необходимо разрешить запуск в приватных окнах, см. <a href='https://rebrand.ly/ac-allow-private-windows'>инструкции</a>."
} }
} }