Bug 856208 - Stop using global-history;2 in SeaMonkey code, followup to move more Places modules code, r=Neil SEA_2_26_1_RELBRANCH
authorFrank Wein <mcsmurf@mcsmurf.de>
Fri, 07 Mar 2014 17:49:01 +0100
branchSEA_2_26_1_RELBRANCH
changeset 31058 c9876da9d1ff84c54a6c5f00ff0827a0222ba1e0
parent 31057 27995f4797f516eff98a6702919b095e645a4990
child 31059 9f7c2c32fad1af5b8ba4f35ad289e355c1b1d6ad
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs856208
Bug 856208 - Stop using global-history;2 in SeaMonkey code, followup to move more Places modules code, r=Neil CLOSED TREE
suite/common/contentAreaClick.js
suite/common/pref/pref-history.js
suite/modules/Sanitizer.jsm
--- a/suite/common/contentAreaClick.js
+++ b/suite/common/contentAreaClick.js
@@ -137,17 +137,16 @@
       case 1:                                                         // if middle button clicked
         if (openNewTabOrWindow(event, href, doc))
           return true;
         break;
     }
     return false;
   }
 
-  var gGlobalHistory = null;
   var gURIFixup = null;
 
   function middleMousePaste(event)
   {
     var url = readFromClipboard();
     if (!url)
       return;
     addToUrlbarHistory(url);
@@ -203,29 +202,25 @@
     // Remove leading and trailing spaces first
     aUrlToAdd = aUrlToAdd.trim();
 
     if (!aUrlToAdd)
       return;
     if (aUrlToAdd.search(/[\x00-\x1F]/) != -1) // don't store bad URLs
       return;
 
-    if (!gGlobalHistory)
-      gGlobalHistory = Components.classes["@mozilla.org/browser/nav-history-service;1"]
-                                 .getService(Components.interfaces.nsINavHistoryService);
-
     if (!gURIFixup)
       gURIFixup = Components.classes["@mozilla.org/docshell/urifixup;1"]
                             .getService(Components.interfaces.nsIURIFixup);
 
     try {
       var url = getShortcutOrURI(aUrlToAdd);
       var fixedUpURI = gURIFixup.createFixupURI(url, 0);
       if (!fixedUpURI.schemeIs("data"))
-        gGlobalHistory.markPageAsTyped(fixedUpURI);
+        PlacesUtils.history.markPageAsTyped(fixedUpURI);
     }
     catch(ex) {
     }
 
     // Open or create the urlbar history database.
     var file = GetUrlbarHistoryFile();
     var connection = Services.storage.openDatabase(file);
     connection.beginTransaction();
--- a/suite/common/pref/pref-history.js
+++ b/suite/common/pref/pref-history.js
@@ -27,19 +27,18 @@ function Startup()
   var globalHistory = Components.classes["@mozilla.org/browser/nav-history-service;1"]
                                 .getService(Components.interfaces.nsINavHistoryService);
   if (!globalHistory.hasHistoryEntries)
     globalHistButton.disabled = true;
 }
 
 function prefClearGlobalHistory()
 {
-  var globalHistory = Components.classes["@mozilla.org/browser/nav-history-service;1"]
-                                .getService(Components.interfaces.nsIBrowserHistory);
-  globalHistory.removeAllPages();
+  Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
+  PlacesUtils.history.removeAllPages();
 }
 
 function prefClearUrlbarHistory()
 {
   document.getElementById("general.open_location.last_url").valueFromPreferences = "";
   var file = GetUrlbarHistoryFile();
   if (file.exists())
     file.remove(false);
--- a/suite/modules/Sanitizer.jsm
+++ b/suite/modules/Sanitizer.jsm
@@ -162,21 +162,21 @@ var Sanitizer = {
         } catch (e) {}
       },
 
       canClear: true
     },
 
     history: {
       clear: function() {
+        Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
+
         // use try/catch for everything but the last task so we clear as much as possible
         try {
-          var globalHistory = Components.classes["@mozilla.org/browser/nav-history-service;1"]
-                                        .getService(Components.interfaces.nsIBrowserHistory);
-          globalHistory.removeAllPages();
+          PlacesUtils.history.removeAllPages();
         } catch(ex) {}
 
         try {
           var os = Components.classes["@mozilla.org/observer-service;1"]
                              .getService(Components.interfaces.nsIObserverService);
           os.notifyObservers(null, "browser:purge-session-history", "");
         } catch(ex) {}
       },