Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Bug #18886: When Pocket is disabled, hide its button and menuitem
Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions .
+29
−0
src/chrome/content/torbutton.js
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -21,6 +21,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "WebConsoleUtils",
let { LoadContextInfo } = Cu . import ( 'resource://gre/modules/LoadContextInfo.jsm' ) ;
let { Services } = Cu . import ( "resource://gre/modules/Services.jsm" ) ;
let { bindPrefAndInit } = Cu . import ( "resource://torbutton/modules/utils.js" ) ;
const k_tb_last_browser_version_pref = "extensions.torbutton.lastBrowserVersion" ;
const k_tb_browser_update_needed_pref = "extensions.torbutton.updateNeeded" ;
@@ -645,6 +646,7 @@ function torbutton_init() {
torbutton_update_toolbutton ( mode ) ;
torbutton_update_statusbar ( mode ) ;
torbutton_notify_if_update_needed ( ) ;
torbutton_bind_pocket_ui_to_pref ( ) ;
createTorCircuitDisplay ( m_tb_control_host , m_tb_control_port , m_tb_control_pass ,
"extensions.torbutton.display_circuit" ) ;
@@ -3586,4 +3588,31 @@ function torbutton_is_homepage_url(aURI)
return ( urls . indexOf ( aURI . spec ) >= 0 ) ;
}
// Ensure that Pocket button and menu items are only visible the
// "browser.pocket.enabled" pref is true.
function torbutton_bind_pocket_ui_to_pref ( )
{
try {
let pocketMenuItem = document . getElementById ( "menu_pocket" ) ,
pocketMenuSeparator = document . getElementById ( "menu_pocketSeparator" ) ,
menu = pocketMenuItem . parentElement ,
nextMenuItem = pocketMenuSeparator . nextSibling ,
pocketButton = document . getElementById ( "pocket-button" ) ;
bindPrefAndInit ( "browser.pocket.enabled" , function ( enabled ) {
if ( enabled ) {
menu . insertBefore ( pocketMenuItem , nextMenuItem ) ;
menu . insertBefore ( pocketMenuSeparator , nextMenuItem ) ;
} else {
menu . removeChild ( pocketMenuItem ) ;
menu . removeChild ( pocketMenuSeparator ) ;
}
if ( pocketButton !== null ) {
pocketButton . hidden = ! enabled ;
}
} ) ;
} catch ( e ) {
torbutton_log ( 5 , 'ERROR: failed to bind Pocket UI to "browser.pocket.enabled" pref' ) ;
}
}
//vim:set ts=4
Toggle all file notes
Toggle all file annotations