Bug 658245 - Part 1: pref to open bookmark in a new tab. r=mak
MozReview-Commit-ID: A8nhmBjbNGh
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -455,16 +455,17 @@ pref("browser.tabs.insertRelatedAfterCur
pref("browser.tabs.warnOnClose", true);
pref("browser.tabs.warnOnCloseOtherTabs", true);
pref("browser.tabs.warnOnOpen", true);
pref("browser.tabs.maxOpenBeforeWarn", 15);
pref("browser.tabs.loadInBackground", true);
pref("browser.tabs.opentabfor.middleclick", true);
pref("browser.tabs.loadDivertedInBackground", false);
pref("browser.tabs.loadBookmarksInBackground", false);
+pref("browser.tabs.loadBookmarksInTabs", false);
pref("browser.tabs.tabClipWidth", 140);
#ifdef UNIX_BUT_NOT_MAC
pref("browser.tabs.drawInTitlebar", false);
#else
pref("browser.tabs.drawInTitlebar", true);
#endif
// 0 - Disable the tabbar session restore button.
--- a/browser/components/places/PlacesUIUtils.jsm
+++ b/browser/components/places/PlacesUIUtils.jsm
@@ -35,16 +35,18 @@ XPCOMUtils.defineLazyModuleGetter(this,
const gInContentProcess = Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT;
const FAVICON_REQUEST_TIMEOUT = 60 * 1000;
// Map from windows to arrays of data about pending favicon loads.
let gFaviconLoadDataMap = new Map();
// copied from utilityOverlay.js
const TAB_DROP_TYPE = "application/x-moz-tabbrowser-tab";
+const PREF_LOAD_BOOKMARKS_IN_BACKGROUND = "browser.tabs.loadBookmarksInBackground";
+const PREF_LOAD_BOOKMARKS_IN_TABS = "browser.tabs.loadBookmarksInTabs";
// This function isn't public both because it's synchronous and because it is
// going to be removed in bug 1072833.
function IsLivemark(aItemId) {
// Since this check may be done on each dragover event, it's worth maintaining
// a cache.
let self = IsLivemark;
if (!("ids" in self)) {
@@ -1013,30 +1015,37 @@ this.PlacesUIUtils = {
* An uri result node.
* @param aEvent
* The DOM mouse/key event with modifier keys set that track the
* user's preferred destination window or tab.
*/
openNodeWithEvent:
function PUIU_openNodeWithEvent(aNode, aEvent) {
let window = aEvent.target.ownerGlobal;
- this._openNodeIn(aNode, window.whereToOpenLink(aEvent, false, true), window);
+
+ let where = window.whereToOpenLink(aEvent, false, true);
+ if (where == "current" && this.loadBookmarksInTabs &&
+ PlacesUtils.nodeIsBookmark(aNode) && !aNode.uri.startsWith("javascript:")) {
+ where = "tab";
+ }
+
+ this._openNodeIn(aNode, where, window);
},
/**
* Loads the node's URL in the appropriate tab or window or as a
* web panel.
* see also openUILinkIn
*/
openNodeIn: function PUIU_openNodeIn(aNode, aWhere, aView, aPrivate) {
let window = aView.ownerWindow;
this._openNodeIn(aNode, aWhere, window, aPrivate);
},
- _openNodeIn: function PUIU_openNodeIn(aNode, aWhere, aWindow, aPrivate = false) {
+ _openNodeIn: function PUIU__openNodeIn(aNode, aWhere, aWindow, aPrivate = false) {
if (aNode && PlacesUtils.nodeIsURI(aNode) &&
this.checkURLSecurity(aNode, aWindow)) {
let isBookmark = PlacesUtils.nodeIsBookmark(aNode);
if (!PrivateBrowsingUtils.isWindowPrivate(aWindow)) {
if (isBookmark)
this.markPageAsFollowedBookmark(aNode.uri);
else
@@ -1053,17 +1062,17 @@ this.PlacesUIUtils = {
browserWin.openWebPanel(aNode.title, aNode.uri);
return;
}
}
}
aWindow.openUILinkIn(aNode.uri, aWhere, {
allowPopups: aNode.uri.startsWith("javascript:"),
- inBackground: Services.prefs.getBoolPref("browser.tabs.loadBookmarksInBackground"),
+ inBackground: this.loadBookmarksInBackground,
private: aPrivate,
});
}
},
/**
* Helper for guessing scheme from an url string.
* Used to avoid nsIURI overhead in frequently called UI functions.
@@ -1520,16 +1529,21 @@ XPCOMUtils.defineLazyGetter(PlacesUIUtil
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "useAsyncTransactions", function() {
try {
return Services.prefs.getBoolPref("browser.places.useAsyncTransactions");
} catch (ex) { }
return false;
});
+XPCOMUtils.defineLazyPreferenceGetter(PlacesUIUtils, "loadBookmarksInBackground",
+ PREF_LOAD_BOOKMARKS_IN_BACKGROUND, false);
+XPCOMUtils.defineLazyPreferenceGetter(PlacesUIUtils, "loadBookmarksInTabs",
+ PREF_LOAD_BOOKMARKS_IN_TABS, false);
+
XPCOMUtils.defineLazyServiceGetter(this, "URIFixup",
"@mozilla.org/docshell/urifixup;1",
"nsIURIFixup");
XPCOMUtils.defineLazyGetter(this, "bundle", function() {
const PLACES_STRING_BUNDLE_URI =
"chrome://browser/locale/places/places.properties";
return Cc["@mozilla.org/intl/stringbundle;1"].