Bug 738804: Back out fix for bug 718088, a=akeybl
authorGavin Sharp <gavin@gavinsharp.com>
Tue, 03 Apr 2012 11:06:16 -0700
changeset 92010 2fe257c037f1efe835db9090f7b800983d480a76
parent 92009 18753a4ee7cdc2ef365a1ebc1c66f5d32ec81926
child 92011 ac19f9e7096e7095ffb860f79a55e67137dca574
push idunknown
push userunknown
push dateunknown
reviewersakeybl
bugs738804, 718088
milestone13.0a2
Bug 738804: Back out fix for bug 718088, a=akeybl
browser/components/nsBrowserGlue.js
browser/locales/en-US/chrome/browser/browser.properties
browser/modules/KeywordURLResetPrompter.jsm
browser/modules/Makefile.in
docshell/base/nsDefaultURIFixup.cpp
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -59,19 +59,16 @@ XPCOMUtils.defineLazyGetter(this, "NetUt
   return NetUtil;
 });
 
 XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
   Cu.import("resource://gre/modules/PlacesUtils.jsm");
   return PlacesUtils;
 });
 
-XPCOMUtils.defineLazyModuleGetter(this, "KeywordURLResetPrompter",
-                                  "resource:///modules/KeywordURLResetPrompter.jsm");
-
 XPCOMUtils.defineLazyModuleGetter(this, "webappsUI", 
                                   "resource:///modules/webappsUI.jsm");
 
 const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser";
 const PREF_PLUGINS_UPDATEURL  = "plugins.update.url";
 
 // We try to backup bookmarks at idle times, to avoid doing that at shutdown.
 // Number of idle seconds before trying to backup bookmarks.  15 minutes.
@@ -278,23 +275,16 @@ BrowserGlue.prototype = {
           this._distributionCustomizer.applyPrefDefaults();
           this._distributionCustomizer.applyCustomizations();
           // To apply distribution bookmarks use "places-init-complete".
         }
         else if (data == "force-places-init") {
           this._initPlaces();
         }
         break;
-      case "defaultURIFixup-using-keyword-pref":
-        if (KeywordURLResetPrompter.shouldPrompt) {
-          let keywordURI = subject.QueryInterface(Ci.nsIURI);
-          KeywordURLResetPrompter.prompt(this.getMostRecentBrowserWindow(),
-                                         keywordURI);
-        }
-        break;
     }
   }, 
 
   // initialization (called on application startup) 
   _init: function BG__init() {
     let os = Services.obs;
     os.addObserver(this, "xpcom-shutdown", false);
     os.addObserver(this, "prefservice:after-app-defaults", false);
@@ -314,17 +304,16 @@ BrowserGlue.prototype = {
     os.addObserver(this, "session-save", false);
     os.addObserver(this, "places-init-complete", false);
     this._isPlacesInitObserver = true;
     os.addObserver(this, "places-database-locked", false);
     this._isPlacesLockedObserver = true;
     os.addObserver(this, "distribution-customization-complete", false);
     os.addObserver(this, "places-shutdown", false);
     this._isPlacesShutdownObserver = true;
-    os.addObserver(this, "defaultURIFixup-using-keyword-pref", false);
   },
 
   // cleanup (called on application shutdown)
   _dispose: function BG__dispose() {
     let os = Services.obs;
     os.removeObserver(this, "xpcom-shutdown");
     os.removeObserver(this, "prefservice:after-app-defaults");
     os.removeObserver(this, "final-ui-startup");
@@ -343,17 +332,16 @@ BrowserGlue.prototype = {
     if (this._isIdleObserver)
       this._idleService.removeIdleObserver(this, BOOKMARKS_BACKUP_IDLE_TIME);
     if (this._isPlacesInitObserver)
       os.removeObserver(this, "places-init-complete");
     if (this._isPlacesLockedObserver)
       os.removeObserver(this, "places-database-locked");
     if (this._isPlacesShutdownObserver)
       os.removeObserver(this, "places-shutdown");
-    os.removeObserver(this, "defaultURIFixup-using-keyword-pref");
     webappsUI.uninit();
   },
 
   _onAppDefaults: function BG__onAppDefaults() {
     // apply distribution customizations (prefs)
     // other customizations are applied in _onProfileStartup()
     this._distributionCustomizer.applyPrefDefaults();
   },
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -335,27 +335,12 @@ telemetryNoButtonLabel = No
 telemetryNoButtonAccessKey = N
 
 # Webapps notification popup
 webapps.install = Install
 webapps.install.accesskey = I
 #LOCALIZATION NOTE (webapps.requestInstall) %1$S is the web app name, %2$S is the site from which the web app is installed
 webapps.requestInstall = Do you want to install "%1$S" from this site (%2$S)?
 
-# Keyword.URL reset prompt
-# LOCALIZATION NOTE (keywordPrompt.message):
-#  - %1$S is brandShortName
-#  - %2$S is a host name (e.g. "somewebsearch.com") from the current value of keyword.URL
-#  - %3$S is the name of the default search engine (e.g. "Google")
-keywordPrompt.message = %1$S is using '%2$S' for searches from the location bar. Would you like to restore the default search (%3$S)?
-
-# LOCALIZATION NOTE (keywordPrompt.yesButton): %1$S is the name of the default search engine
-keywordPrompt.yesButton = Yes, use %1$S
-keywordPrompt.yesButton.accessKey = Y
-
-# LOCALIZATION NOTE (keywordPrompt.noButton): %1$S is a host name (e.g. "somewebsearch.com") from the current value of keyword.URL
-keywordPrompt.noButton = No, continue using '%1$S'
-keywordPrompt.noButton.accessKey  = N
-
 # Telemetry opt-out prompt for Aurora and Nightly
 # LOCALIZATION NOTE (telemetryOptOutPrompt): %1$S and %3$S will be replaced by
 # brandFullName, and %2$S by the value of the toolkit.telemetry.server_owner preference.
 telemetryOptOutPrompt = %1$S sends information about performance, hardware, usage and customizations back to %2$S to help improve %3$S.
deleted file mode 100644
--- a/browser/modules/KeywordURLResetPrompter.jsm
+++ /dev/null
@@ -1,105 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-let EXPORTED_SYMBOLS = [ "KeywordURLResetPrompter" ];
-
-const Ci = Components.interfaces;
-const Cc = Components.classes;
-const Cu = Components.utils;
-
-Cu.import("resource://gre/modules/Services.jsm");
-
-const KEYWORD_PROMPT_REV = 1;
-
-let KeywordURLResetPrompter = {
-  get shouldPrompt() {
-    let keywordURLUserSet = Services.prefs.prefHasUserValue("keyword.URL");
-    let declinedRev;
-    try {
-      declinedRev = Services.prefs.getIntPref("browser.keywordURLPromptDeclined");
-    } catch (ex) {}
-
-    return keywordURLUserSet && declinedRev != KEYWORD_PROMPT_REV;
-  },
-
-  prompt: function KeywordURLResetPrompter_prompt(win, keywordURI) {
-    let tabbrowser = win.gBrowser;
-    let notifyBox = tabbrowser.getNotificationBox();
-
-    let existingNotification = notifyBox.getNotificationWithValue("keywordURL-reset");
-    if (existingNotification)
-      return;
-
-    // Find the name/URI of this build's original default engine.
-    // XXX: Can't use originalDefaultEngine getter here, because that doesn't
-    //      use the default pref branch.
-    let defaultURI;
-    let defaultEngine;
-    try {
-      let defaultPB = Services.prefs.getDefaultBranch(null);
-      let defaultName = defaultPB.getComplexValue("browser.search.defaultenginename",
-                                                  Ci.nsIPrefLocalizedString).data;
-      defaultEngine = Services.search.getEngineByName(defaultName);
-      defaultURI = defaultEngine.getSubmission("foo").uri;
-    } catch (ex) {
-      // Something went horribly wrong! bail out
-      return;
-    }
-
-    // If the user-set value has the same base domain as the default, don't
-    // prompt.
-    let keywordBaseDomain;
-    try {
-      keywordBaseDomain = Services.eTLD.getBaseDomain(keywordURI);
-      if (keywordBaseDomain == Services.eTLD.getBaseDomain(defaultURI))
-        return;
-    } catch (ex) {}
-
-    if (!keywordBaseDomain)
-      return;
-
-    let brandBundle  = Services.strings.createBundle("chrome://branding/locale/brand.properties");
-    let brandShortName = brandBundle.GetStringFromName("brandShortName");
-
-    let browserBundle = win.gNavigatorBundle;
-    let msg = browserBundle.getFormattedString("keywordPrompt.message",
-                                               [brandShortName, keywordBaseDomain,
-                                                defaultEngine.name]);
-    let buttons = [
-      {
-        label: browserBundle.getFormattedString("keywordPrompt.yesButton",
-                                                [defaultEngine.name]),
-        accessKey: browserBundle.getString("keywordPrompt.yesButton.accessKey"),
-        popup:     null,
-        callback: function(aNotificationBar, aButton) {
-          Services.prefs.clearUserPref("keyword.URL");
-          try {
-            // If the currently loaded URI still has the same base domain as the
-            // keyword URI (this is used as a rough approximation of whether the
-            // user is still seeing search results as opposed to having clicked
-            // on a result link), load the default engine's searchForm URL so
-            // that they can re-do their search.
-            let currentBaseDomain = Services.eTLD.getBaseDomain(tabbrowser.currentURI);
-            if (currentBaseDomain == keywordBaseDomain)
-              tabbrowser.loadURI(defaultEngine.searchForm);
-          } catch (ex) {}
-        }
-      },
-      {
-        label: browserBundle.getFormattedString("keywordPrompt.noButton",
-                                                [keywordBaseDomain]),
-        accessKey: browserBundle.getString("keywordPrompt.noButton.accessKey"),
-        popup:     null,
-        callback: function(aNotificationBar, aButton) {
-          Services.prefs.setIntPref("browser.keywordURLPromptDeclined", KEYWORD_PROMPT_REV);
-        }
-      }
-    ];
-    
-    let notification = notifyBox.appendNotification(msg, "keywordURL-reset", null, notifyBox.PRIORITY_WARNING_HIGH, buttons);
-    notification.setAttribute("hideclose", true);
-    // stick around for a few page loads in case there are redirects involved
-    notification.persistence = 3;
-  }
-}
--- a/browser/modules/Makefile.in
+++ b/browser/modules/Makefile.in
@@ -47,17 +47,16 @@ include $(topsrcdir)/config/config.mk
 TEST_DIRS += test
 
 EXTRA_JS_MODULES = \
 	openLocationLastURL.jsm \
 	NetworkPrioritizer.jsm \
 	NewTabUtils.jsm \
 	offlineAppCache.jsm \
 	TelemetryTimestamps.jsm \
-	KeywordURLResetPrompter.jsm \
 	webappsUI.jsm \
 	$(NULL)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows) 
 EXTRA_JS_MODULES += \
 	WindowsPreviewPerTab.jsm \
 	WindowsJumpLists.jsm \
 	$(NULL)
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -49,17 +49,16 @@
 
 #ifdef MOZ_TOOLKIT_SEARCH
 #include "nsIBrowserSearchService.h"
 #endif
 
 #include "nsIURIFixup.h"
 #include "nsDefaultURIFixup.h"
 #include "mozilla/Preferences.h"
-#include "nsIObserverService.h"
 
 using namespace mozilla;
 
 /* Implementation file */
 NS_IMPL_ISUPPORTS1(nsDefaultURIFixup, nsIURIFixup)
 
 nsDefaultURIFixup::nsDefaultURIFixup()
 {
@@ -374,27 +373,17 @@ NS_IMETHODIMP nsDefaultURIFixup::Keyword
         // Escape keyword, then prepend URL
         nsCAutoString spec;
         if (!NS_Escape(keyword, spec, url_XPAlphas)) {
             return NS_ERROR_OUT_OF_MEMORY;
         }
 
         spec.Insert(url, 0);
 
-        nsresult rv = NS_NewURI(aURI, spec);
-        if (NS_FAILED(rv))
-            return rv;
-
-        nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
-        if (obsSvc) {
-            obsSvc->NotifyObservers(*aURI,
-                                    "defaultURIFixup-using-keyword-pref",
-                                    nsnull);
-        }
-        return NS_OK;
+        return NS_NewURI(aURI, spec);
     }
 
 #ifdef MOZ_TOOLKIT_SEARCH
     // Try falling back to the search service's default search engine
     nsCOMPtr<nsIBrowserSearchService> searchSvc = do_GetService("@mozilla.org/browser/search-service;1");
     if (searchSvc) {
         nsCOMPtr<nsISearchEngine> defaultEngine;
         searchSvc->GetOriginalDefaultEngine(getter_AddRefs(defaultEngine));