Skip to content

Commit

Permalink
Initial UI support for Fennec
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVallat committed Mar 2, 2015
1 parent 2349df9 commit 2b60436
Show file tree
Hide file tree
Showing 11 changed files with 380 additions and 212 deletions.
29 changes: 28 additions & 1 deletion platform/firefox/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ const restartListener = {
}
};

const optionsObserver = {
observe: function (aSubject, aTopic, aData) {
if (aTopic === "addon-options-displayed" && aData === "{2b10c1c8-a11f-4bad-fe9c-1c11e82cac42}") {
var doc = aSubject;
setupOptionsButton(doc, "showDashboardButton", "dashboard.html");
setupOptionsButton(doc, "showNetworkLogButton", "devtools.html");
}
}
};

function setupOptionsButton(doc, id, page) {
var vAPI = bgProcess.contentWindow.vAPI;
var button = doc.getElementById(id);
button.addEventListener("command", function () {
vAPI.tabs.open({ url: vAPI.getURL(page), index: -1 });
});
button.label = vAPI.i18n(id);
}

/******************************************************************************/

function startup(data, reason) {
Expand Down Expand Up @@ -74,7 +93,11 @@ function startup(data, reason) {
);
};

if ( reason !== APP_STARTUP ) {
let obs = Components.classes['@mozilla.org/observer-service;1']
.getService(Components.interfaces.nsIObserverService);
obs.addObserver(optionsObserver, "addon-options-displayed", false);

if (reason !== APP_STARTUP) {
onReady();
return;
}
Expand Down Expand Up @@ -118,6 +141,10 @@ function shutdown(data, reason) {
hostName + '-restart',
restartListener
);

let obs = Components.classes['@mozilla.org/observer-service;1']
.getService(Components.interfaces.nsIObserverService);
obs.removeObserver(optionsObserver, "addon-options-displayed");
}

/******************************************************************************/
Expand Down
3 changes: 1 addition & 2 deletions platform/firefox/install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
<type>2</type>
<bootstrap>true</bootstrap>
<multiprocessCompatible>true</multiprocessCompatible>
<optionsType>3</optionsType>
<optionsURL>chrome://ublock/content/dashboard.html</optionsURL>
<optionsType>2</optionsType>
{localized}

<!-- Firefox -->
Expand Down
Loading

0 comments on commit 2b60436

Please sign in to comment.