Skip to content

Commit d1eb928

Browse files
aleksei-cliqzalver-cliqz
authored andcommitted
DB-2411: fix freshtab url load
1 parent 7100a2a commit d1eb928

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

mozilla-release/browser/base/content/browser.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,6 @@ var gInitialPages = [
659659
"about:cliqz",
660660
"about:welcome",
661661
"about:newinstall",
662-
#endif
663-
CliqzResources.getFreshTabUrl(),
664-
#if 0
665662
];
666663

667664
function isInitialPage(url) {
@@ -2265,11 +2262,33 @@ var gBrowserInit = {
22652262
return;
22662263
}
22672264

2265+
let aboutNewTabURL = gAboutNewTabService.defaultURL;
2266+
if (aboutNewTabURL === "about:newtab") {
2267+
// CLIQZ-SPECIAL: DB-2411, we assign moz-extension url to newTabURL in AboutNewTabService;
2268+
// Sometimes it gets reset to default value "about:newtab" resetting
2269+
// the value having come from the extension.
2270+
// We need this hack for that kind of problem.
2271+
// TODO: find cases when newTabURL is reset.
2272+
// See AboutNewTabService#setter newTabURL;
2273+
aboutNewTabURL = CliqzResources.whatIstheURL('freshtab/home.html');
2274+
}
2275+
22682276
// We don't check if uriToLoad is a XULElement because this case has
22692277
// already been handled before first paint, and the argument cleared.
22702278
if (Array.isArray(uriToLoad)) {
22712279
// This function throws for certain malformed URIs, so use exception handling
22722280
// so that we don't disrupt startup
2281+
2282+
// CLIQZ-SPECIAL: DB-2411, we should not load a freshtab url directly here.
2283+
// Instead we delegate it to AboutRedirector.cpp.
2284+
// That is any uri which is explicitly set as a freshtab moz-extension we
2285+
// assign a default home page value as a string (in most cases about:home);
2286+
// gAboutNewTabService.defaultURL has an explicit freshtab url.
2287+
// Same rule is applicable for other two cases below.
2288+
uriToLoad = uriToLoad.map((uri) => {
2289+
return uri === aboutNewTabURL ? HomePage.getAsString(true) : uri;
2290+
});
2291+
22732292
try {
22742293
gBrowser.loadTabs(uriToLoad, {
22752294
inBackground: false,
@@ -2285,6 +2304,8 @@ var gBrowserInit = {
22852304
});
22862305
} catch (e) {}
22872306
} else if (window.arguments.length >= 3) {
2307+
// CLIQZ-SPECIAL: DB-2411
2308+
uriToLoad = uriToLoad === aboutNewTabURL ? HomePage.getAsString(true) : uriToLoad;
22882309
// window.arguments[1]: unused (bug 871161)
22892310
// [2]: referrerInfo (nsIReferrerInfo)
22902311
// [3]: postData (nsIInputStream)
@@ -2318,6 +2339,8 @@ var gBrowserInit = {
23182339
);
23192340
window.focus();
23202341
} else {
2342+
// CLIQZ-SPECIAL: DB-2411
2343+
uriToLoad = uriToLoad === aboutNewTabURL ? HomePage.getAsString(true) : uriToLoad;
23212344
// Note: loadOneOrMoreURIs *must not* be called if window.arguments.length >= 3.
23222345
// Such callers expect that window.arguments[0] is handled as a single URI.
23232346
loadOneOrMoreURIs(

mozilla-release/browser/components/CliqzResources.jsm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const CliqzResources = {
3939
case 'chrome://cliqz/content/onboarding-v3/index.html':
4040
case 'resource://cliqz/freshtab/home.html':
4141
case 'about:welcome':
42-
return this.getFreshTabUrl();
42+
return 'about:home';
4343

4444
default:
4545
return key;
@@ -67,7 +67,6 @@ const CliqzResources = {
6767
},
6868
whatIstheURL: (u) => `${getWebExtPrefix()}/modules/${u}`,
6969
getExtensionURL: (path, extensionId = DEFAULT_EXTENSION_ID) => `${getWebExtPrefix(extensionId)}${path}`,
70-
getFreshTabUrl: () => `${getWebExtPrefix()}/modules/freshtab/home.html`,
7170
getUrlWithProperExtentionId: function(url = '') {
7271
if (!url || typeof url != 'string') {
7372
return url;

mozilla-release/browser/components/newtab/AboutNewTabService.jsm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ AboutNewTabService.prototype = {
265265
const results = Services.cpmm.sendSyncMessage("AboutNewTabService:Parent:getStartupFreshtabUrl");
266266
return results[0];
267267
} else {
268-
this.newTabURL;
268+
return this.newTabURL;
269269
}
270270
#if 0
271271
return [

mozilla-release/browser/modules/HomePage.jsm

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,6 @@ function getHomepagePref(useDefault) {
5353
homePage = getHomepagePref(true);
5454
}
5555

56-
if (homePage === kDefaultHomePage) {
57-
// CLIQZ-SPECIAL: in case of homePage ends up with "about:home"
58-
// this url will be handled by AboutRedirector.cpp which in turn
59-
// will go to AboutNewTabService to get a defaultUrl value.
60-
// Then this value will be retrieved from extension manifest.json.
61-
// To workaround that path we can get the freshtab url from
62-
// CliqzResources.
63-
const { CliqzResources } = ChromeUtils.import(
64-
"resource:///modules/CliqzResources.jsm"
65-
);
66-
homePage = CliqzResources.getFreshTabUrl();
67-
}
68-
6956
return homePage;
7057
}
7158

mozilla-release/toolkit/components/extensions/webrequest/WebRequest.jsm

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ const { PrivateBrowsingUtils } = ChromeUtils.import(
2323
const autoForgetTabs= Cc["@cliqz.com/browser/auto_forget_tabs_service;1"].
2424
getService(Ci.nsISupports).wrappedJSObject;
2525

26-
const { CliqzResources } = ChromeUtils.import(
27-
"resource:///modules/CliqzResources.jsm"
28-
);
29-
3026
XPCOMUtils.defineLazyModuleGetters(this, {
3127
ExtensionUtils: "resource://gre/modules/ExtensionUtils.jsm",
3228
WebRequestUpload: "resource://gre/modules/WebRequestUpload.jsm",
@@ -708,7 +704,6 @@ HttpObserverManager = {
708704
const { finalURL, originURL } = channel;
709705
const { gBrowser, openLinkIn, openTrustedLinkIn } = channel.browserElement.ownerGlobal;
710706
const { selectedTab, tabs = [] } = gBrowser;
711-
const freshTabURL = CliqzResources.getFreshTabUrl();
712707
const otherWin = openLinkIn(
713708
finalURL,
714709
"window",
@@ -757,7 +752,7 @@ HttpObserverManager = {
757752
// Deletes the tab if there is no history path
758753
if (!gBrowser.webNavigation.canGoBack) {
759754
if (tabs.length === 1) {
760-
openTrustedLinkIn(freshTabURL, "tab");
755+
openTrustedLinkIn("about:home", "tab");
761756
}
762757
gBrowser.removeTab(selectedTab);
763758
}

0 commit comments

Comments
 (0)