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_frame/policy_settings.h" | 5 #include "chrome_frame/policy_settings.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 for (int i = 0; i < arraysize(kRootKeys); ++i) { | 130 for (int i = 0; i < arraysize(kRootKeys); ++i) { |
131 if ((config_key.Open(kRootKeys[i], policy::kRegistryChromePolicyKey, | 131 if ((config_key.Open(kRootKeys[i], policy::kRegistryChromePolicyKey, |
132 KEY_READ) == ERROR_SUCCESS) && | 132 KEY_READ) == ERROR_SUCCESS) && |
133 (config_key.ReadValue(value_name_str.c_str(), | 133 (config_key.ReadValue(value_name_str.c_str(), |
134 value) == ERROR_SUCCESS)) { | 134 value) == ERROR_SUCCESS)) { |
135 break; | 135 break; |
136 } | 136 } |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
| 140 // static |
| 141 void PolicySettings::ReadBoolSetting(const char* value_name, bool* value) { |
| 142 DCHECK(value); |
| 143 base::win::RegKey config_key; |
| 144 string16 value_name_str(ASCIIToWide(value_name)); |
| 145 DWORD dword_value = 0; |
| 146 for (int i = 0; i < arraysize(kRootKeys); ++i) { |
| 147 if ((config_key.Open(kRootKeys[i], policy::kRegistryChromePolicyKey, |
| 148 KEY_QUERY_VALUE) == ERROR_SUCCESS) && |
| 149 (config_key.ReadValueDW(value_name_str.c_str(), |
| 150 &dword_value) == ERROR_SUCCESS)) { |
| 151 *value = (dword_value != 0); |
| 152 break; |
| 153 } |
| 154 } |
| 155 } |
| 156 |
140 void PolicySettings::RefreshFromRegistry() { | 157 void PolicySettings::RefreshFromRegistry() { |
141 RendererForUrl default_renderer; | 158 RendererForUrl default_renderer; |
142 std::vector<std::wstring> renderer_exclusion_list; | 159 std::vector<std::wstring> renderer_exclusion_list; |
143 std::vector<std::wstring> content_type_list; | 160 std::vector<std::wstring> content_type_list; |
144 std::wstring application_locale; | 161 std::wstring application_locale; |
145 CommandLine additional_launch_parameters(CommandLine::NO_PROGRAM); | 162 CommandLine additional_launch_parameters(CommandLine::NO_PROGRAM); |
146 std::wstring additional_parameters_str; | 163 std::wstring additional_parameters_str; |
| 164 bool suppress_turndown_prompt = false; |
147 | 165 |
148 // Read the latest settings from the registry | 166 // Read the latest settings from the registry |
149 ReadUrlSettings(&default_renderer, &renderer_exclusion_list); | 167 ReadUrlSettings(&default_renderer, &renderer_exclusion_list); |
150 ReadContentTypeSetting(&content_type_list); | 168 ReadContentTypeSetting(&content_type_list); |
151 ReadStringSetting(policy::key::kApplicationLocaleValue, &application_locale); | 169 ReadStringSetting(policy::key::kApplicationLocaleValue, &application_locale); |
152 ReadStringSetting(policy::key::kAdditionalLaunchParameters, | 170 ReadStringSetting(policy::key::kAdditionalLaunchParameters, |
153 &additional_parameters_str); | 171 &additional_parameters_str); |
154 if (!additional_parameters_str.empty()) { | 172 if (!additional_parameters_str.empty()) { |
155 additional_parameters_str.insert(0, L"fake.exe "); | 173 additional_parameters_str.insert(0, L"fake.exe "); |
156 additional_launch_parameters.ParseFromString(additional_parameters_str); | 174 additional_launch_parameters.ParseFromString(additional_parameters_str); |
157 } | 175 } |
| 176 ReadBoolSetting(policy::key::kSuppressChromeFrameTurndownPrompt, |
| 177 &suppress_turndown_prompt); |
158 | 178 |
159 // Nofail swap in the new values. (Note: this is all that need be protected | 179 // Nofail swap in the new values. (Note: this is all that need be protected |
160 // under a mutex if/when this becomes thread safe.) | 180 // under a mutex if/when this becomes thread safe.) |
161 using std::swap; | 181 using std::swap; |
162 | 182 |
163 swap(default_renderer_, default_renderer); | 183 swap(default_renderer_, default_renderer); |
164 swap(renderer_exclusion_list_, renderer_exclusion_list); | 184 swap(renderer_exclusion_list_, renderer_exclusion_list); |
165 swap(content_type_list_, content_type_list); | 185 swap(content_type_list_, content_type_list); |
166 swap(application_locale_, application_locale); | 186 swap(application_locale_, application_locale); |
167 swap(additional_launch_parameters_, additional_launch_parameters); | 187 swap(additional_launch_parameters_, additional_launch_parameters); |
| 188 swap(suppress_turndown_prompt_, suppress_turndown_prompt); |
168 } | 189 } |
169 | 190 |
170 // static | 191 // static |
171 PolicySettings* PolicySettings::GetInstance() { | 192 PolicySettings* PolicySettings::GetInstance() { |
172 return Singleton<PolicySettings>::get(); | 193 return Singleton<PolicySettings>::get(); |
173 } | 194 } |
OLD | NEW |