[BASILISK] Make Basilisk front-end use Weave

This commit is contained in:
wolfbeast 2018-12-01 23:40:09 +01:00 • committed by Roy Tam
commit 446ce70a66
7 changed files with 12 additions and 106 deletions

View file

@ -293,17 +293,13 @@ var gSyncUI = {
*/ */
openSetup: function SUI_openSetup(wizardType, entryPoint = "syncbutton") { openSetup: function SUI_openSetup(wizardType, entryPoint = "syncbutton") {
if (this.weaveService.fxAccountsEnabled) { let win = Services.wm.getMostRecentWindow("Weave:AccountSetup");
this.openPrefs(entryPoint); if (win)
} else { win.focus();
let win = Services.wm.getMostRecentWindow("Weave:AccountSetup"); else {
if (win) window.openDialog("chrome://browser/content/sync/setup.xul",
win.focus(); "weaveSetup", "centerscreen,chrome,resizable=no",
else { wizardType);
window.openDialog("chrome://browser/content/sync/setup.xul",
"weaveSetup", "centerscreen,chrome,resizable=no",
wizardType);
}
} }
}, },
@ -328,23 +324,6 @@ var gSyncUI = {
gFxAccounts.openSignInAgainPage(entryPoint); gFxAccounts.openSignInAgainPage(entryPoint);
}, },
openSyncedTabsPanel() {
let placement = CustomizableUI.getPlacementOfWidget("sync-button");
let area = placement ? placement.area : CustomizableUI.AREA_NAVBAR;
let anchor = document.getElementById("sync-button") ||
document.getElementById("PanelUI-menu-button");
if (area == CustomizableUI.AREA_PANEL) {
// The button is in the panel, so we need to show the panel UI, then our
// subview.
PanelUI.show().then(() => {
PanelUI.showSubView("PanelUI-remotetabs", anchor, area);
}).catch(Cu.reportError);
} else {
// It is placed somewhere else - just try and show it.
PanelUI.showSubView("PanelUI-remotetabs", anchor, area);
}
},
/* After Sync is initialized we perform a once-only check for the sync /* After Sync is initialized we perform a once-only check for the sync
button being in "customize purgatory" and if so, move it to the panel. button being in "customize purgatory" and if so, move it to the panel.
This is done primarily for profiles created before SyncedTabs landed, This is done primarily for profiles created before SyncedTabs landed,

View file

@ -6355,7 +6355,7 @@ function checkEmptyPageOrigin(browser = gBrowser.selectedBrowser,
} }
function BrowserOpenSyncTabs() { function BrowserOpenSyncTabs() {
gSyncUI.openSyncedTabsPanel(); switchToTabHavingURI("about:sync-tabs", true);
} }
/** /**

View file

@ -23,8 +23,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
"resource://gre/modules/CharsetMenu.jsm"); "resource://gre/modules/CharsetMenu.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm"); "resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SyncedTabs",
"resource://services-sync/SyncedTabs.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService", XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService",
"resource://gre/modules/ContextualIdentityService.jsm"); "resource://gre/modules/ContextualIdentityService.jsm");
@ -312,77 +310,6 @@ const CustomizableWidgets = [
obnode.setAttribute("element", "sync-status"); obnode.setAttribute("element", "sync-status");
obnode.setAttribute("attribute", "syncstatus"); obnode.setAttribute("attribute", "syncstatus");
aNode.appendChild(obnode); aNode.appendChild(obnode);
// A somewhat complicated dance to format the mobilepromo label.
let bundle = doc.getElementById("bundle_browser");
let formatArgs = ["android", "ios"].map(os => {
let link = doc.createElement("label");
link.textContent = bundle.getString(`appMenuRemoteTabs.mobilePromo.${os}`);
link.setAttribute("mobile-promo-os", os);
link.className = "text-link remotetabs-promo-link";
return link.outerHTML;
});
let promoParentElt = doc.getElementById("PanelUI-remotetabs-mobile-promo");
// Put it all together...
let contents = bundle.getFormattedString("appMenuRemoteTabs.mobilePromo.text2", formatArgs);
promoParentElt.innerHTML = contents;
// We manually manage the "click" event to open the promo links because
// allowing the "text-link" widget handle it has 2 problems: (1) it only
// supports button 0 and (2) it's tricky to intercept when it does the
// open and auto-close the panel. (1) can probably be fixed, but (2) is
// trickier without hard-coding here the knowledge of exactly what buttons
// it does support.
// So we allow left and middle clicks to open the link in a new tab and
// close the panel; not setting a "href" attribute prevents the text-link
// widget handling it, and we build the final URL in the click handler to
// make testing easier (ie, so tests can change the pref after the links
// were created and have the new pref value used.)
promoParentElt.addEventListener("click", e => {
let os = e.target.getAttribute("mobile-promo-os");
if (!os || e.button > 1) {
return;
}
let link = Services.prefs.getCharPref(`identity.mobilepromo.${os}`) + "synced-tabs";
doc.defaultView.openUILinkIn(link, "tab");
CustomizableUI.hidePanelForNode(e.target);
});
},
onViewShowing(aEvent) {
let doc = aEvent.target.ownerDocument;
this._tabsList = doc.getElementById("PanelUI-remotetabs-tabslist");
Services.obs.addObserver(this, SyncedTabs.TOPIC_TABS_CHANGED, false);
if (SyncedTabs.isConfiguredToSyncTabs) {
if (SyncedTabs.hasSyncedThisSession) {
this.setDeckIndex(this.deckIndices.DECKINDEX_TABS);
} else {
// Sync hasn't synced tabs yet, so show the "fetching" panel.
this.setDeckIndex(this.deckIndices.DECKINDEX_FETCHING);
}
// force a background sync.
SyncedTabs.syncTabs().catch(ex => {
Cu.reportError(ex);
});
// show the current list - it will be updated by our observer.
this._showTabs();
} else {
// not configured to sync tabs, so no point updating the list.
this.setDeckIndex(this.deckIndices.DECKINDEX_TABSDISABLED);
}
},
onViewHiding() {
Services.obs.removeObserver(this, SyncedTabs.TOPIC_TABS_CHANGED);
this._tabsList = null;
},
_tabsList: null,
observe(subject, topic, data) {
switch (topic) {
case SyncedTabs.TOPIC_TABS_CHANGED:
this._showTabs();
break;
default:
break;
}
}, },
setDeckIndex(index) { setDeckIndex(index) {
let deck = this._tabsList.ownerDocument.getElementById("PanelUI-remotetabs-deck"); let deck = this._tabsList.ownerDocument.getElementById("PanelUI-remotetabs-deck");

View file

@ -111,7 +111,7 @@
<vbox id="PanelUI-remotetabs-buttons"> <vbox id="PanelUI-remotetabs-buttons">
<toolbarbutton id="PanelUI-remotetabs-view-sidebar" <toolbarbutton id="PanelUI-remotetabs-view-sidebar"
class="subviewbutton" class="subviewbutton"
observes="viewTabsSidebar" oncommand="BrowserOpenSyncTabs();"
label="&appMenuRemoteTabs.sidebar.label;"/> label="&appMenuRemoteTabs.sidebar.label;"/>
<toolbarbutton id="PanelUI-remotetabs-syncnow" <toolbarbutton id="PanelUI-remotetabs-syncnow"
observes="sync-status" observes="sync-status"

View file

@ -349,7 +349,7 @@ These should match what Safari and other Apple applications use on OS X Lion. --
<!ENTITY appMenuRemoteTabs.openprefs.label "Sync Preferences"> <!ENTITY appMenuRemoteTabs.openprefs.label "Sync Preferences">
<!ENTITY appMenuRemoteTabs.notsignedin.label "Sign in to view a list of tabs from your other devices."> <!ENTITY appMenuRemoteTabs.notsignedin.label "Sign in to view a list of tabs from your other devices.">
<!ENTITY appMenuRemoteTabs.signin.label "Sign in to Sync"> <!ENTITY appMenuRemoteTabs.signin.label "Sign in to Sync">
<!ENTITY appMenuRemoteTabs.sidebar.label "View Synced Tabs Sidebar"> <!ENTITY appMenuRemoteTabs.sidebar.label "View Synced Tabs">
<!ENTITY customizeMenu.addToToolbar.label "Add to Toolbar"> <!ENTITY customizeMenu.addToToolbar.label "Add to Toolbar">
<!ENTITY customizeMenu.addToToolbar.accesskey "A"> <!ENTITY customizeMenu.addToToolbar.accesskey "A">

View file

@ -3,5 +3,5 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!ENTITY syncBrand.shortName.label "Sync"> <!ENTITY syncBrand.shortName.label "Sync">
<!ENTITY syncBrand.fullName.label "Firefox Sync"> <!ENTITY syncBrand.fullName.label "Pale Moon Sync">
<!ENTITY syncBrand.fxAccount.label "Firefox Account"> <!ENTITY syncBrand.fxAccount.label "Firefox Account">

View file

@ -16,7 +16,7 @@
<!-- New Account AND Existing Account --> <!-- New Account AND Existing Account -->
<!ENTITY server.label "Server"> <!ENTITY server.label "Server">
<!ENTITY serverType.default.label "Default: Mozilla &syncBrand.fullName.label; server"> <!ENTITY serverType.default.label "Default: &syncBrand.fullName.label; server">
<!ENTITY serverType.custom2.label "Use a custom server…"> <!ENTITY serverType.custom2.label "Use a custom server…">
<!ENTITY signIn.account2.label "Account"> <!ENTITY signIn.account2.label "Account">
<!ENTITY signIn.account2.accesskey "A"> <!ENTITY signIn.account2.accesskey "A">