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 DCHECK(value); |
123 | 127 value->clear(); |
124 application_locale->clear(); | |
125 base::win::RegKey config_key; | 128 base::win::RegKey config_key; |
126 std::wstring application_locale_value( | 129 std::wstring value_name_str(ASCIIToWide(value_name)); |
127 ASCIIToWide(policy::key::kApplicationLocaleValue)); | |
128 for (int i = 0; i < arraysize(kRootKeys); ++i) { | 130 for (int i = 0; i < arraysize(kRootKeys); ++i) { |
129 if ((config_key.Open(kRootKeys[i], policy::kRegistryMandatorySubKey, | 131 if ((config_key.Open(kRootKeys[i], policy::kRegistryMandatorySubKey, |
130 KEY_READ) == ERROR_SUCCESS) && | 132 KEY_READ) == ERROR_SUCCESS) && |
131 (config_key.ReadValue(application_locale_value.c_str(), | 133 (config_key.ReadValue(value_name_str.c_str(), |
132 application_locale) == ERROR_SUCCESS)) { | 134 value) == ERROR_SUCCESS)) { |
133 break; | 135 break; |
134 } | 136 } |
135 } | 137 } |
136 } | 138 } |
137 | 139 |
138 void PolicySettings::RefreshFromRegistry() { | 140 void PolicySettings::RefreshFromRegistry() { |
139 RendererForUrl default_renderer; | 141 RendererForUrl default_renderer; |
140 std::vector<std::wstring> renderer_exclusion_list; | 142 std::vector<std::wstring> renderer_exclusion_list; |
141 std::vector<std::wstring> content_type_list; | 143 std::vector<std::wstring> content_type_list; |
142 std::wstring application_locale; | 144 std::wstring application_locale; |
| 145 CommandLine additional_launch_parameters(CommandLine::NO_PROGRAM); |
| 146 std::wstring additional_parameters_str; |
143 | 147 |
144 // Read the latest settings from the registry | 148 // Read the latest settings from the registry |
145 ReadUrlSettings(&default_renderer, &renderer_exclusion_list); | 149 ReadUrlSettings(&default_renderer, &renderer_exclusion_list); |
146 ReadContentTypeSetting(&content_type_list); | 150 ReadContentTypeSetting(&content_type_list); |
147 ReadApplicationLocaleSetting(&application_locale); | 151 ReadStringSetting(policy::key::kApplicationLocaleValue, &application_locale); |
| 152 ReadStringSetting(policy::key::kAdditionalLaunchParameters, |
| 153 &additional_parameters_str); |
| 154 if (!additional_parameters_str.empty()) { |
| 155 additional_parameters_str.insert(0, L"fake.exe "); |
| 156 additional_launch_parameters.ParseFromString(additional_parameters_str); |
| 157 } |
148 | 158 |
149 // Nofail swap in the new values. (Note: this is all that need be protected | 159 // Nofail swap in the new values. (Note: this is all that need be protected |
150 // under a mutex if/when this becomes thread safe.) | 160 // under a mutex if/when this becomes thread safe.) |
151 using std::swap; | 161 using std::swap; |
152 | 162 |
153 swap(default_renderer_, default_renderer); | 163 swap(default_renderer_, default_renderer); |
154 swap(renderer_exclusion_list_, renderer_exclusion_list); | 164 swap(renderer_exclusion_list_, renderer_exclusion_list); |
155 swap(content_type_list_, content_type_list); | 165 swap(content_type_list_, content_type_list); |
156 swap(application_locale_, application_locale); | 166 swap(application_locale_, application_locale); |
| 167 swap(additional_launch_parameters_, additional_launch_parameters); |
157 } | 168 } |
158 | 169 |
159 // static | 170 // static |
160 PolicySettings* PolicySettings::GetInstance() { | 171 PolicySettings* PolicySettings::GetInstance() { |
161 return Singleton<PolicySettings>::get(); | 172 return Singleton<PolicySettings>::get(); |
162 } | 173 } |
OLD | NEW |