| OLD | NEW | 
|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 // | 4 // | 
| 5 // This file declares methods that are useful for integrating Chrome in | 5 // This file declares methods that are useful for integrating Chrome in | 
| 6 // Windows shell. These methods are all static and currently part of | 6 // Windows shell. These methods are all static and currently part of | 
| 7 // ShellUtil class. | 7 // ShellUtil class. | 
| 8 | 8 | 
| 9 #ifndef CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 9 #ifndef CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 
| 10 #define CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 10 #define CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 
| 11 #pragma once | 11 #pragma once | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 23 // This is a utility class that provides common shell integration methods | 23 // This is a utility class that provides common shell integration methods | 
| 24 // that can be used by installer as well as Chrome. | 24 // that can be used by installer as well as Chrome. | 
| 25 class ShellUtil { | 25 class ShellUtil { | 
| 26  public: | 26  public: | 
| 27   // Input to any methods that make changes to OS shell. | 27   // Input to any methods that make changes to OS shell. | 
| 28   enum ShellChange { | 28   enum ShellChange { | 
| 29     CURRENT_USER = 0x1,  // Make any shell changes only at the user level | 29     CURRENT_USER = 0x1,  // Make any shell changes only at the user level | 
| 30     SYSTEM_LEVEL = 0x2   // Make any shell changes only at the system level | 30     SYSTEM_LEVEL = 0x2   // Make any shell changes only at the system level | 
| 31   }; | 31   }; | 
| 32 | 32 | 
|  | 33   // Relative path of the URL Protocol registry entry (prefixed with '\'). | 
|  | 34   static const wchar_t* kRegURLProtocol; | 
|  | 35 | 
| 33   // Relative path of DefaultIcon registry entry (prefixed with '\'). | 36   // Relative path of DefaultIcon registry entry (prefixed with '\'). | 
| 34   static const wchar_t* kRegDefaultIcon; | 37   static const wchar_t* kRegDefaultIcon; | 
| 35 | 38 | 
| 36   // Relative path of "shell" registry key. | 39   // Relative path of "shell" registry key. | 
| 37   static const wchar_t* kRegShellPath; | 40   static const wchar_t* kRegShellPath; | 
| 38 | 41 | 
| 39   // Relative path of shell open command in Windows registry | 42   // Relative path of shell open command in Windows registry | 
| 40   // (i.e. \\shell\\open\\command). | 43   // (i.e. \\shell\\open\\command). | 
| 41   static const wchar_t* kRegShellOpen; | 44   static const wchar_t* kRegShellOpen; | 
| 42 | 45 | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 62 | 65 | 
| 63   // Description of Chrome file association handler ProgId. | 66   // Description of Chrome file association handler ProgId. | 
| 64   static const wchar_t* kChromeHTMLProgIdDesc; | 67   static const wchar_t* kChromeHTMLProgIdDesc; | 
| 65 | 68 | 
| 66   // Registry path that stores url associations on Vista. | 69   // Registry path that stores url associations on Vista. | 
| 67   static const wchar_t* kRegVistaUrlPrefs; | 70   static const wchar_t* kRegVistaUrlPrefs; | 
| 68 | 71 | 
| 69   // File extensions that Chrome registers itself for. | 72   // File extensions that Chrome registers itself for. | 
| 70   static const wchar_t* kFileAssociations[]; | 73   static const wchar_t* kFileAssociations[]; | 
| 71 | 74 | 
| 72   // Protocols that Chrome registers itself for. | 75   // Protocols that Chrome registers itself as the default handler for | 
| 73   static const wchar_t* kProtocolAssociations[]; | 76   // when the user makes Chrome the default browser. | 
|  | 77   static const wchar_t* kBrowserProtocolAssociations[]; | 
|  | 78 | 
|  | 79   // Protocols that Chrome registers itself as being capable of handling. | 
|  | 80   static const wchar_t* kPotentialProtocolAssociations[]; | 
| 74 | 81 | 
| 75   // Registry value name that is needed for ChromeHTML ProgId | 82   // Registry value name that is needed for ChromeHTML ProgId | 
| 76   static const wchar_t* kRegUrlProtocol; | 83   static const wchar_t* kRegUrlProtocol; | 
| 77 | 84 | 
| 78   // Checks if we need Admin rights for registry cleanup by checking if any | 85   // Checks if we need Admin rights for registry cleanup by checking if any | 
| 79   // entry exists in HKLM. | 86   // entry exists in HKLM. | 
| 80   static bool AdminNeededForRegistryCleanup(BrowserDistribution* dist, | 87   static bool AdminNeededForRegistryCleanup(BrowserDistribution* dist, | 
| 81                                             const std::wstring& suffix); | 88                                             const std::wstring& suffix); | 
| 82 | 89 | 
| 83   // Create Chrome shortcut on Desktop | 90   // Create Chrome shortcut on Desktop | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 149   // This function gets a suffix (user's login name) that can be added | 156   // This function gets a suffix (user's login name) that can be added | 
| 150   // to Chromium default browser entry in the registry to create a unique name | 157   // to Chromium default browser entry in the registry to create a unique name | 
| 151   // if there are multiple users on the machine, each with their own copy of | 158   // if there are multiple users on the machine, each with their own copy of | 
| 152   // Chromium that they want to set as default browser. | 159   // Chromium that they want to set as default browser. | 
| 153   // This suffix value is assigned to |entry|. The function also checks for | 160   // This suffix value is assigned to |entry|. The function also checks for | 
| 154   // existence of Default Browser registry key with this suffix and | 161   // existence of Default Browser registry key with this suffix and | 
| 155   // returns true if it exists. In all other cases it returns false. | 162   // returns true if it exists. In all other cases it returns false. | 
| 156   static bool GetUserSpecificDefaultBrowserSuffix(BrowserDistribution* dist, | 163   static bool GetUserSpecificDefaultBrowserSuffix(BrowserDistribution* dist, | 
| 157                                                   std::wstring* entry); | 164                                                   std::wstring* entry); | 
| 158 | 165 | 
| 159   // Make Chrome default browser. | 166   // Make Chrome the default browser. This function works by going through | 
|  | 167   // the url protocols and file associations that are related to general | 
|  | 168   // browsing, e.g. http, https, .html etc., and requesting to become the | 
|  | 169   // default handler for each. If any of these fails the operation will return | 
|  | 170   // false to indicate failure, which is consistent with the return value of | 
|  | 171   // ShellIntegration::IsDefaultBrowser. | 
|  | 172   // | 
|  | 173   // In the case of failure any successful changes will be left, however no | 
|  | 174   // more changes will be attempted. | 
|  | 175   // TODO(benwells): Attempt to undo any changes that were successfully made. | 
|  | 176   // http://crbug.com/83970 | 
|  | 177   // | 
| 160   // shell_change: Defined whether to register as default browser at system | 178   // shell_change: Defined whether to register as default browser at system | 
| 161   //               level or user level. If value has ShellChange::SYSTEM_LEVEL | 179   //               level or user level. If value has ShellChange::SYSTEM_LEVEL | 
| 162   //               we should be running as admin user. | 180   //               we should be running as admin user. | 
| 163   // chrome_exe: The chrome.exe path to register as default browser. | 181   // chrome_exe: The chrome.exe path to register as default browser. | 
| 164   // elevate_if_not_admin: On Vista if user is not admin, try to elevate for | 182   // elevate_if_not_admin: On Vista if user is not admin, try to elevate for | 
| 165   //                       Chrome registration. | 183   //                       Chrome registration. | 
| 166   static bool MakeChromeDefault(BrowserDistribution* dist, | 184   static bool MakeChromeDefault(BrowserDistribution* dist, | 
| 167                                 int shell_change, | 185                                 int shell_change, | 
| 168                                 const std::wstring& chrome_exe, | 186                                 const std::wstring& chrome_exe, | 
| 169                                 bool elevate_if_not_admin); | 187                                 bool elevate_if_not_admin); | 
| 170 | 188 | 
|  | 189   // Make Chrome the default application for a protocol. | 
|  | 190   // chrome_exe: The chrome.exe path to register as default browser. | 
|  | 191   // protocol: The protocol to register as the default handler for. | 
|  | 192   static bool MakeChromeDefaultProtocolClient(BrowserDistribution* dist, | 
|  | 193                                               const std::wstring& chrome_exe, | 
|  | 194                                               const std::wstring& protocol); | 
|  | 195 | 
| 171   // This method adds Chrome to the list that shows up in Add/Remove Programs-> | 196   // This method adds Chrome to the list that shows up in Add/Remove Programs-> | 
| 172   // Set Program Access and Defaults and also creates Chrome ProgIds under | 197   // Set Program Access and Defaults and also creates Chrome ProgIds under | 
| 173   // Software\Classes. This method requires write access to HKLM so is just | 198   // Software\Classes. This method requires write access to HKLM so is just | 
| 174   // best effort deal. If write to HKLM fails and elevate_if_not_admin is true, | 199   // best effort deal. If write to HKLM fails and elevate_if_not_admin is true, | 
| 175   // this method will: | 200   // this method will: | 
| 176   // - add the ProgId entries to HKCU on XP. HKCU entries will not make | 201   // - add the ProgId entries to HKCU on XP. HKCU entries will not make | 
| 177   //   Chrome show in Set Program Access and Defaults but they are still useful | 202   //   Chrome show in Set Program Access and Defaults but they are still useful | 
| 178   //   because we can make Chrome run when user clicks on http link or html | 203   //   because we can make Chrome run when user clicks on http link or html | 
| 179   //   file. | 204   //   file. | 
| 180   // - will try to launch setup.exe with admin priviledges on Vista to do | 205   // - will try to launch setup.exe with admin priviledges on Vista to do | 
| 181   //   these tasks. Users will see standard Vista elevation prompt and if they | 206   //   these tasks. Users will see standard Vista elevation prompt and if they | 
| 182   //   enter the right credentials, the write operation will work. | 207   //   enter the right credentials, the write operation will work. | 
| 183   // Currently elevate_if_not_admin is true only when user tries to make Chrome | 208   // Currently elevate_if_not_admin is true only when user tries to make Chrome | 
| 184   // default browser (through the UI or through installer options) and Chrome | 209   // default browser (through the UI or through installer options) and Chrome | 
| 185   // is not registered on the machine. | 210   // is not registered on the machine. | 
| 186   // | 211   // | 
| 187   // |chrome_exe| full path to chrome.exe. | 212   // |chrome_exe| full path to chrome.exe. | 
| 188   // |unique_suffix| Optional input. If given, this function appends the value | 213   // |unique_suffix| Optional input. If given, this function appends the value | 
| 189   // to default browser entries names that it creates in the registry. | 214   // to default browser entries names that it creates in the registry. | 
| 190   // |elevate_if_not_admin| if true will make this method try alternate methods | 215   // |elevate_if_not_admin| if true will make this method try alternate methods | 
| 191   // as described above. | 216   // as described above. | 
| 192   static bool RegisterChromeBrowser(BrowserDistribution* dist, | 217   static bool RegisterChromeBrowser(BrowserDistribution* dist, | 
| 193                                     const std::wstring& chrome_exe, | 218                                     const std::wstring& chrome_exe, | 
| 194                                     const std::wstring& unique_suffix, | 219                                     const std::wstring& unique_suffix, | 
| 195                                     bool elevate_if_not_admin); | 220                                     bool elevate_if_not_admin); | 
| 196 | 221 | 
|  | 222   // This method declares to Windows that Chrome is capable of handling the | 
|  | 223   // given protocol. This function will call the RegisterChromeBrowser function | 
|  | 224   // to register with Windows as capable of handling the protocol, if it isn't | 
|  | 225   // currently registered as capable. | 
|  | 226   // Declaring the capability of handling a protocol is necessary to register | 
|  | 227   // as the default handler for the protocol in Vista and later versions of | 
|  | 228   // Windows. | 
|  | 229   // | 
|  | 230   // If called by the browser and elevation is required, it will elevate by | 
|  | 231   // calling setup.exe which will again call this function with elevate false. | 
|  | 232   // | 
|  | 233   // |chrome_exe| full path to chrome.exe. | 
|  | 234   // |unique_suffix| Optional input. If given, this function appends the value | 
|  | 235   // to default browser entries names that it creates in the registry. | 
|  | 236   // |protocol| The protocol to register as being capable of handling.s | 
|  | 237   // |elevate_if_not_admin| if true will make this method try alternate methods | 
|  | 238   // as described above. | 
|  | 239   static bool RegisterChromeForProtocol(BrowserDistribution* dist, | 
|  | 240                                         const std::wstring& chrome_exe, | 
|  | 241                                         const std::wstring& unique_suffix, | 
|  | 242                                         const std::wstring& protocol, | 
|  | 243                                         bool elevate_if_not_admin); | 
|  | 244 | 
| 197   // Remove Chrome shortcut from Desktop. | 245   // Remove Chrome shortcut from Desktop. | 
| 198   // If shell_change is CURRENT_USER, the shortcut is removed from the | 246   // If shell_change is CURRENT_USER, the shortcut is removed from the | 
| 199   // Desktop folder of current user's profile. | 247   // Desktop folder of current user's profile. | 
| 200   // If shell_change is SYSTEM_LEVEL, the shortcut is removed from the | 248   // If shell_change is SYSTEM_LEVEL, the shortcut is removed from the | 
| 201   // Desktop folder of "All Users" profile. | 249   // Desktop folder of "All Users" profile. | 
| 202   // If alternate is true, the shortcut with the alternate name is removed. See | 250   // If alternate is true, the shortcut with the alternate name is removed. See | 
| 203   // CreateChromeDesktopShortcut() for more information. | 251   // CreateChromeDesktopShortcut() for more information. | 
| 204   static bool RemoveChromeDesktopShortcut(BrowserDistribution* dist, | 252   static bool RemoveChromeDesktopShortcut(BrowserDistribution* dist, | 
| 205                                           int shell_change, bool alternate); | 253                                           int shell_change, bool alternate); | 
| 206 | 254 | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 222                                    const std::wstring& shortcut, | 270                                    const std::wstring& shortcut, | 
| 223                                    const std::wstring& description, | 271                                    const std::wstring& description, | 
| 224                                    bool create_new); | 272                                    bool create_new); | 
| 225 | 273 | 
| 226  private: | 274  private: | 
| 227   DISALLOW_COPY_AND_ASSIGN(ShellUtil); | 275   DISALLOW_COPY_AND_ASSIGN(ShellUtil); | 
| 228 }; | 276 }; | 
| 229 | 277 | 
| 230 | 278 | 
| 231 #endif  // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 279 #endif  // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 
| OLD | NEW | 
|---|