OLD | NEW |
---|---|
1 // Copyright (c) 2010 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/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 for (it = content_type_list_.begin(); | 48 for (it = content_type_list_.begin(); |
49 it != content_type_list_.end(); ++it) { | 49 it != content_type_list_.end(); ++it) { |
50 if (lstrcmpiW(content_type, (*it).c_str()) == 0) { | 50 if (lstrcmpiW(content_type, (*it).c_str()) == 0) { |
51 renderer = RENDER_IN_CHROME_FRAME; | 51 renderer = RENDER_IN_CHROME_FRAME; |
52 break; | 52 break; |
53 } | 53 } |
54 } | 54 } |
55 return renderer; | 55 return renderer; |
56 } | 56 } |
57 | 57 |
58 const CommandLine& PolicySettings::AdditionalLaunchParameters() const { | |
59 return additional_launch_parameters_; | |
60 } | |
61 | |
58 // static | 62 // static |
59 void PolicySettings::ReadUrlSettings( | 63 void PolicySettings::ReadUrlSettings( |
60 RendererForUrl* default_renderer, | 64 RendererForUrl* default_renderer, |
61 std::vector<std::wstring>* renderer_exclusion_list) { | 65 std::vector<std::wstring>* renderer_exclusion_list) { |
62 DCHECK(default_renderer); | 66 DCHECK(default_renderer); |
63 DCHECK(renderer_exclusion_list); | 67 DCHECK(renderer_exclusion_list); |
64 | 68 |
65 *default_renderer = RENDERER_NOT_SPECIFIED; | 69 *default_renderer = RENDERER_NOT_SPECIFIED; |
66 renderer_exclusion_list->clear(); | 70 renderer_exclusion_list->clear(); |
67 | 71 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 sub_key += ASCIIToWide(policy::key::kChromeFrameContentTypes); | 114 sub_key += ASCIIToWide(policy::key::kChromeFrameContentTypes); |
111 | 115 |
112 content_type_list->clear(); | 116 content_type_list->clear(); |
113 for (int i = 0; i < arraysize(kRootKeys) && content_type_list->empty(); | 117 for (int i = 0; i < arraysize(kRootKeys) && content_type_list->empty(); |
114 ++i) { | 118 ++i) { |
115 EnumerateKeyValues(kRootKeys[i], sub_key.c_str(), content_type_list); | 119 EnumerateKeyValues(kRootKeys[i], sub_key.c_str(), content_type_list); |
116 } | 120 } |
117 } | 121 } |
118 | 122 |
119 // static | 123 // static |
120 void PolicySettings::ReadApplicationLocaleSetting( | 124 void PolicySettings::ReadStringSetting(const char* value_name, |
121 std::wstring* application_locale) { | 125 std::wstring* value) { |
122 DCHECK(application_locale); | 126 value->clear(); |
grt (UTC plus 2)
2012/03/27 20:00:43
DCHECK(value);
| |
123 | |
124 application_locale->clear(); | |
125 base::win::RegKey config_key; | 127 base::win::RegKey config_key; |
126 std::wstring application_locale_value( | 128 std::wstring value_name_str(ASCIIToWide(value_name)); |
127 ASCIIToWide(policy::key::kApplicationLocaleValue)); | |
128 for (int i = 0; i < arraysize(kRootKeys); ++i) { | 129 for (int i = 0; i < arraysize(kRootKeys); ++i) { |
129 if ((config_key.Open(kRootKeys[i], policy::kRegistryMandatorySubKey, | 130 if ((config_key.Open(kRootKeys[i], policy::kRegistryMandatorySubKey, |
130 KEY_READ) == ERROR_SUCCESS) && | 131 KEY_READ) == ERROR_SUCCESS) && |
131 (config_key.ReadValue(application_locale_value.c_str(), | 132 (config_key.ReadValue(value_name_str.c_str(), |
132 application_locale) == ERROR_SUCCESS)) { | 133 value) == ERROR_SUCCESS)) { |
133 break; | 134 break; |
134 } | 135 } |
135 } | 136 } |
136 } | 137 } |
137 | 138 |
138 void PolicySettings::RefreshFromRegistry() { | 139 void PolicySettings::RefreshFromRegistry() { |
139 RendererForUrl default_renderer; | 140 RendererForUrl default_renderer; |
140 std::vector<std::wstring> renderer_exclusion_list; | 141 std::vector<std::wstring> renderer_exclusion_list; |
141 std::vector<std::wstring> content_type_list; | 142 std::vector<std::wstring> content_type_list; |
142 std::wstring application_locale; | 143 std::wstring application_locale; |
144 CommandLine additional_launch_parameters(CommandLine::NO_PROGRAM); | |
145 std::wstring additional_parameters_str; | |
143 | 146 |
144 // Read the latest settings from the registry | 147 // Read the latest settings from the registry |
145 ReadUrlSettings(&default_renderer, &renderer_exclusion_list); | 148 ReadUrlSettings(&default_renderer, &renderer_exclusion_list); |
146 ReadContentTypeSetting(&content_type_list); | 149 ReadContentTypeSetting(&content_type_list); |
147 ReadApplicationLocaleSetting(&application_locale); | 150 ReadStringSetting(policy::key::kApplicationLocaleValue, &application_locale); |
151 ReadStringSetting(policy::key::kAdditionalLaunchParameters, | |
152 &additional_parameters_str); | |
153 if (!additional_parameters_str.empty()) { | |
154 additional_parameters_str.insert(0, L"fake.exe "); | |
155 additional_launch_parameters.ParseFromString(additional_parameters_str); | |
156 } | |
148 | 157 |
149 // Nofail swap in the new values. (Note: this is all that need be protected | 158 // Nofail swap in the new values. (Note: this is all that need be protected |
150 // under a mutex if/when this becomes thread safe.) | 159 // under a mutex if/when this becomes thread safe.) |
151 using std::swap; | 160 using std::swap; |
152 | 161 |
153 swap(default_renderer_, default_renderer); | 162 swap(default_renderer_, default_renderer); |
154 swap(renderer_exclusion_list_, renderer_exclusion_list); | 163 swap(renderer_exclusion_list_, renderer_exclusion_list); |
155 swap(content_type_list_, content_type_list); | 164 swap(content_type_list_, content_type_list); |
156 swap(application_locale_, application_locale); | 165 swap(application_locale_, application_locale); |
166 swap(additional_launch_parameters_, additional_launch_parameters); | |
157 } | 167 } |
158 | 168 |
159 // static | 169 // static |
160 PolicySettings* PolicySettings::GetInstance() { | 170 PolicySettings* PolicySettings::GetInstance() { |
161 return Singleton<PolicySettings>::get(); | 171 return Singleton<PolicySettings>::get(); |
162 } | 172 } |
OLD | NEW |