bug 570788 - Incorporate improvements from SeaMonkey places review into Firefox code - round 1, r=sdwilsh

This commit is contained in:
Robert Kaiser 2010-06-09 23:50:38 +02:00
parent 155d247243
commit 70bc39dadd
3 changed files with 42 additions and 48 deletions

View File

@ -125,6 +125,26 @@ PlacesController.prototype = {
*/
_view: null,
supportsCommand: function PC_supportsCommand(aCommand) {
//LOG("supportsCommand: " + command);
// Non-Places specific commands that we also support
switch (aCommand) {
case "cmd_undo":
case "cmd_redo":
case "cmd_cut":
case "cmd_copy":
case "cmd_paste":
case "cmd_delete":
case "cmd_selectAll":
return true;
}
// All other Places Commands are prefixed with "placesCmd_" ... this
// filters out other commands that we do _not_ support (see 329587).
const CMD_PREFIX = "placesCmd_";
return (aCommand.substr(0, CMD_PREFIX.length) == CMD_PREFIX);
},
isCommandEnabled: function PC_isCommandEnabled(aCommand) {
switch (aCommand) {
case "cmd_undo":
@ -206,26 +226,6 @@ PlacesController.prototype = {
}
},
supportsCommand: function PC_supportsCommand(aCommand) {
//LOG("supportsCommand: " + command);
// Non-Places specific commands that we also support
switch (aCommand) {
case "cmd_undo":
case "cmd_redo":
case "cmd_cut":
case "cmd_copy":
case "cmd_paste":
case "cmd_delete":
case "cmd_selectAll":
return true;
}
// All other Places Commands are prefixed with "placesCmd_" ... this
// filters out other commands that we do _not_ support (see 329587).
const CMD_PREFIX = "placesCmd_";
return (aCommand.substr(0, CMD_PREFIX.length) == CMD_PREFIX);
},
doCommand: function PC_doCommand(aCommand) {
switch (aCommand) {
case "cmd_undo":

View File

@ -49,7 +49,7 @@ EXTRA_COMPONENTS = \
PlacesProtocolHandler.js \
$(NULL)
EXTRA_PP_JS_MODULES = \
EXTRA_JS_MODULES = \
PlacesUIUtils.jsm \
$(NULL)

View File

@ -48,11 +48,7 @@ var Cr = Components.results;
var Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "Services", function() {
Cu.import("resource://gre/modules/Services.jsm");
return Services;
});
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
Cu.import("resource://gre/modules/PlacesUtils.jsm");
@ -652,7 +648,7 @@ var PlacesUIUtils = {
var features;
if (aMinimalUI)
features = "centerscreen,chrome,dialog,resizable,modal";
features = "centerscreen,chrome,modal,resizable=yes";
else
features = "centerscreen,chrome,modal,resizable=no";
this._getCurrentActiveWin().openDialog(dialogURL, "", features, aInfo);
@ -682,7 +678,6 @@ var PlacesUIUtils = {
node.firstChild._placesView)
return node.firstChild._placesView;
// XXXmano: somehow we reach the xul document here!
while (node instanceof Ci.nsIDOMElement) {
if (node._placesView)
return node._placesView;
@ -739,19 +734,20 @@ var PlacesUIUtils = {
*
*/
checkURLSecurity: function PUIU_checkURLSecurity(aURINode, aWindow) {
if (!PlacesUtils.nodeIsBookmark(aURINode)) {
var uri = PlacesUtils._uri(aURINode.uri);
if (uri.schemeIs("javascript") || uri.schemeIs("data")) {
const BRANDING_BUNDLE_URI = "chrome://branding/locale/brand.properties";
var brandShortName = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
createBundle(BRANDING_BUNDLE_URI).
GetStringFromName("brandShortName");
if (PlacesUtils.nodeIsBookmark(aURINode))
return true;
var errorStr = this.getString("load-js-data-url-error");
Services.prompt.alert(aWindow, brandShortName, errorStr);
return false;
}
var uri = PlacesUtils._uri(aURINode.uri);
if (uri.schemeIs("javascript") || uri.schemeIs("data")) {
const BRANDING_BUNDLE_URI = "chrome://branding/locale/brand.properties";
var brandShortName = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
createBundle(BRANDING_BUNDLE_URI).
GetStringFromName("brandShortName");
var errorStr = this.getString("load-js-data-url-error");
Services.prompt.alert(aWindow, brandShortName, errorStr);
return false;
}
return true;
},
@ -792,13 +788,11 @@ var PlacesUIUtils = {
* Gives the user a chance to cancel loading lots of tabs at once
*/
_confirmOpenInTabs: function PUIU__confirmOpenInTabs(numTabsToOpen) {
let pref = Services.prefs;
let prompt = Services.prompt;
const WARN_ON_OPEN_PREF = "browser.tabs.warnOnOpen";
var reallyOpen = true;
if (pref.getBoolPref(WARN_ON_OPEN_PREF)) {
if (numTabsToOpen >= pref.getIntPref("browser.tabs.maxOpenBeforeWarn")) {
if (Services.prefs.getBoolPref(WARN_ON_OPEN_PREF)) {
if (numTabsToOpen >= Services.prefs.getIntPref("browser.tabs.maxOpenBeforeWarn")) {
// default to true: if it were false, we wouldn't get this far
var warnOnOpen = { value: true };
@ -810,12 +804,12 @@ var PlacesUIUtils = {
createBundle(BRANDING_BUNDLE_URI).
GetStringFromName("brandShortName");
var buttonPressed = prompt.confirmEx(
var buttonPressed = Services.prompt.confirmEx(
this._getCurrentActiveWin(),
this.getString("tabs.openWarningTitle"),
this.getFormattedString(messageKey, [numTabsToOpen, brandShortName]),
(prompt.BUTTON_TITLE_IS_STRING * prompt.BUTTON_POS_0) +
(prompt.BUTTON_TITLE_CANCEL * prompt.BUTTON_POS_1),
(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) +
(Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1),
this.getString(openKey), null, null,
this.getFormattedString("tabs.openWarningPromptMeBranded",
[brandShortName]),
@ -825,7 +819,7 @@ var PlacesUIUtils = {
reallyOpen = (buttonPressed == 0);
// don't set the pref unless they press OK and it's false
if (reallyOpen && !warnOnOpen.value)
pref.setBoolPref(WARN_ON_OPEN_PREF, false);
Services.prefs.setBoolPref(WARN_ON_OPEN_PREF, false);
}
}