Bug 937253 - Make pinned tabs work for Homescreen shortcuts r=bnicholson

--HG--
extra : rebase_source : 115614b5980ef885b6732196607930ad4dd3ce2d
This commit is contained in:
Mark Finkle 2015-01-07 23:53:28 -05:00
parent 97e7dcba51
commit f94bab0c79
5 changed files with 21 additions and 23 deletions

View File

@ -1200,13 +1200,13 @@ public class BrowserApp extends GeckoApp
}
@Override
protected void loadStartupTab(String url) {
protected void loadStartupTab(String url, int flags) {
// We aren't showing about:home, so cancel the telemetry timer
if (url != null || mShouldRestore) {
mAboutHomeStartupTimer.cancel();
}
super.loadStartupTab(url);
super.loadStartupTab(url, flags);
}
private void setToolbarMargin(int margin) {

View File

@ -1438,16 +1438,15 @@ public abstract class GeckoApp
*
* @param url External URL to load, or null to load the default URL
*/
protected void loadStartupTab(String url) {
protected void loadStartupTab(String url, int flags) {
if (url == null) {
if (!mShouldRestore) {
// Show about:home if we aren't restoring previous session and
// there's no external URL.
Tabs.getInstance().loadUrl(AboutPages.HOME, Tabs.LOADURL_NEW_TAB);
Tabs.getInstance().loadUrl(AboutPages.HOME, flags);
}
} else {
// If given an external URL, load it
int flags = Tabs.LOADURL_NEW_TAB | Tabs.LOADURL_USER_ENTERED | Tabs.LOADURL_EXTERNAL;
Tabs.getInstance().loadUrl(url, flags);
}
}
@ -1514,10 +1513,14 @@ public abstract class GeckoApp
// Restore tabs before opening an external URL so that the new tab
// is animated properly.
Tabs.getInstance().notifyListeners(null, Tabs.TabEvents.RESTORED);
loadStartupTab(passedUri);
int flags = Tabs.LOADURL_NEW_TAB | Tabs.LOADURL_USER_ENTERED | Tabs.LOADURL_EXTERNAL;
if (ACTION_HOMESCREEN_SHORTCUT.equals(action)) {
flags |= Tabs.LOADURL_PINNED;
}
loadStartupTab(passedUri, flags);
} else {
if (!mIsRestoringActivity) {
loadStartupTab(null);
loadStartupTab(null, Tabs.LOADURL_NEW_TAB);
}
Tabs.getInstance().notifyListeners(null, Tabs.TabEvents.RESTORED);

View File

@ -179,10 +179,11 @@ public class WebappImpl extends GeckoApp implements InstallCallback {
}
@Override
protected void loadStartupTab(String uri) {
protected void loadStartupTab(String uri, int flags) {
// Load a tab so it's available for any code that assumes a tab
// before the app tab itself is loaded in BrowserApp._loadWebapp.
super.loadStartupTab("about:blank");
flags = Tabs.LOADURL_NEW_TAB | Tabs.LOADURL_USER_ENTERED | Tabs.LOADURL_EXTERNAL;
super.loadStartupTab("about:blank", flags);
}
private void showSplash() {

View File

@ -3175,6 +3175,8 @@ nsBrowserAccess.prototype = {
}
}
// If OPEN_SWITCHTAB was not handled above, we need to open a new tab,
// along with other OPEN_ values that create a new tab.
let newTab = (aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW ||
aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWTAB ||
aWhere == Ci.nsIBrowserDOMWindow.OPEN_SWITCHTAB);
@ -3204,8 +3206,9 @@ nsBrowserAccess.prototype = {
// OPEN_CURRENTWINDOW and illegal values
let browser = BrowserApp.selectedBrowser;
if (aURI && browser)
if (aURI && browser) {
browser.loadURIWithFlags(aURI.spec, loadflags, referrer, null, null);
}
return browser;
},

View File

@ -17,7 +17,6 @@ function dump(a) {
function openWindow(aParent, aURL, aTarget, aFeatures, aArgs) {
let argsArray = Cc["@mozilla.org/supports-array;1"].createInstance(Ci.nsISupportsArray);
let urlString = null;
let pinnedBool = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
let widthInt = Cc["@mozilla.org/supports-PRInt32;1"].createInstance(Ci.nsISupportsPRInt32);
let heightInt = Cc["@mozilla.org/supports-PRInt32;1"].createInstance(Ci.nsISupportsPRInt32);
@ -27,12 +26,10 @@ function openWindow(aParent, aURL, aTarget, aFeatures, aArgs) {
}
widthInt.data = "width" in aArgs ? aArgs.width : 1;
heightInt.data = "height" in aArgs ? aArgs.height : 1;
pinnedBool.data = "pinned" in aArgs ? aArgs.pinned : false;
argsArray.AppendElement(urlString, false);
argsArray.AppendElement(widthInt, false);
argsArray.AppendElement(heightInt, false);
argsArray.AppendElement(pinnedBool, false);
return Services.ww.openWindow(aParent, aURL, aTarget, aFeatures, argsArray);
}
@ -66,7 +63,7 @@ BrowserCLH.prototype = {
openURL = aCmdLine.handleFlagWithParam("url", false);
} catch (e) { /* Optional */ }
try {
pinned = aCmdLine.handleFlag("webapp", false);
pinned = aCmdLine.handleFlag("bookmark", false);
} catch (e) { /* Optional */ }
try {
@ -86,22 +83,16 @@ BrowserCLH.prototype = {
let browserWin = Services.wm.getMostRecentWindow("navigator:browser");
if (browserWin) {
if (!pinned) {
browserWin.browserDOMWindow.openURI(uri, null, Ci.nsIBrowserDOMWindow.OPEN_NEWTAB, Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
}
let whereFlags = pinned ? Ci.nsIBrowserDOMWindow.OPEN_SWITCHTAB : Ci.nsIBrowserDOMWindow.OPEN_NEWTAB;
browserWin.browserDOMWindow.openURI(uri, null, whereFlags, Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
} else {
let args = {
url: openURL,
pinned: pinned,
width: width,
height: height,
};
// Make sure webapps do not have: locationbar, personalbar, menubar, statusbar, and toolbar
let flags = "chrome,dialog=no";
if (!pinned)
flags += ",all";
let flags = "chrome,dialog=no,all";
browserWin = openWindow(null, "chrome://browser/content/browser.xul", "_blank", flags, args);
}