Commit c45a94e1 authored by Raine Makelainen's avatar Raine Makelainen

Merge branch 'rebase-fix' into 'master'

[embedlite-components] Fix Gecko38 rebase errors

This aligns content between nemo_embedlite_38 and master
branches. Noticed that "embedui:addhistory" got duplicated
in embedhelper.js and noticed small glitches in UserAgentOverrideHelper.

Noticed errors right after merging MR:
https://git.merproject.org/mer-core/embedlite-components/merge_requests/20

See merge request !21
parents 22c159bf 8b91c9dc
......@@ -51,8 +51,7 @@ UserAgentOverrideHelper.prototype = {
},
getUserAgentForURIAndWindow: function ssua_getUserAgentForURIAndWindow(aURI, aWindow) {
// aWindow is unused / not needed.
return UserAgent.getUserAgentForWindow(aURI)
return UserAgent.getUserAgentForWindow(aURI, aWindow, true)
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsISiteSpecificUserAgent, Ci.nsIObserver,
......@@ -103,7 +102,7 @@ var UserAgent = {
if (this._desktopMode)
return this.DESKTOP_UA;
return this._customUA ? this._customUA : defaultUA;
return this._customUA ? this._customUA : this.DESKTOP_UA;
},
getUserAgentForUriAndTab: function ua_getUserAgentForUriAndTab(aUri) {
......@@ -154,19 +153,27 @@ var UserAgent = {
if (this.overrideMap.has(host)) {
ua = this.overrideMap.get(host);
} else if (this.overrideMap.has(windowHost)) {
} else if (this.currentHost && (this.currentHost == windowHost) && this.overrideMap.has(windowHost)) {
ua = this.overrideMap.get(windowHost);
} else {
ua = this.getUserAgentForWindow(channel.URI);
ua = this.getUserAgentForWindow(channel.URI, channelWindow, false);
}
return ua
},
// Called if onRequest returns empty user-agent.
getUserAgentForWindow: function ua_getUserAgentForWindow(aUri) {
getUserAgentForWindow: function ua_getUserAgentForWindow(aUri, aWindow, aIsCurrentHost) {
// Try to pick 'general.useragent.override.*'
let ua = UserAgentOverrides.getOverrideForURI(aUri)
if (aIsCurrentHost) {
this.currentHost = aUri.asciiHost;
if (aWindow) {
aWindow.addEventListener("beforeunload", this, true);
}
}
if (!ua) {
ua = this.getUserAgentForUriAndTab(aUri);
}
......@@ -179,6 +186,15 @@ var UserAgent = {
return this.getDefaultUserAgent();
},
handleEvent: function(aEvent) {
switch (aEvent.type) {
case "beforeunload": {
this.currentHost = "";
break;
}
}
},
_getRequestLoadContext: function ua_getRequestLoadContext(aRequest) {
if (aRequest && aRequest.notificationCallbacks) {
try {
......
......@@ -341,35 +341,6 @@ EmbedHelper.prototype = {
docShell.setCurrentURI(initialURI);
break;
}
case "embedui:addhistory": {
// aMessage.data contains: 1) list of 'links' loaded from DB, 2) current 'index'.
let webNav = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation);
let docShell = webNav.QueryInterface(Ci.nsIDocShell);
let shist = webNav.sessionHistory.QueryInterface(Ci.nsISHistoryInternal);
try {
// Initially we load the current URL and that creates an unneeded entry in History -> purge it.
webNav.sessionHistory.PurgeHistory(1);
} catch (e) {
dump("Warning: couldn't PurgeHistory. Was it a file download?\n");
}
aMessage.data.links.forEach(function(link) {
let uri = Cc["@mozilla.org/network/standard-url;1"].createInstance(Ci.nsIURI);
let historyEntry = Cc["@mozilla.org/browser/session-history-entry;1"].createInstance(Ci.nsISHEntry);
uri.spec = link;
historyEntry.setURI(uri);
shist.addEntry(historyEntry, true);
});
webNav.sessionHistory.getEntryAtIndex(aMessage.data.index, true);
shist.updateIndex();
let initialURI = Cc["@mozilla.org/network/standard-url;1"].createInstance(Ci.nsIURI);
initialURI.spec = aMessage.data.links[aMessage.data.index];
docShell.setCurrentURI(initialURI);
break;
}
case "Memory:Dump": {
if (aMessage.data && aMessage.data.fileName) {
let memDumper = Cc["@mozilla.org/memory-info-dumper;1"].getService(Ci.nsIMemoryInfoDumper);
......
......@@ -61,5 +61,3 @@ touch /var/lib/_MOZEMBED_CACHE_CLEAN_
%files
%defattr(-,root,root,-)
%{_libdir}/mozembedlite/*
%exclude %{_libdir}/mozembedlite/chrome/embedlite/content/duckduckgo.xml
%exclude %{_libdir}/mozembedlite/chrome/embedlite/content/baidu.xml
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment