Bug 692295 - Remove nsWindowsShellService's ShortcutMaintenance method and calls now that it is no longer needed. r=jimm
authorRobert Strong <robert.bugzilla@gmail.com>
Mon, 12 Jun 2017 18:42:23 -0700
changeset 412314 1c26e57c1899
parent 412313 3f431be7899b
child 412315 abdf1eb7663f
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs692295
milestone56.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 692295 - Remove nsWindowsShellService's ShortcutMaintenance method and calls now that it is no longer needed. r=jimm Removes nsIWindowsShellService.idl since there are no longer custom methods and it can just use nsIShellService.idl Removes a couple of includes that are no longer used and should have been removed after the code to delete Firefox prefetch files was removed
browser/components/shell/moz.build
browser/components/shell/nsIWindowsShellService.idl
browser/components/shell/nsWindowsShellService.cpp
browser/components/shell/nsWindowsShellService.h
browser/modules/WindowsJumpLists.jsm
--- a/browser/components/shell/moz.build
+++ b/browser/components/shell/moz.build
@@ -8,21 +8,17 @@ XPCSHELL_TESTS_MANIFESTS += ['test/unit/
 BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
 
 JAR_MANIFESTS += ['jar.mn']
 
 XPIDL_SOURCES += [
     'nsIShellService.idl',
 ]
 
-if CONFIG['OS_ARCH'] == 'WINNT':
-    XPIDL_SOURCES += [
-        'nsIWindowsShellService.idl',
-    ]
-elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     XPIDL_SOURCES += [
         'nsIMacShellService.idl',
     ]
 elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
     XPIDL_SOURCES += [
         'nsIGNOMEShellService.idl',
     ]
 
deleted file mode 100644
--- a/browser/components/shell/nsIWindowsShellService.idl
+++ /dev/null
@@ -1,17 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "nsIShellService.idl"
-
-[scriptable, uuid(f8a26b94-49e5-4441-8fbc-315e0b4f22ef)]
-interface nsIWindowsShellService : nsIShellService
-{
-    /**
-     * Provides the shell service an opportunity to do some Win7+ shortcut
-     * maintenance needed on initial startup of the browser.
-     */
-    void shortcutMaintenance();
-};
-
--- a/browser/components/shell/nsWindowsShellService.cpp
+++ b/browser/components/shell/nsWindowsShellService.cpp
@@ -24,20 +24,17 @@
 #include "nsIProcess.h"
 #include "nsICategoryManager.h"
 #include "nsBrowserCompsCID.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsIWindowsRegKey.h"
 #include "nsUnicharUtils.h"
-#include "nsIWinTaskbar.h"
-#include "nsISupportsPrimitives.h"
 #include "nsIURLFormatter.h"
-#include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/WindowsVersion.h"
 
 #include "windows.h"
 #include "shellapi.h"
 
 #ifdef _WIN32_WINNT
 #undef _WIN32_WINNT
@@ -60,25 +57,23 @@
 #endif
 
 #define REG_SUCCEEDED(val) \
   (val == ERROR_SUCCESS)
 
 #define REG_FAILED(val) \
   (val != ERROR_SUCCESS)
 
-#define NS_TASKBAR_CONTRACTID "@mozilla.org/windows-taskbar;1"
-
 #define APP_REG_NAME_BASE L"Firefox-"
 
 using mozilla::IsWin8OrLater;
 using namespace mozilla;
 using namespace mozilla::gfx;
 
-NS_IMPL_ISUPPORTS(nsWindowsShellService, nsIWindowsShellService, nsIShellService)
+NS_IMPL_ISUPPORTS(nsWindowsShellService, nsIShellService)
 
 static nsresult
 OpenKeyForReading(HKEY aKeyRoot, const nsAString& aKeyName, HKEY* aKey)
 {
   const nsString &flatName = PromiseFlatString(aKeyName);
 
   DWORD res = ::RegOpenKeyExW(aKeyRoot, flatName.get(), 0, KEY_READ, aKey);
   switch (res) {
@@ -131,88 +126,16 @@ LaunchHelper(nsAutoString& aPath)
     return NS_ERROR_FAILURE;
   }
 
   CloseHandle(pi.hProcess);
   CloseHandle(pi.hThread);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsWindowsShellService::ShortcutMaintenance()
-{
-  nsresult rv;
-
-  // XXX App ids were updated to a constant install path hash,
-  // XXX this code can be removed after a few upgrade cycles.
-
-  // Launch helper.exe so it can update the application user model ids on
-  // shortcuts in the user's taskbar and start menu. This keeps older pinned
-  // shortcuts grouped correctly after major updates. Note, we also do this
-  // through the upgrade installer script, however, this is the only place we
-  // have a chance to trap links created by users who do control the install/
-  // update process of the browser.
-
-  nsCOMPtr<nsIWinTaskbar> taskbarInfo =
-    do_GetService(NS_TASKBAR_CONTRACTID);
-  if (!taskbarInfo) // If we haven't built with win7 sdk features, this fails.
-    return NS_OK;
-
-  // Avoid if this isn't Win7+
-  bool isSupported = false;
-  taskbarInfo->GetAvailable(&isSupported);
-  if (!isSupported)
-    return NS_OK;
-
-  nsAutoString appId;
-  if (NS_FAILED(taskbarInfo->GetDefaultGroupId(appId)))
-    return NS_ERROR_UNEXPECTED;
-
-  const char* prefName = "browser.taskbar.lastgroupid";
-  nsCOMPtr<nsIPrefBranch> prefs =
-    do_GetService(NS_PREFSERVICE_CONTRACTID);
-  if (!prefs)
-    return NS_ERROR_UNEXPECTED;
-
-  nsCOMPtr<nsISupportsString> prefString;
-  rv = prefs->GetComplexValue(prefName,
-                              NS_GET_IID(nsISupportsString),
-                              getter_AddRefs(prefString));
-  if (NS_SUCCEEDED(rv)) {
-    nsAutoString version;
-    prefString->GetData(version);
-    if (!version.IsEmpty() && version.Equals(appId)) {
-      // We're all good, get out of here.
-      return NS_OK;
-    }
-  }
-  // Update the version in prefs
-  prefString =
-    do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
-  if (NS_FAILED(rv))
-    return rv;
-
-  prefString->SetData(appId);
-  rv = prefs->SetComplexValue(prefName,
-                              NS_GET_IID(nsISupportsString),
-                              prefString);
-  if (NS_FAILED(rv)) {
-    NS_WARNING("Couldn't set last user model id!");
-    return NS_ERROR_UNEXPECTED;
-  }
-
-  nsAutoString appHelperPath;
-  if (NS_FAILED(GetHelperPath(appHelperPath)))
-    return NS_ERROR_UNEXPECTED;
-
-  appHelperPath.AppendLiteral(" /UpdateShortcutAppUserModelIds");
-
-  return LaunchHelper(appHelperPath);
-}
-
 static bool
 IsPathDefaultForClass(const RefPtr<IApplicationAssociationRegistration>& pAAR,
                       wchar_t *exePath, LPCWSTR aClassName)
 {
   // Make sure the Prog ID matches what we have
   LPWSTR registeredApp;
   bool isProtocol = *aClassName != L'.';
   ASSOCIATIONTYPE queryType = isProtocol ? AT_URLPROTOCOL : AT_FILEEXTENSION;
--- a/browser/components/shell/nsWindowsShellService.h
+++ b/browser/components/shell/nsWindowsShellService.h
@@ -3,32 +3,30 @@
  * 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/. */
 
 #ifndef nswindowsshellservice_h____
 #define nswindowsshellservice_h____
 
 #include "nscore.h"
 #include "nsString.h"
-#include "nsIWindowsShellService.h"
-#include "nsITimer.h"
+#include "nsIShellService.h"
 
 #include <windows.h>
 #include <ole2.h>
 
-class nsWindowsShellService : public nsIWindowsShellService
+class nsWindowsShellService : public nsIShellService
 {
   virtual ~nsWindowsShellService();
 
 public:
   nsWindowsShellService();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISHELLSERVICE
-  NS_DECL_NSIWINDOWSSHELLSERVICE
 
 protected:
   nsresult LaunchControlPanelDefaultsSelectionUI();
   nsresult LaunchControlPanelDefaultPrograms();
   nsresult LaunchModernSettingsDialogDefaultApps();
   nsresult InvokeHTTPOpenAsVerb();
   nsresult LaunchHTTPHandlerPane();
 };
--- a/browser/modules/WindowsJumpLists.jsm
+++ b/browser/modules/WindowsJumpLists.jsm
@@ -48,19 +48,16 @@ XPCOMUtils.defineLazyGetter(this, "_stri
 });
 
 XPCOMUtils.defineLazyServiceGetter(this, "_idle",
                                    "@mozilla.org/widget/idleservice;1",
                                    "nsIIdleService");
 XPCOMUtils.defineLazyServiceGetter(this, "_taskbarService",
                                    "@mozilla.org/windows-taskbar;1",
                                    "nsIWinTaskbar");
-XPCOMUtils.defineLazyServiceGetter(this, "_winShellService",
-                                   "@mozilla.org/browser/shell-service;1",
-                                   "nsIWindowsShellService");
 
 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
   "resource://gre/modules/PlacesUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
   "resource://gre/modules/PrivateBrowsingUtils.jsm");
 
 /**
  * Global functions
@@ -131,25 +128,16 @@ this.WinTaskbarJumpList =
    * Startup, shutdown, and update
    */
 
   startup: function WTBJL_startup() {
     // exit if this isn't win7 or higher.
     if (!this._initTaskbar())
       return;
 
-    // Win shell shortcut maintenance. If we've gone through an update,
-    // this will update any pinned taskbar shortcuts. Not specific to
-    // jump lists, but this was a convienent place to call it.
-    try {
-      // dev builds may not have helper.exe, ignore failures.
-      this._shortcutMaintenance();
-    } catch (ex) {
-    }
-
     // Store our task list config data
     this._tasks = tasksCfg;
 
     // retrieve taskbar related prefs.
     this._refreshPrefs();
 
     // observer for private browsing and our prefs branch
     this._initObs();
@@ -175,20 +163,16 @@ this.WinTaskbarJumpList =
     // this value, so it's a pretty fast call.
     if (!PlacesUtils.history.hasHistoryEntries) {
       this.update();
     }
 
     this._free();
   },
 
-  _shortcutMaintenance: function WTBJL__maintenace() {
-    _winShellService.shortcutMaintenance();
-  },
-
   /**
    * List building
    *
    * @note Async builders must add their mozIStoragePendingStatement to
    *       _pendingStatements object, using a different LIST_TYPE entry for
    *       each statement. Once finished they must remove it and call
    *       commitBuild().  When there will be no more _pendingStatements,
    *       commitBuild() will commit for real.