Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(857)

Side by Side Diff: chrome_frame/policy_settings.cc

Issue 6090006: Regkey functions return error code instead of bool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 for (int i = 0; i < arraysize(kRootKeys); ++i) { 72 for (int i = 0; i < arraysize(kRootKeys); ++i) {
73 if (config_key.Open(kRootKeys[i], policy::kRegistrySubKey, KEY_READ) && 73 if ((config_key.Open(kRootKeys[i], policy::kRegistrySubKey,
74 config_key.ReadValueDW(settings_value.c_str(), &value)) { 74 KEY_READ) == ERROR_SUCCESS) &&
75 break; 75 (config_key.ReadValueDW(settings_value.c_str(),
76 &value) == ERROR_SUCCESS)) {
77 break;
76 } 78 }
77 } 79 }
78 80
79 DCHECK(value == RENDERER_NOT_SPECIFIED || 81 DCHECK(value == RENDERER_NOT_SPECIFIED ||
80 value == RENDER_IN_HOST || 82 value == RENDER_IN_HOST ||
81 value == RENDER_IN_CHROME_FRAME) << 83 value == RENDER_IN_CHROME_FRAME) <<
82 "invalid default renderer setting: " << value; 84 "invalid default renderer setting: " << value;
83 85
84 if (value != RENDER_IN_HOST && value != RENDER_IN_CHROME_FRAME) { 86 if (value != RENDER_IN_HOST && value != RENDER_IN_CHROME_FRAME) {
85 DVLOG(1) << "default renderer not specified via policy"; 87 DVLOG(1) << "default renderer not specified via policy";
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // static 119 // static
118 void PolicySettings::ReadApplicationLocaleSetting( 120 void PolicySettings::ReadApplicationLocaleSetting(
119 std::wstring* application_locale) { 121 std::wstring* application_locale) {
120 DCHECK(application_locale); 122 DCHECK(application_locale);
121 123
122 application_locale->clear(); 124 application_locale->clear();
123 base::win::RegKey config_key; 125 base::win::RegKey config_key;
124 std::wstring application_locale_value( 126 std::wstring application_locale_value(
125 ASCIIToWide(policy::key::kApplicationLocaleValue)); 127 ASCIIToWide(policy::key::kApplicationLocaleValue));
126 for (int i = 0; i < arraysize(kRootKeys); ++i) { 128 for (int i = 0; i < arraysize(kRootKeys); ++i) {
127 if (config_key.Open(kRootKeys[i], policy::kRegistrySubKey, KEY_READ) && 129 if ((config_key.Open(kRootKeys[i], policy::kRegistrySubKey,
128 config_key.ReadValue(application_locale_value.c_str(), 130 KEY_READ) == ERROR_SUCCESS) &&
129 application_locale)) { 131 (config_key.ReadValue(application_locale_value.c_str(),
130 break; 132 application_locale) == ERROR_SUCCESS)) {
133 break;
131 } 134 }
132 } 135 }
133 } 136 }
134 137
135 void PolicySettings::RefreshFromRegistry() { 138 void PolicySettings::RefreshFromRegistry() {
136 RendererForUrl default_renderer; 139 RendererForUrl default_renderer;
137 std::vector<std::wstring> renderer_exclusion_list; 140 std::vector<std::wstring> renderer_exclusion_list;
138 std::vector<std::wstring> content_type_list; 141 std::vector<std::wstring> content_type_list;
139 std::wstring application_locale; 142 std::wstring application_locale;
140 143
141 // Read the latest settings from the registry 144 // Read the latest settings from the registry
142 ReadUrlSettings(&default_renderer, &renderer_exclusion_list); 145 ReadUrlSettings(&default_renderer, &renderer_exclusion_list);
143 ReadContentTypeSetting(&content_type_list); 146 ReadContentTypeSetting(&content_type_list);
144 ReadApplicationLocaleSetting(&application_locale); 147 ReadApplicationLocaleSetting(&application_locale);
145 148
146 // Nofail swap in the new values. (Note: this is all that need be protected 149 // Nofail swap in the new values. (Note: this is all that need be protected
147 // under a mutex if/when this becomes thread safe.) 150 // under a mutex if/when this becomes thread safe.)
148 using std::swap; 151 using std::swap;
149 152
150 swap(default_renderer_, default_renderer); 153 swap(default_renderer_, default_renderer);
151 swap(renderer_exclusion_list_, renderer_exclusion_list); 154 swap(renderer_exclusion_list_, renderer_exclusion_list);
152 swap(content_type_list_, content_type_list); 155 swap(content_type_list_, content_type_list);
153 swap(application_locale_, application_locale); 156 swap(application_locale_, application_locale);
154 } 157 }
155 158
156 // static 159 // static
157 PolicySettings* PolicySettings::GetInstance() { 160 PolicySettings* PolicySettings::GetInstance() {
158 return Singleton<PolicySettings>::get(); 161 return Singleton<PolicySettings>::get();
159 } 162 }
OLDNEW
« no previous file with comments | « chrome_frame/crash_reporting/crash_metrics.cc ('k') | chrome_frame/ready_mode/internal/registry_ready_mode_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698