Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 defines functions that integrate Chrome in Windows shell. These | 5 // This file defines functions that integrate Chrome in Windows shell. These |
| 6 // functions can be used by Chrome as well as Chrome installer. All of the | 6 // functions can be used by Chrome as well as Chrome installer. All of the |
| 7 // work is done by the local functions defined in anonymous namespace in | 7 // work is done by the local functions defined in anonymous namespace in |
| 8 // this class. | 8 // this class. |
| 9 | 9 |
| 10 #include "chrome/installer/util/shell_util.h" | 10 #include "chrome/installer/util/shell_util.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/path_service.h" | 22 #include "base/path_service.h" |
| 23 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
| 24 #include "base/string_number_conversions.h" | 24 #include "base/string_number_conversions.h" |
| 25 #include "base/string_split.h" | 25 #include "base/string_split.h" |
| 26 #include "base/string_util.h" | 26 #include "base/string_util.h" |
| 27 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
| 28 #include "base/values.h" | 28 #include "base/values.h" |
| 29 #include "base/win/registry.h" | 29 #include "base/win/registry.h" |
| 30 #include "base/win/scoped_comptr.h" | 30 #include "base/win/scoped_comptr.h" |
| 31 #include "base/win/win_util.h" | |
| 31 #include "base/win/windows_version.h" | 32 #include "base/win/windows_version.h" |
| 32 #include "chrome/common/chrome_constants.h" | 33 #include "chrome/common/chrome_constants.h" |
| 33 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/installer/util/browser_distribution.h" | 35 #include "chrome/installer/util/browser_distribution.h" |
| 35 #include "chrome/installer/util/install_util.h" | 36 #include "chrome/installer/util/install_util.h" |
| 36 #include "chrome/installer/util/master_preferences.h" | 37 #include "chrome/installer/util/master_preferences.h" |
| 37 #include "chrome/installer/util/master_preferences_constants.h" | 38 #include "chrome/installer/util/master_preferences_constants.h" |
| 38 | 39 |
| 39 using base::win::RegKey; | 40 using base::win::RegKey; |
| 40 | 41 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 VER_SET_CONDITION(condition_mask, VER_BUILDNUMBER, VER_GREATER_EQUAL); | 79 VER_SET_CONDITION(condition_mask, VER_BUILDNUMBER, VER_GREATER_EQUAL); |
| 79 VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); | 80 VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); |
| 80 VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL); | 81 VER_SET_CONDITION(condition_mask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL); |
| 81 | 82 |
| 82 DWORD type_mask = VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER | | 83 DWORD type_mask = VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER | |
| 83 VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR; | 84 VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR; |
| 84 | 85 |
| 85 return VerifyVersionInfo(&min_version_info, type_mask, condition_mask) != 0; | 86 return VerifyVersionInfo(&min_version_info, type_mask, condition_mask) != 0; |
| 86 } | 87 } |
| 87 | 88 |
| 89 // Sets |suffix| to a base 16 encoding of this user's sid preceded by a dot. | |
| 90 // This suffix is then meant to be added to all registration that may conflict | |
| 91 // with another user-level Chrome install. | |
| 92 // This is guaranteed to be 25 characters (including the dot). | |
| 93 // Note that prior to Chrome 21, the suffix registered used to be the user's | |
| 94 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old | |
| 95 // installs registered that way, but it was wrong because some of the characters | |
| 96 // allowed in a username are not allowed in a ProgId. | |
| 97 // Returns true unless the OS call to retrieve the username fails. | |
| 98 bool GetNewUserSpecificRegistrySuffix(string16* suffix) { | |
| 99 string16 encoded_sid; | |
| 100 if (!base::win::GetUserSidBase16Encoded(&encoded_sid)) { | |
| 101 PLOG(DFATAL) << "GetUserSidBase16Encoded failed"; | |
| 102 return false; | |
| 103 } | |
| 104 suffix->reserve(encoded_sid.length() + 1); | |
| 105 suffix->assign(1, L'.'); | |
| 106 suffix->append(encoded_sid); | |
| 107 return true; | |
| 108 } | |
| 109 | |
| 110 // Sets |suffix| to this user's username preceded by a dot. This suffix is then | |
| 111 // meant to be added to all registration that may conflict with another | |
| 112 // user-level Chrome install. | |
| 113 // Returns true unless the OS call to retrieve the username fails. | |
| 114 bool GetOldUserSpecificRegistrySuffix(string16* suffix) { | |
|
gab
2012/06/21 05:55:41
This is not new, simply moved from lower to avoid
| |
| 115 wchar_t user_name[256]; | |
| 116 DWORD size = arraysize(user_name); | |
| 117 if (::GetUserName(user_name, &size) == 0 || size < 1) { | |
| 118 PLOG(DFATAL) << "GetUserName failed"; | |
| 119 return false; | |
| 120 } | |
| 121 suffix->reserve(size); | |
| 122 suffix->assign(1, L'.'); | |
| 123 suffix->append(user_name, size - 1); | |
| 124 return true; | |
| 125 } | |
| 126 | |
| 127 // Returns Chrome's ProgId as "ChromeHTML|suffix|". | |
|
grt (UTC plus 2)
2012/06/22 14:08:24
although there are other funcs in this file with C
gab
2012/06/22 18:24:04
Done.
| |
| 128 // |suffix| can be the empty string. | |
| 129 string16 GetChromeHTMLProgId(const string16& suffix) { | |
|
grt (UTC plus 2)
2012/06/22 14:08:24
i'm not too fond of the fact that this is called a
gab
2012/06/22 18:24:04
Done.
Cached it locally as a static variable whic
| |
| 130 string16 chrome_html(ShellUtil::kChromeHTMLProgId); | |
| 131 chrome_html.append(suffix); | |
| 132 | |
| 133 // ProgIds cannot be longer than 39 characters. | |
| 134 // Ref: http://msdn.microsoft.com/en-us/library/aa911706.aspx. | |
| 135 // We can however only make sure it's compliant with MSDN in the new-style of | |
|
grt (UTC plus 2)
2012/06/22 14:08:24
suggest: "Make all new registrations comply with t
gab
2012/06/22 18:24:04
Done.
| |
| 136 // registrations as we didn't respect this before (and can't go back on what's | |
| 137 // currently installed). | |
| 138 string16 new_style_suffix; | |
| 139 if (GetNewUserSpecificRegistrySuffix(&new_style_suffix) && | |
| 140 suffix.compare(new_style_suffix) == 0 && chrome_html.length() > 39) { | |
| 141 LOG(DFATAL) << "The suffixed ProgId is longer than 39 characters."; | |
|
grt (UTC plus 2)
2012/06/22 14:08:24
suggest NOTREACHED(); since the log will be meanin
gab
2012/06/22 18:24:04
Done.
| |
| 142 chrome_html.erase(39, string16::npos); | |
|
grt (UTC plus 2)
2012/06/22 14:08:24
chrome_html.erase(39);
gab
2012/06/22 18:24:04
Done.
| |
| 143 } | |
| 144 return chrome_html; | |
| 145 } | |
| 146 | |
| 88 // This class represents a single registry entry. The objective is to | 147 // This class represents a single registry entry. The objective is to |
| 89 // encapsulate all the registry entries required for registering Chrome at one | 148 // encapsulate all the registry entries required for registering Chrome at one |
| 90 // place. This class can not be instantiated outside the class and the objects | 149 // place. This class can not be instantiated outside the class and the objects |
| 91 // of this class type can be obtained only by calling a static method of this | 150 // of this class type can be obtained only by calling a static method of this |
| 92 // class. | 151 // class. |
| 93 class RegistryEntry { | 152 class RegistryEntry { |
| 94 public: | 153 public: |
| 95 // A bit-field enum of places to look for this key in the Windows registry. | 154 // A bit-field enum of places to look for this key in the Windows registry. |
| 96 enum LookForIn { | 155 enum LookForIn { |
| 97 LOOK_IN_HKCU = 1 << 0, | 156 LOOK_IN_HKCU = 1 << 0, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 // <root hkey>\Software\Classes\<app_id>\.exe\shell\<verb>\command | 233 // <root hkey>\Software\Classes\<app_id>\.exe\shell\<verb>\command |
| 175 entries->push_front(new RegistryEntry(sub_path, delegate_command)); | 234 entries->push_front(new RegistryEntry(sub_path, delegate_command)); |
| 176 entries->push_front(new RegistryEntry( | 235 entries->push_front(new RegistryEntry( |
| 177 sub_path, ShellUtil::kRegDelegateExecute, delegate_guid)); | 236 sub_path, ShellUtil::kRegDelegateExecute, delegate_guid)); |
| 178 } | 237 } |
| 179 } | 238 } |
| 180 | 239 |
| 181 // File association ProgId | 240 // File association ProgId |
| 182 string16 chrome_html_prog_id(ShellUtil::kRegClasses); | 241 string16 chrome_html_prog_id(ShellUtil::kRegClasses); |
| 183 chrome_html_prog_id.push_back(FilePath::kSeparators[0]); | 242 chrome_html_prog_id.push_back(FilePath::kSeparators[0]); |
| 184 chrome_html_prog_id.append(ShellUtil::kChromeHTMLProgId); | 243 chrome_html_prog_id.append(GetChromeHTMLProgId(suffix)); |
| 185 chrome_html_prog_id.append(suffix); | |
| 186 entries->push_front(new RegistryEntry( | 244 entries->push_front(new RegistryEntry( |
| 187 chrome_html_prog_id, ShellUtil::kChromeHTMLProgIdDesc)); | 245 chrome_html_prog_id, ShellUtil::kChromeHTMLProgIdDesc)); |
| 188 entries->push_front(new RegistryEntry( | 246 entries->push_front(new RegistryEntry( |
| 189 chrome_html_prog_id, ShellUtil::kRegUrlProtocol, L"")); | 247 chrome_html_prog_id, ShellUtil::kRegUrlProtocol, L"")); |
| 190 entries->push_front(new RegistryEntry( | 248 entries->push_front(new RegistryEntry( |
| 191 chrome_html_prog_id + ShellUtil::kRegDefaultIcon, icon_path)); | 249 chrome_html_prog_id + ShellUtil::kRegDefaultIcon, icon_path)); |
| 192 entries->push_front(new RegistryEntry( | 250 entries->push_front(new RegistryEntry( |
| 193 chrome_html_prog_id + ShellUtil::kRegShellOpen, open_cmd)); | 251 chrome_html_prog_id + ShellUtil::kRegShellOpen, open_cmd)); |
| 194 if (set_delegate_execute) { | 252 if (set_delegate_execute) { |
| 195 entries->push_front(new RegistryEntry( | 253 entries->push_front(new RegistryEntry( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 } | 285 } |
| 228 | 286 |
| 229 // This method returns a list of the registry entries needed to declare a | 287 // This method returns a list of the registry entries needed to declare a |
| 230 // capability of handling a protocol on Windows. | 288 // capability of handling a protocol on Windows. |
| 231 static bool GetProtocolCapabilityEntries(BrowserDistribution* dist, | 289 static bool GetProtocolCapabilityEntries(BrowserDistribution* dist, |
| 232 const string16& suffix, | 290 const string16& suffix, |
| 233 const string16& protocol, | 291 const string16& protocol, |
| 234 std::list<RegistryEntry*>* entries) { | 292 std::list<RegistryEntry*>* entries) { |
| 235 entries->push_front(new RegistryEntry( | 293 entries->push_front(new RegistryEntry( |
| 236 GetCapabilitiesKey(dist, suffix).append(L"\\URLAssociations"), | 294 GetCapabilitiesKey(dist, suffix).append(L"\\URLAssociations"), |
| 237 protocol, string16(ShellUtil::kChromeHTMLProgId).append(suffix))); | 295 protocol, GetChromeHTMLProgId(suffix))); |
| 238 return true; | 296 return true; |
| 239 } | 297 } |
| 240 | 298 |
| 241 // This method returns a list of all the registry entries required to fully | 299 // This method returns a list of all the registry entries required to fully |
| 242 // integrate Chrome with Windows (i.e. StartMenuInternet, Default Programs, | 300 // integrate Chrome with Windows (i.e. StartMenuInternet, Default Programs, |
| 243 // AppPaths, etc.). This entries need to be registered in HKLM prior to Win8. | 301 // AppPaths, etc.). This entries need to be registered in HKLM prior to Win8. |
| 244 static bool GetShellIntegrationEntries(BrowserDistribution* dist, | 302 static bool GetShellIntegrationEntries(BrowserDistribution* dist, |
| 245 const string16& chrome_exe, | 303 const string16& chrome_exe, |
| 246 const string16& suffix, | 304 const string16& suffix, |
| 247 std::list<RegistryEntry*>* entries) { | 305 std::list<RegistryEntry*>* entries) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 dist->GetLongAppDescription())); | 346 dist->GetLongAppDescription())); |
| 289 entries->push_front(new RegistryEntry( | 347 entries->push_front(new RegistryEntry( |
| 290 capabilities, ShellUtil::kRegApplicationIcon, icon_path)); | 348 capabilities, ShellUtil::kRegApplicationIcon, icon_path)); |
| 291 entries->push_front(new RegistryEntry( | 349 entries->push_front(new RegistryEntry( |
| 292 capabilities, ShellUtil::kRegApplicationName, | 350 capabilities, ShellUtil::kRegApplicationName, |
| 293 dist->GetAppShortCutName())); | 351 dist->GetAppShortCutName())); |
| 294 | 352 |
| 295 entries->push_front(new RegistryEntry(capabilities + L"\\Startmenu", | 353 entries->push_front(new RegistryEntry(capabilities + L"\\Startmenu", |
| 296 L"StartMenuInternet", reg_app_name)); | 354 L"StartMenuInternet", reg_app_name)); |
| 297 | 355 |
| 298 string16 html_prog_id(ShellUtil::kChromeHTMLProgId); | 356 string16 html_prog_id(GetChromeHTMLProgId(suffix)); |
| 299 html_prog_id.append(suffix); | |
| 300 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { | 357 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { |
| 301 entries->push_front(new RegistryEntry( | 358 entries->push_front(new RegistryEntry( |
| 302 capabilities + L"\\FileAssociations", | 359 capabilities + L"\\FileAssociations", |
| 303 ShellUtil::kFileAssociations[i], html_prog_id)); | 360 ShellUtil::kFileAssociations[i], html_prog_id)); |
| 304 } | 361 } |
| 305 for (int i = 0; ShellUtil::kPotentialProtocolAssociations[i] != NULL; | 362 for (int i = 0; ShellUtil::kPotentialProtocolAssociations[i] != NULL; |
| 306 i++) { | 363 i++) { |
| 307 entries->push_front(new RegistryEntry( | 364 entries->push_front(new RegistryEntry( |
| 308 capabilities + L"\\URLAssociations", | 365 capabilities + L"\\URLAssociations", |
| 309 ShellUtil::kPotentialProtocolAssociations[i], html_prog_id)); | 366 ShellUtil::kPotentialProtocolAssociations[i], html_prog_id)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 return true; | 415 return true; |
| 359 } | 416 } |
| 360 | 417 |
| 361 // This method returns a list of all the user level registry entries that | 418 // This method returns a list of all the user level registry entries that |
| 362 // are needed to make Chromium default browser. | 419 // are needed to make Chromium default browser. |
| 363 static bool GetUserEntries(BrowserDistribution* dist, | 420 static bool GetUserEntries(BrowserDistribution* dist, |
| 364 const string16& chrome_exe, | 421 const string16& chrome_exe, |
| 365 const string16& suffix, | 422 const string16& suffix, |
| 366 std::list<RegistryEntry*>* entries) { | 423 std::list<RegistryEntry*>* entries) { |
| 367 // File extension associations. | 424 // File extension associations. |
| 368 string16 html_prog_id(ShellUtil::kChromeHTMLProgId); | 425 string16 html_prog_id(GetChromeHTMLProgId(suffix)); |
| 369 html_prog_id.append(suffix); | |
| 370 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { | 426 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { |
| 371 string16 ext_key(ShellUtil::kRegClasses); | 427 string16 ext_key(ShellUtil::kRegClasses); |
| 372 ext_key.push_back(FilePath::kSeparators[0]); | 428 ext_key.push_back(FilePath::kSeparators[0]); |
| 373 ext_key.append(ShellUtil::kFileAssociations[i]); | 429 ext_key.append(ShellUtil::kFileAssociations[i]); |
| 374 entries->push_front(new RegistryEntry(ext_key, html_prog_id)); | 430 entries->push_front(new RegistryEntry(ext_key, html_prog_id)); |
| 375 } | 431 } |
| 376 | 432 |
| 377 // Protocols associations. | 433 // Protocols associations. |
| 378 string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); | 434 string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); |
| 379 string16 chrome_icon = ShellUtil::GetChromeIcon(dist, chrome_exe); | 435 string16 chrome_icon = ShellUtil::GetChromeIcon(dist, chrome_exe); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 | 726 |
| 671 // <root hkey>\Software\Classes\<app_id> | 727 // <root hkey>\Software\Classes\<app_id> |
| 672 string16 key(ShellUtil::kRegClasses); | 728 string16 key(ShellUtil::kRegClasses); |
| 673 key.push_back(FilePath::kSeparators[0]); | 729 key.push_back(FilePath::kSeparators[0]); |
| 674 key.append(app_id); | 730 key.append(app_id); |
| 675 InstallUtil::DeleteRegistryKey(root_key, key); | 731 InstallUtil::DeleteRegistryKey(root_key, key); |
| 676 | 732 |
| 677 // <root hkey>\Software\Classes\ChromiumHTML[.user]\shell\open\command | 733 // <root hkey>\Software\Classes\ChromiumHTML[.user]\shell\open\command |
| 678 key = ShellUtil::kRegClasses; | 734 key = ShellUtil::kRegClasses; |
| 679 key.push_back(FilePath::kSeparators[0]); | 735 key.push_back(FilePath::kSeparators[0]); |
| 680 key.append(ShellUtil::kChromeHTMLProgId); | 736 key.append(GetChromeHTMLProgId(installation_suffix)); |
| 681 key.append(installation_suffix); | |
| 682 key.append(ShellUtil::kRegShellOpen); | 737 key.append(ShellUtil::kRegShellOpen); |
| 683 InstallUtil::DeleteRegistryValue(root_key, key, | 738 InstallUtil::DeleteRegistryValue(root_key, key, |
| 684 ShellUtil::kRegDelegateExecute); | 739 ShellUtil::kRegDelegateExecute); |
| 685 } | 740 } |
| 686 } | 741 } |
| 687 | 742 |
| 688 // Returns true if the current install's |chrome_exe| has been registered with | 743 // Returns true if the current install's |chrome_exe| has been registered with |
| 689 // |suffix|. | 744 // |suffix|. |
| 690 // |confirmation_level| is the level of verification desired as described in | 745 // |confirmation_level| is the level of verification desired as described in |
| 691 // the RegistrationConfirmationLevel enum above. | 746 // the RegistrationConfirmationLevel enum above. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 // Assert that |reg_key| points to |chrome_exe| in HKLM. | 795 // Assert that |reg_key| points to |chrome_exe| in HKLM. |
| 741 const RegKey key_hklm(HKEY_LOCAL_MACHINE, reg_key.c_str(), KEY_QUERY_VALUE); | 796 const RegKey key_hklm(HKEY_LOCAL_MACHINE, reg_key.c_str(), KEY_QUERY_VALUE); |
| 742 string16 hklm_value; | 797 string16 hklm_value; |
| 743 if (key_hklm.ReadValue(L"", &hklm_value) == ERROR_SUCCESS) { | 798 if (key_hklm.ReadValue(L"", &hklm_value) == ERROR_SUCCESS) { |
| 744 return InstallUtil::ProgramCompare( | 799 return InstallUtil::ProgramCompare( |
| 745 FilePath(chrome_exe)).Evaluate(hklm_value); | 800 FilePath(chrome_exe)).Evaluate(hklm_value); |
| 746 } | 801 } |
| 747 return false; | 802 return false; |
| 748 } | 803 } |
| 749 | 804 |
| 750 // Sets |suffix| to this user's username preceded by a dot. This suffix is then | 805 // Sets |suffix| to a base 16 encoding of this user's sid preceded by a dot, on |
| 751 // meant to be added to all registration that may conflict with another | 806 // user-level installs, preferably. |
| 752 // user-level Chrome install. | |
| 753 // Returns true unless the OS call to retrieve the username fails. | |
| 754 bool GetUserSpecificRegistrySuffix(string16* suffix) { | |
| 755 wchar_t user_name[256]; | |
| 756 DWORD size = arraysize(user_name); | |
| 757 if (::GetUserName(user_name, &size) == 0 || size < 1) { | |
| 758 PLOG(DFATAL) << "GetUserName failed"; | |
| 759 return false; | |
| 760 } | |
| 761 suffix->reserve(size); | |
| 762 suffix->assign(1, L'.'); | |
| 763 suffix->append(user_name, size - 1); | |
| 764 return true; | |
| 765 } | |
| 766 | |
| 767 // Sets |suffix| to the current user's username, preceded by a dot, on | |
| 768 // user-level installs. | |
| 769 // To support old-style user-level installs however, |suffix| is cleared if | 807 // To support old-style user-level installs however, |suffix| is cleared if |
| 770 // the user currently owns the non-suffixed HKLM registrations. | 808 // the user currently owns the non-suffixed HKLM registrations. |
| 771 // |suffix| is also cleared on system-level installs. | 809 // |suffix| can also be set to the user's username if the current install |
| 810 // is suffixed as per the old-style registrations. | |
| 811 // |suffix| is cleared on system-level installs. | |
| 772 // |suffix| should then be appended to all Chrome properties that may conflict | 812 // |suffix| should then be appended to all Chrome properties that may conflict |
| 773 // with other Chrome user-level installs. | 813 // with other Chrome user-level installs. |
| 774 // Returns true unless one of the underlying calls fails. | 814 // Returns true unless one of the underlying calls fails. |
| 775 bool GetInstallationSpecificSuffix(BrowserDistribution* dist, | 815 bool GetInstallationSpecificSuffix(BrowserDistribution* dist, |
| 776 const string16& chrome_exe, | 816 const string16& chrome_exe, |
| 777 string16* suffix) { | 817 string16* suffix) { |
| 778 if (!InstallUtil::IsPerUserInstall(chrome_exe.c_str()) || | 818 if (!InstallUtil::IsPerUserInstall(chrome_exe.c_str()) || |
| 779 QuickIsChromeRegistered(dist, chrome_exe, string16(), | 819 QuickIsChromeRegistered(dist, chrome_exe, string16(), |
| 780 CONFIRM_SHELL_REGISTRATION)) { | 820 CONFIRM_SHELL_REGISTRATION)) { |
| 781 // No suffix on system-level installs and user-level installs already | 821 // No suffix on system-level installs and user-level installs already |
| 782 // registered with no suffix. | 822 // registered with no suffix. |
| 783 suffix->clear(); | 823 suffix->clear(); |
| 784 return true; | 824 return true; |
| 785 } else { | |
| 786 return GetUserSpecificRegistrySuffix(suffix); | |
| 787 } | 825 } |
| 826 | |
| 827 string16 old_suffix; | |
| 828 if (!GetOldUserSpecificRegistrySuffix(&old_suffix)) { | |
| 829 return false; | |
| 830 } else if (QuickIsChromeRegistered(dist, chrome_exe, old_suffix, | |
| 831 CONFIRM_SHELL_REGISTRATION)) { | |
| 832 // Username suffix for installs that are suffixed as per the old-style. | |
| 833 suffix->assign(old_suffix); | |
| 834 return true; | |
| 835 } | |
| 836 | |
| 837 return GetNewUserSpecificRegistrySuffix(suffix); | |
| 788 } | 838 } |
| 789 | 839 |
| 790 // Returns the root registry key (HKLM or HKCU) into which shell integration | 840 // Returns the root registry key (HKLM or HKCU) into which shell integration |
| 791 // registration for default protocols must be placed. As of Windows 8 everything | 841 // registration for default protocols must be placed. As of Windows 8 everything |
| 792 // can go in HKCU for per-user installs. | 842 // can go in HKCU for per-user installs. |
| 793 HKEY DetermineShellIntegrationRoot(bool is_per_user) { | 843 HKEY DetermineShellIntegrationRoot(bool is_per_user) { |
| 794 return is_per_user && base::win::GetVersion() >= base::win::VERSION_WIN8 ? | 844 return is_per_user && base::win::GetVersion() >= base::win::VERSION_WIN8 ? |
| 795 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; | 845 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; |
| 796 } | 846 } |
| 797 | 847 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1053 key.ReadValue(kReinstallCommand, &command) == ERROR_SUCCESS && | 1103 key.ReadValue(kReinstallCommand, &command) == ERROR_SUCCESS && |
| 1054 !command.empty()) { | 1104 !command.empty()) { |
| 1055 (*browsers)[name] = command; | 1105 (*browsers)[name] = command; |
| 1056 } | 1106 } |
| 1057 } | 1107 } |
| 1058 } | 1108 } |
| 1059 } | 1109 } |
| 1060 | 1110 |
| 1061 string16 ShellUtil::GetCurrentInstallationSuffix(BrowserDistribution* dist, | 1111 string16 ShellUtil::GetCurrentInstallationSuffix(BrowserDistribution* dist, |
| 1062 const string16& chrome_exe) { | 1112 const string16& chrome_exe) { |
| 1113 // This method is somewhat the opposite of GetInstallationSpecificSuffix(). | |
| 1114 // In this case we are not trying to determine the current suffix for the | |
| 1115 // upcoming installation (i.e. not trying to stick to a currently bad | |
| 1116 // registration style if one is present). | |
| 1117 // Here we want to determine which suffix we should use at run-time. | |
| 1118 // In order of preference, we prefer (for user-level installs): | |
| 1119 // 1) Base 16 encoded sid (new-style). | |
| 1120 // 2) Username (old-style). | |
| 1121 // 3) Unsuffixed (even worst). | |
| 1063 string16 tested_suffix; | 1122 string16 tested_suffix; |
| 1064 if (!InstallUtil::IsPerUserInstall(chrome_exe.c_str()) || | 1123 if (!InstallUtil::IsPerUserInstall(chrome_exe.c_str()) || |
| 1065 !GetUserSpecificRegistrySuffix(&tested_suffix) || | 1124 !GetNewUserSpecificRegistrySuffix(&tested_suffix) || |
|
grt (UTC plus 2)
2012/06/22 14:08:24
a failure in GetNewUserSpecificRegistrySuffix mean
gab
2012/06/22 18:24:04
Ah yes, good catch, changed it to check old suffix
| |
| 1125 !QuickIsChromeRegistered(dist, chrome_exe, tested_suffix, | |
| 1126 CONFIRM_PROGID_REGISTRATION) || | |
| 1127 !GetOldUserSpecificRegistrySuffix(&tested_suffix) || | |
| 1066 !QuickIsChromeRegistered(dist, chrome_exe, tested_suffix, | 1128 !QuickIsChromeRegistered(dist, chrome_exe, tested_suffix, |
| 1067 CONFIRM_PROGID_REGISTRATION)) { | 1129 CONFIRM_PROGID_REGISTRATION)) { |
| 1130 DCHECK(InstallUtil::IsPerUserInstall(chrome_exe.c_str()) || | |
|
grt (UTC plus 2)
2012/06/22 14:08:24
it's not clear to me what this is checking. shoul
gab
2012/06/22 18:24:04
Ah yes, good catch :)! Added a comment to clarify.
| |
| 1131 QuickIsChromeRegistered(dist, chrome_exe, string16(), | |
| 1132 CONFIRM_PROGID_REGISTRATION)); | |
| 1068 return string16(); | 1133 return string16(); |
| 1069 } | 1134 } |
| 1070 return tested_suffix; | 1135 return tested_suffix; |
| 1071 } | 1136 } |
| 1072 | 1137 |
| 1073 string16 ShellUtil::GetApplicationName(BrowserDistribution* dist, | 1138 string16 ShellUtil::GetApplicationName(BrowserDistribution* dist, |
| 1074 const string16& chrome_exe) { | 1139 const string16& chrome_exe) { |
| 1075 string16 app_name = dist->GetBaseAppName(); | 1140 string16 app_name = dist->GetBaseAppName(); |
| 1076 app_name += GetCurrentInstallationSuffix(dist, chrome_exe); | 1141 app_name += GetCurrentInstallationSuffix(dist, chrome_exe); |
| 1077 return app_name; | 1142 return app_name; |
| 1078 } | 1143 } |
| 1079 | 1144 |
| 1080 string16 ShellUtil::GetBrowserModelId(BrowserDistribution* dist, | 1145 string16 ShellUtil::GetBrowserModelId(BrowserDistribution* dist, |
| 1081 const string16& chrome_exe) { | 1146 const string16& chrome_exe) { |
| 1082 string16 app_id(dist->GetBaseAppId()); | 1147 string16 app_id(dist->GetBaseAppId()); |
| 1083 string16 suffix; | 1148 string16 suffix; |
| 1084 if (InstallUtil::IsPerUserInstall(chrome_exe.c_str()) && | 1149 if (InstallUtil::IsPerUserInstall(chrome_exe.c_str()) && |
| 1085 !GetUserSpecificRegistrySuffix(&suffix)) { | 1150 !GetNewUserSpecificRegistrySuffix(&suffix)) { |
| 1086 NOTREACHED(); | 1151 NOTREACHED(); |
| 1087 } | 1152 } |
| 1088 // There is only one component (i.e. the suffixed appid) in this case, but it | 1153 // There is only one component (i.e. the suffixed appid) in this case, but it |
| 1089 // is still necessary to go through the appid constructor to make sure the | 1154 // is still necessary to go through the appid constructor to make sure the |
| 1090 // returned appid is truncated if necessary. | 1155 // returned appid is truncated if necessary. |
| 1091 std::vector<string16> components(1, app_id.append(suffix)); | 1156 std::vector<string16> components(1, app_id.append(suffix)); |
| 1092 return BuildAppModelId(components); | 1157 return BuildAppModelId(components); |
| 1093 } | 1158 } |
| 1094 | 1159 |
| 1095 string16 ShellUtil::BuildAppModelId( | 1160 string16 ShellUtil::BuildAppModelId( |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1513 chrome_exe.c_str(), | 1578 chrome_exe.c_str(), |
| 1514 shortcut.c_str(), | 1579 shortcut.c_str(), |
| 1515 chrome_path.value().c_str(), | 1580 chrome_path.value().c_str(), |
| 1516 arguments.c_str(), | 1581 arguments.c_str(), |
| 1517 description.c_str(), | 1582 description.c_str(), |
| 1518 icon_path.c_str(), | 1583 icon_path.c_str(), |
| 1519 icon_index, | 1584 icon_index, |
| 1520 app_id.c_str(), | 1585 app_id.c_str(), |
| 1521 ConvertShellUtilShortcutOptionsToFileUtil(options)); | 1586 ConvertShellUtilShortcutOptionsToFileUtil(options)); |
| 1522 } | 1587 } |
| OLD | NEW |