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 #include "chrome/installer/util/google_update_settings.h" | 5 #include "chrome/installer/util/google_update_settings.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 L"SOFTWARE\\Policies\\Google\\Update"; | 31 L"SOFTWARE\\Policies\\Google\\Update"; |
32 const wchar_t kGoogleUpdateUpdatePolicyValue[] = L"UpdateDefault"; | 32 const wchar_t kGoogleUpdateUpdatePolicyValue[] = L"UpdateDefault"; |
33 const wchar_t kGoogleUpdateUpdateOverrideValuePrefix[] = L"Update"; | 33 const wchar_t kGoogleUpdateUpdateOverrideValuePrefix[] = L"Update"; |
34 const GoogleUpdateSettings::UpdatePolicy kGoogleUpdateDefaultUpdatePolicy = | 34 const GoogleUpdateSettings::UpdatePolicy kGoogleUpdateDefaultUpdatePolicy = |
35 #if defined(GOOGLE_CHROME_BUILD) | 35 #if defined(GOOGLE_CHROME_BUILD) |
36 GoogleUpdateSettings::AUTOMATIC_UPDATES; | 36 GoogleUpdateSettings::AUTOMATIC_UPDATES; |
37 #else | 37 #else |
38 GoogleUpdateSettings::UPDATES_DISABLED; | 38 GoogleUpdateSettings::UPDATES_DISABLED; |
39 #endif | 39 #endif |
40 | 40 |
41 // An list of search results in increasing order of desirability. | |
42 enum EulaSearchResult { | |
43 NO_SETTING, | |
44 FOUND_CLIENT_STATE, | |
45 FOUND_OPPOSITE_SETTING, | |
46 FOUND_SAME_SETTING | |
47 }; | |
48 | |
49 bool ReadGoogleUpdateStrKey(const wchar_t* const name, std::wstring* value) { | 41 bool ReadGoogleUpdateStrKey(const wchar_t* const name, std::wstring* value) { |
50 // The registry functions below will end up going to disk. Do this on another | 42 // The registry functions below will end up going to disk. Do this on another |
51 // thread to avoid slowing the IO thread. http://crbug.com/62121 | 43 // thread to avoid slowing the IO thread. http://crbug.com/62121 |
52 base::ThreadRestrictions::ScopedAllowIO allow_io; | 44 base::ThreadRestrictions::ScopedAllowIO allow_io; |
53 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 45 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
54 std::wstring reg_path = dist->GetStateKey(); | 46 std::wstring reg_path = dist->GetStateKey(); |
55 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ); | 47 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ); |
56 if (key.ReadValue(name, value) != ERROR_SUCCESS) { | 48 if (key.ReadValue(name, value) != ERROR_SUCCESS) { |
57 RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); | 49 RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); |
58 return (hklm_key.ReadValue(name, value) == ERROR_SUCCESS); | 50 return (hklm_key.ReadValue(name, value) == ERROR_SUCCESS); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 93 |
102 bool RemoveGoogleUpdateStrKey(const wchar_t* const name) { | 94 bool RemoveGoogleUpdateStrKey(const wchar_t* const name) { |
103 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 95 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
104 std::wstring reg_path = dist->GetStateKey(); | 96 std::wstring reg_path = dist->GetStateKey(); |
105 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ | KEY_WRITE); | 97 RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ | KEY_WRITE); |
106 if (!key.HasValue(name)) | 98 if (!key.HasValue(name)) |
107 return true; | 99 return true; |
108 return (key.DeleteValue(name) == ERROR_SUCCESS); | 100 return (key.DeleteValue(name) == ERROR_SUCCESS); |
109 } | 101 } |
110 | 102 |
111 EulaSearchResult HasEULASetting(HKEY root, const std::wstring& state_key, | |
112 bool setting) { | |
113 RegKey key; | |
114 DWORD previous_value = setting ? 1 : 0; | |
115 if (key.Open(root, state_key.c_str(), KEY_QUERY_VALUE) != ERROR_SUCCESS) | |
116 return NO_SETTING; | |
117 if (key.ReadValueDW(google_update::kRegEULAAceptedField, | |
118 &previous_value) != ERROR_SUCCESS) | |
119 return FOUND_CLIENT_STATE; | |
120 | |
121 return ((previous_value != 0) == setting) ? | |
122 FOUND_SAME_SETTING : FOUND_OPPOSITE_SETTING; | |
123 } | |
124 | |
125 bool GetChromeChannelInternal(bool system_install, | 103 bool GetChromeChannelInternal(bool system_install, |
126 bool add_multi_modifier, | 104 bool add_multi_modifier, |
127 string16* channel) { | 105 string16* channel) { |
128 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 106 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
129 if (dist->GetChromeChannel(channel)) { | 107 if (dist->GetChromeChannel(channel)) { |
130 return true; | 108 return true; |
131 } | 109 } |
132 | 110 |
133 // The registry functions below will end up going to disk. Do this on another | 111 // The registry functions below will end up going to disk. Do this on another |
134 // thread to avoid slowing the IO thread. http://crbug.com/62121 | 112 // thread to avoid slowing the IO thread. http://crbug.com/62121 |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 data); | 635 data); |
658 } | 636 } |
659 | 637 |
660 bool GoogleUpdateSettings::GetUpdateDetail(bool system_install, | 638 bool GoogleUpdateSettings::GetUpdateDetail(bool system_install, |
661 ProductData* data) { | 639 ProductData* data) { |
662 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 640 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
663 return GetUpdateDetailForApp(system_install, | 641 return GetUpdateDetailForApp(system_install, |
664 dist->GetAppGuid().c_str(), | 642 dist->GetAppGuid().c_str(), |
665 data); | 643 data); |
666 } | 644 } |
OLD | NEW |