Bug 1288558 - Part 3: Replace usage of Components with Cc/Ci/Cu. r=MattN
authorSteve Chung <schung@mozilla.com>
Wed, 07 Sep 2016 14:51:40 +0800
changeset 354419 5db2cc28a8ff880a980fbf799a9a4b0bd0d4e52d
parent 354418 6f18e82e0ccdf068a2ddf1a826f654ab66535ceb
child 354420 62a6840937fa8d23f4aec4e8fdad649b29e8bd8d
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1288558
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1288558 - Part 3: Replace usage of Components with Cc/Ci/Cu. r=MattN MozReview-Commit-ID: Goj429Tbk31
toolkit/components/passwordmgr/content/passwordManager.js
--- a/toolkit/components/passwordmgr/content/passwordManager.js
+++ b/toolkit/components/passwordmgr/content/passwordManager.js
@@ -55,22 +55,22 @@ let signonReloadDisplay = {
 let dateFormatter = new Intl.DateTimeFormat(undefined,
                       { day: "numeric", month: "short", year: "numeric" });
 let dateAndTimeFormatter = new Intl.DateTimeFormat(undefined,
                              { day: "numeric", month: "short", year: "numeric",
                                hour: "numeric", minute: "numeric" });
 
 function Startup() {
   // xpconnect to password manager interfaces
-  passwordmanager = Components.classes["@mozilla.org/login-manager;1"]
-                        .getService(Components.interfaces.nsILoginManager);
+  passwordmanager = Cc["@mozilla.org/login-manager;1"]
+                        .getService(Ci.nsILoginManager);
 
   // be prepared to reload the display if anything changes
-  kObserverService = Components.classes["@mozilla.org/observer-service;1"]
-                               .getService(Components.interfaces.nsIObserverService);
+  kObserverService = Cc["@mozilla.org/observer-service;1"]
+                               .getService(Ci.nsIObserverService);
   kObserverService.addObserver(signonReloadDisplay, "passwordmgr-storage-changed", false);
 
   signonsTree = document.getElementById("signonsTree");
 }
 
 
 // TODO: Integragte to SignonsStartup?
 function HandleTreeColumnClick(sortFunction, event) {
@@ -301,17 +301,17 @@ function SortTree(tree, view, table, col
 
 function LoadSignons() {
   // loads signons into table
   try {
     signons = passwordmanager.getAllLogins();
   } catch (e) {
     signons = [];
   }
-  signons.forEach(login => login.QueryInterface(Components.interfaces.nsILoginMetaInfo));
+  signons.forEach(login => login.QueryInterface(Ci.nsILoginMetaInfo));
   signonsTreeView.rowCount = signons.length;
 
   // sort and display the table
   signonsTree.view = signonsTreeView;
   // The sort column didn't change. SortTree (called by
   // SignonColumnSort) assumes we want to toggle the sort
   // direction but here we don't so we have to trick it
   lastSignonSortAscending = !lastSignonSortAscending;
@@ -428,18 +428,18 @@ function DeleteAllFromTree(tree, view, t
 
 
   // disable buttons
   document.getElementById(removeButton).setAttribute("disabled", "true")
   document.getElementById(removeAllButton).setAttribute("disabled", "true");
 }
 
 function DeleteAllSignons() {
-  let prompter = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
-                           .getService(Components.interfaces.nsIPromptService);
+  let prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"]
+                           .getService(Ci.nsIPromptService);
 
   // Confirm the user wants to remove all passwords
   let dummy = { value: false };
   if (prompter.confirmEx(window,
                          kSignonBundle.getString("removeAllPasswordsTitle"),
                          kSignonBundle.getString("removeAllPasswordsPrompt"),
                          prompter.STD_YES_NO_BUTTONS + prompter.BUTTON_POS_1_DEFAULT,
                          null, null, null, null, dummy) == 1) // 1 == "No" button
@@ -464,17 +464,17 @@ function TogglePasswordVisible() {
 
   // Notify observers that the password visibility toggling is
   // completed.  (Mostly useful for tests)
   kObserverService.notifyObservers(null, "passwordmgr-password-toggle-complete", null);
   Services.telemetry.getHistogramById("PWMGR_MANAGE_VISIBILITY_TOGGLED").add(showingPasswords);
 }
 
 function AskUserShowPasswords() {
-  let prompter = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
+  let prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService);
   let dummy = { value: false };
 
   // Confirm the user wants to display passwords
   return prompter.confirmEx(window,
           null,
           kSignonBundle.getString("noMasterPasswordPrompt"), prompter.STD_YES_NO_BUTTONS,
           null, null, null, null, dummy) == 0;    // 0=="Yes" button
 }
@@ -647,28 +647,28 @@ function _filterPasswords() {
 }
 
 function CopyPassword() {
   // Don't copy passwords if we aren't already showing the passwords & a master
   // password hasn't been entered.
   if (!showingPasswords && !masterPasswordLogin())
     return;
   // Copy selected signon's password to clipboard
-  let clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"].
-                  getService(Components.interfaces.nsIClipboardHelper);
+  let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
+                  getService(Ci.nsIClipboardHelper);
   let row = document.getElementById("signonsTree").currentIndex;
   let password = signonsTreeView.getCellText(row, {id : "passwordCol" });
   clipboard.copyString(password);
   Services.telemetry.getHistogramById("PWMGR_MANAGE_COPIED_PASSWORD").add(1);
 }
 
 function CopyUsername() {
   // Copy selected signon's username to clipboard
-  let clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"].
-                  getService(Components.interfaces.nsIClipboardHelper);
+  let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
+                  getService(Ci.nsIClipboardHelper);
   let row = document.getElementById("signonsTree").currentIndex;
   let username = signonsTreeView.getCellText(row, {id : "userCol" });
   clipboard.copyString(username);
   Services.telemetry.getHistogramById("PWMGR_MANAGE_COPIED_USERNAME").add(1);
 }
 
 function EditCellInSelectedRow(columnName) {
   let row = signonsTree.currentIndex;
@@ -708,18 +708,18 @@ function UpdateContextMenu() {
     menuItems.get("context-editpassword").removeAttribute("disabled");
   } else {
     menuItems.get("context-editpassword").setAttribute("disabled", "true");
   }
 }
 
 function masterPasswordLogin(noPasswordCallback) {
   // This doesn't harm if passwords are not encrypted
-  let tokendb = Components.classes["@mozilla.org/security/pk11tokendb;1"]
-                    .createInstance(Components.interfaces.nsIPK11TokenDB);
+  let tokendb = Cc["@mozilla.org/security/pk11tokendb;1"]
+                    .createInstance(Ci.nsIPK11TokenDB);
   let token = tokendb.getInternalKeyToken();
 
   // If there is no master password, still give the user a chance to opt-out of displaying passwords
   if (token.checkPassword(""))
     return noPasswordCallback ? noPasswordCallback() : true;
 
   // So there's a master password. But since checkPassword didn't succeed, we're logged out (per nsIPK11Token.idl).
   try {