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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 uint32_t look_for_in) { | 675 uint32_t look_for_in) { |
676 std::vector<std::unique_ptr<RegistryEntry>> entries; | 676 std::vector<std::unique_ptr<RegistryEntry>> entries; |
677 GetProtocolCapabilityEntries(suffix, protocol, &entries); | 677 GetProtocolCapabilityEntries(suffix, protocol, &entries); |
678 return AreEntriesAsDesired(entries, look_for_in); | 678 return AreEntriesAsDesired(entries, look_for_in); |
679 } | 679 } |
680 | 680 |
681 // This method registers Chrome by launching an elevated setup.exe. That will | 681 // This method registers Chrome by launching an elevated setup.exe. That will |
682 // show the user the standard elevation prompt. If the user accepts it the new | 682 // show the user the standard elevation prompt. If the user accepts it the new |
683 // process will make the necessary changes and return SUCCESS that we capture | 683 // process will make the necessary changes and return SUCCESS that we capture |
684 // and return. If protocol is non-empty we will also register Chrome as being | 684 // and return. If protocol is non-empty we will also register Chrome as being |
685 // capable of handling the protocol. This is most commonly used on per-user | 685 // capable of handling the protocol. This is used for general browser |
686 // installs on Windows 7 where setup.exe did not have permission to register | 686 // registration on Windows 7 for per-user installs where setup.exe did not have |
687 // Chrome during install. It may also be used on all OSs for system-level | 687 // permission to register Chrome during install. It may also be used on Windows |
688 // installs in case Chrome's registration is somehow broken or missing. | 688 // 7 for system-level installs to register Chrome for a specific protocol. |
689 bool ElevateAndRegisterChrome(BrowserDistribution* dist, | 689 bool ElevateAndRegisterChrome(BrowserDistribution* dist, |
690 const base::FilePath& chrome_exe, | 690 const base::FilePath& chrome_exe, |
691 const base::string16& suffix, | 691 const base::string16& suffix, |
692 const base::string16& protocol) { | 692 const base::string16& protocol) { |
693 // Check for setup.exe in the same directory as chrome.exe, as is the case | 693 // Check for setup.exe in the same directory as chrome.exe, as is the case |
694 // when running out of a build output directory. | 694 // when running out of a build output directory. |
695 base::FilePath exe_path = chrome_exe.DirName().Append(installer::kSetupExe); | 695 base::FilePath exe_path = chrome_exe.DirName().Append(installer::kSetupExe); |
696 | 696 |
697 // Failing that, read the path to setup.exe from Chrome's ClientState key, | 697 // Failing that, read the path to setup.exe from Chrome's ClientState key, |
698 // which is the canonical location of the installer for all types of installs | 698 // which is the canonical location of the installer for all types of installs |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2095 std::vector<std::unique_ptr<RegistryEntry>> progid_and_appreg_entries; | 2095 std::vector<std::unique_ptr<RegistryEntry>> progid_and_appreg_entries; |
2096 std::vector<std::unique_ptr<RegistryEntry>> shell_entries; | 2096 std::vector<std::unique_ptr<RegistryEntry>> shell_entries; |
2097 GetChromeProgIdEntries(dist, chrome_exe, suffix, | 2097 GetChromeProgIdEntries(dist, chrome_exe, suffix, |
2098 &progid_and_appreg_entries); | 2098 &progid_and_appreg_entries); |
2099 GetChromeAppRegistrationEntries(chrome_exe, suffix, | 2099 GetChromeAppRegistrationEntries(chrome_exe, suffix, |
2100 &progid_and_appreg_entries); | 2100 &progid_and_appreg_entries); |
2101 GetShellIntegrationEntries(dist, chrome_exe, suffix, &shell_entries); | 2101 GetShellIntegrationEntries(dist, chrome_exe, suffix, &shell_entries); |
2102 result = (AddRegistryEntries(root, progid_and_appreg_entries) && | 2102 result = (AddRegistryEntries(root, progid_and_appreg_entries) && |
2103 AddRegistryEntries(root, shell_entries)); | 2103 AddRegistryEntries(root, shell_entries)); |
2104 } else if (elevate_if_not_admin && | 2104 } else if (elevate_if_not_admin && |
2105 base::win::GetVersion() >= base::win::VERSION_VISTA && | 2105 base::win::GetVersion() >= base::win::VERSION_VISTA && |
2106 ElevateAndRegisterChrome(dist, chrome_exe, suffix, base::string16())) { | 2106 (!user_level || ElevateAndRegisterChrome(dist, chrome_exe, suffix, |
gab
2017/05/15 16:50:17
Would it perhaps be cleaner to tweak |elevate_if_n
grt (UTC plus 2)
2017/05/15 21:13:59
I think we want the quick "result = true;" here as
gab
2017/05/16 15:08:11
I think we want |elevate_if_not_admin| to be false
| |
2107 base::string16()))) { | |
2107 // If the user is not an admin and OS is between Vista and Windows 7 | 2108 // If the user is not an admin and OS is between Vista and Windows 7 |
2108 // inclusively, try to elevate and register. This is only intended for | 2109 // inclusively, try to elevate and register. This is only intended for |
2109 // user-level installs as system-level installs should always be run with | 2110 // user-level installs as system-level installs should always be run with |
2110 // admin rights. | 2111 // admin rights. |
2111 result = true; | 2112 result = true; |
2112 } else { | 2113 } else { |
2113 // If we got to this point then all we can do is create ProgId and basic app | 2114 // If we got to this point then all we can do is create ProgId and basic app |
2114 // registrations under HKCU. | 2115 // registrations under HKCU. |
2115 std::vector<std::unique_ptr<RegistryEntry>> entries; | 2116 std::vector<std::unique_ptr<RegistryEntry>> entries; |
2116 GetChromeProgIdEntries(dist, chrome_exe, base::string16(), &entries); | 2117 GetChromeProgIdEntries(dist, chrome_exe, base::string16(), &entries); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2343 for (const auto& entry : entries) | 2344 for (const auto& entry : entries) |
2344 entry->AddToWorkItemList(root, items.get()); | 2345 entry->AddToWorkItemList(root, items.get()); |
2345 | 2346 |
2346 // Apply all the registry changes and if there is a problem, rollback | 2347 // Apply all the registry changes and if there is a problem, rollback |
2347 if (!items->Do()) { | 2348 if (!items->Do()) { |
2348 items->Rollback(); | 2349 items->Rollback(); |
2349 return false; | 2350 return false; |
2350 } | 2351 } |
2351 return true; | 2352 return true; |
2352 } | 2353 } |
OLD | NEW |