| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 DCHECK(default_renderer); | 62 DCHECK(default_renderer); |
| 63 DCHECK(renderer_exclusion_list); | 63 DCHECK(renderer_exclusion_list); |
| 64 | 64 |
| 65 *default_renderer = RENDERER_NOT_SPECIFIED; | 65 *default_renderer = RENDERER_NOT_SPECIFIED; |
| 66 renderer_exclusion_list->clear(); | 66 renderer_exclusion_list->clear(); |
| 67 | 67 |
| 68 base::win::RegKey config_key; | 68 base::win::RegKey config_key; |
| 69 DWORD value = RENDERER_NOT_SPECIFIED; | 69 DWORD value = RENDERER_NOT_SPECIFIED; |
| 70 std::wstring settings_value( | 70 std::wstring settings_value( |
| 71 ASCIIToWide(policy::key::kChromeFrameRendererSettings)); | 71 ASCIIToWide(policy::key::kChromeFrameRendererSettings)); |
| 72 LONG result = ERROR_SUCCESS; |
| 72 for (int i = 0; i < arraysize(kRootKeys); ++i) { | 73 for (int i = 0; i < arraysize(kRootKeys); ++i) { |
| 73 if (config_key.Open(kRootKeys[i], policy::kRegistrySubKey, KEY_READ) && | 74 result = config_key.Open(kRootKeys[i], policy::kRegistrySubKey, KEY_READ); |
| 74 config_key.ReadValueDW(settings_value.c_str(), &value)) { | 75 if (result == ERROR_SUCCESS) { |
| 75 break; | 76 result = config_key.ReadValueDW(settings_value.c_str(), &value); |
| 77 if (result == ERROR_SUCCESS) |
| 78 break; |
| 76 } | 79 } |
| 77 } | 80 } |
| 78 | 81 |
| 79 DCHECK(value == RENDERER_NOT_SPECIFIED || | 82 DCHECK(value == RENDERER_NOT_SPECIFIED || |
| 80 value == RENDER_IN_HOST || | 83 value == RENDER_IN_HOST || |
| 81 value == RENDER_IN_CHROME_FRAME) << | 84 value == RENDER_IN_CHROME_FRAME) << |
| 82 "invalid default renderer setting: " << value; | 85 "invalid default renderer setting: " << value; |
| 83 | 86 |
| 84 if (value != RENDER_IN_HOST && value != RENDER_IN_CHROME_FRAME) { | 87 if (value != RENDER_IN_HOST && value != RENDER_IN_CHROME_FRAME) { |
| 85 DVLOG(1) << "default renderer not specified via policy"; | 88 DVLOG(1) << "default renderer not specified via policy"; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 116 | 119 |
| 117 // static | 120 // static |
| 118 void PolicySettings::ReadApplicationLocaleSetting( | 121 void PolicySettings::ReadApplicationLocaleSetting( |
| 119 std::wstring* application_locale) { | 122 std::wstring* application_locale) { |
| 120 DCHECK(application_locale); | 123 DCHECK(application_locale); |
| 121 | 124 |
| 122 application_locale->clear(); | 125 application_locale->clear(); |
| 123 base::win::RegKey config_key; | 126 base::win::RegKey config_key; |
| 124 std::wstring application_locale_value( | 127 std::wstring application_locale_value( |
| 125 ASCIIToWide(policy::key::kApplicationLocaleValue)); | 128 ASCIIToWide(policy::key::kApplicationLocaleValue)); |
| 129 LONG result = ERROR_SUCCESS; |
| 126 for (int i = 0; i < arraysize(kRootKeys); ++i) { | 130 for (int i = 0; i < arraysize(kRootKeys); ++i) { |
| 127 if (config_key.Open(kRootKeys[i], policy::kRegistrySubKey, KEY_READ) && | 131 result = config_key.Open(kRootKeys[i], policy::kRegistrySubKey, KEY_READ); |
| 128 config_key.ReadValue(application_locale_value.c_str(), | 132 if (result == ERROR_SUCCESS) { |
| 129 application_locale)) { | 133 result = config_key.ReadValue(application_locale_value.c_str(), |
| 130 break; | 134 application_locale); |
| 135 if (result == ERROR_SUCCESS) |
| 136 break; |
| 131 } | 137 } |
| 132 } | 138 } |
| 133 } | 139 } |
| 134 | 140 |
| 135 void PolicySettings::RefreshFromRegistry() { | 141 void PolicySettings::RefreshFromRegistry() { |
| 136 RendererForUrl default_renderer; | 142 RendererForUrl default_renderer; |
| 137 std::vector<std::wstring> renderer_exclusion_list; | 143 std::vector<std::wstring> renderer_exclusion_list; |
| 138 std::vector<std::wstring> content_type_list; | 144 std::vector<std::wstring> content_type_list; |
| 139 std::wstring application_locale; | 145 std::wstring application_locale; |
| 140 | 146 |
| 141 // Read the latest settings from the registry | 147 // Read the latest settings from the registry |
| 142 ReadUrlSettings(&default_renderer, &renderer_exclusion_list); | 148 ReadUrlSettings(&default_renderer, &renderer_exclusion_list); |
| 143 ReadContentTypeSetting(&content_type_list); | 149 ReadContentTypeSetting(&content_type_list); |
| 144 ReadApplicationLocaleSetting(&application_locale); | 150 ReadApplicationLocaleSetting(&application_locale); |
| 145 | 151 |
| 146 // Nofail swap in the new values. (Note: this is all that need be protected | 152 // Nofail swap in the new values. (Note: this is all that need be protected |
| 147 // under a mutex if/when this becomes thread safe.) | 153 // under a mutex if/when this becomes thread safe.) |
| 148 using std::swap; | 154 using std::swap; |
| 149 | 155 |
| 150 swap(default_renderer_, default_renderer); | 156 swap(default_renderer_, default_renderer); |
| 151 swap(renderer_exclusion_list_, renderer_exclusion_list); | 157 swap(renderer_exclusion_list_, renderer_exclusion_list); |
| 152 swap(content_type_list_, content_type_list); | 158 swap(content_type_list_, content_type_list); |
| 153 swap(application_locale_, application_locale); | 159 swap(application_locale_, application_locale); |
| 154 } | 160 } |
| 155 | 161 |
| 156 // static | 162 // static |
| 157 PolicySettings* PolicySettings::GetInstance() { | 163 PolicySettings* PolicySettings::GetInstance() { |
| 158 return Singleton<PolicySettings>::get(); | 164 return Singleton<PolicySettings>::get(); |
| 159 } | 165 } |
| OLD | NEW |