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/browser/ui/webui/options/chromeos/core_chromeos_options_handler
.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler
.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" | 26 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" |
27 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 27 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
28 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
29 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h" | 29 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h" |
30 #include "chrome/browser/chromeos/settings/cros_settings.h" | 30 #include "chrome/browser/chromeos/settings/cros_settings.h" |
31 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/browser/ui/webui/chromeos/ui_account_tweaks.h" | 32 #include "chrome/browser/ui/webui/chromeos/ui_account_tweaks.h" |
33 #include "chrome/browser/ui/webui/options/chromeos/accounts_options_handler.h" | 33 #include "chrome/browser/ui/webui/options/chromeos/accounts_options_handler.h" |
34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
35 #include "chrome/grit/generated_resources.h" | 35 #include "chrome/grit/generated_resources.h" |
| 36 #include "components/onc/onc_pref_names.h" |
36 #include "components/prefs/pref_change_registrar.h" | 37 #include "components/prefs/pref_change_registrar.h" |
37 #include "components/proxy_config/proxy_config_pref_names.h" | 38 #include "components/proxy_config/proxy_config_pref_names.h" |
38 #include "components/user_manager/user_manager.h" | 39 #include "components/user_manager/user_manager.h" |
39 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
40 #include "content/public/browser/user_metrics.h" | 41 #include "content/public/browser/user_metrics.h" |
41 #include "content/public/browser/web_ui.h" | 42 #include "content/public/browser/web_ui.h" |
42 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
43 | 44 |
44 namespace chromeos { | 45 namespace chromeos { |
45 namespace options { | 46 namespace options { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 proxy_config_service_.SetCurrentNetworkGuid(""); | 144 proxy_config_service_.SetCurrentNetworkGuid(""); |
144 // And clear the cached configuration. | 145 // And clear the cached configuration. |
145 proxy_config_service_.UpdateFromPrefs(); | 146 proxy_config_service_.UpdateFromPrefs(); |
146 | 147 |
147 CoreOptionsHandler::InitializeHandler(); | 148 CoreOptionsHandler::InitializeHandler(); |
148 | 149 |
149 PrefService* profile_prefs = NULL; | 150 PrefService* profile_prefs = NULL; |
150 Profile* profile = Profile::FromWebUI(web_ui()); | 151 Profile* profile = Profile::FromWebUI(web_ui()); |
151 if (!ProfileHelper::IsSigninProfile(profile)) { | 152 if (!ProfileHelper::IsSigninProfile(profile)) { |
152 profile_prefs = profile->GetPrefs(); | 153 profile_prefs = profile->GetPrefs(); |
153 ObservePref(prefs::kOpenNetworkConfiguration); | 154 ObservePref(onc::prefs::kOpenNetworkConfiguration); |
154 } | 155 } |
155 ObservePref(proxy_config::prefs::kProxy); | 156 ObservePref(proxy_config::prefs::kProxy); |
156 ObservePref(prefs::kDeviceOpenNetworkConfiguration); | 157 ObservePref(onc::prefs::kDeviceOpenNetworkConfiguration); |
157 proxy_config_service_.SetPrefs(profile_prefs, | 158 proxy_config_service_.SetPrefs(profile_prefs, |
158 g_browser_process->local_state()); | 159 g_browser_process->local_state()); |
159 } | 160 } |
160 | 161 |
161 void CoreChromeOSOptionsHandler::Observe( | 162 void CoreChromeOSOptionsHandler::Observe( |
162 int type, | 163 int type, |
163 const content::NotificationSource& source, | 164 const content::NotificationSource& source, |
164 const content::NotificationDetails& details) { | 165 const content::NotificationDetails& details) { |
165 DCHECK_EQ(chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, type); | 166 DCHECK_EQ(chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, type); |
166 | 167 |
(...skipping 13 matching lines...) Expand all Loading... |
180 const std::string& pref_name) { | 181 const std::string& pref_name) { |
181 if (proxy_cros_settings_parser::IsProxyPref(pref_name)) { | 182 if (proxy_cros_settings_parser::IsProxyPref(pref_name)) { |
182 base::Value* value = nullptr; | 183 base::Value* value = nullptr; |
183 proxy_cros_settings_parser::GetProxyPrefValue( | 184 proxy_cros_settings_parser::GetProxyPrefValue( |
184 proxy_config_service_, pref_name, &value); | 185 proxy_config_service_, pref_name, &value); |
185 return value ? value : base::Value::CreateNullValue().release(); | 186 return value ? value : base::Value::CreateNullValue().release(); |
186 } | 187 } |
187 | 188 |
188 Profile* profile = Profile::FromWebUI(web_ui()); | 189 Profile* profile = Profile::FromWebUI(web_ui()); |
189 if (!CrosSettings::IsCrosSettings(pref_name)) { | 190 if (!CrosSettings::IsCrosSettings(pref_name)) { |
190 std::string controlling_pref = pref_name == prefs::kUseSharedProxies | 191 std::string controlling_pref = |
191 ? proxy_config::prefs::kProxy | 192 pref_name == proxy_config::prefs::kUseSharedProxies |
192 : std::string(); | 193 ? proxy_config::prefs::kProxy |
| 194 : std::string(); |
193 base::Value* value = CreateValueForPref(pref_name, controlling_pref); | 195 base::Value* value = CreateValueForPref(pref_name, controlling_pref); |
194 if (!IsSettingShared(pref_name) || !IsSecondaryUser(profile)) | 196 if (!IsSettingShared(pref_name) || !IsSecondaryUser(profile)) |
195 return value; | 197 return value; |
196 base::DictionaryValue* dict; | 198 base::DictionaryValue* dict; |
197 if (!value->GetAsDictionary(&dict) || dict->HasKey("controlledBy")) | 199 if (!value->GetAsDictionary(&dict) || dict->HasKey("controlledBy")) |
198 return value; | 200 return value; |
199 Profile* primary_profile = ProfileHelper::Get()->GetProfileByUser( | 201 Profile* primary_profile = ProfileHelper::Get()->GetProfileByUser( |
200 user_manager::UserManager::Get()->GetPrimaryUser()); | 202 user_manager::UserManager::Get()->GetPrimaryUser()); |
201 if (!primary_profile) | 203 if (!primary_profile) |
202 return value; | 204 return value; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 } | 385 } |
384 proxy_config_service_.SetCurrentNetworkGuid(guid); | 386 proxy_config_service_.SetCurrentNetworkGuid(guid); |
385 NotifyProxyPrefsChanged(); | 387 NotifyProxyPrefsChanged(); |
386 } | 388 } |
387 | 389 |
388 void CoreChromeOSOptionsHandler::OnPreferenceChanged( | 390 void CoreChromeOSOptionsHandler::OnPreferenceChanged( |
389 PrefService* service, | 391 PrefService* service, |
390 const std::string& pref_name) { | 392 const std::string& pref_name) { |
391 // Redetermine the current proxy settings and notify the UI if any of these | 393 // Redetermine the current proxy settings and notify the UI if any of these |
392 // preferences change. | 394 // preferences change. |
393 if (pref_name == prefs::kOpenNetworkConfiguration || | 395 if (pref_name == onc::prefs::kOpenNetworkConfiguration || |
394 pref_name == prefs::kDeviceOpenNetworkConfiguration || | 396 pref_name == onc::prefs::kDeviceOpenNetworkConfiguration || |
395 pref_name == proxy_config::prefs::kProxy) { | 397 pref_name == proxy_config::prefs::kProxy) { |
396 NotifyProxyPrefsChanged(); | 398 NotifyProxyPrefsChanged(); |
397 return; | 399 return; |
398 } | 400 } |
399 if (pref_name == prefs::kUseSharedProxies) { | 401 if (pref_name == proxy_config::prefs::kUseSharedProxies) { |
400 // kProxy controls kUseSharedProxies and decides if it's managed by | 402 // kProxy controls kUseSharedProxies and decides if it's managed by |
401 // policy/extension. | 403 // policy/extension. |
402 NotifyPrefChanged(prefs::kUseSharedProxies, proxy_config::prefs::kProxy); | 404 NotifyPrefChanged(proxy_config::prefs::kUseSharedProxies, |
| 405 proxy_config::prefs::kProxy); |
403 return; | 406 return; |
404 } | 407 } |
405 ::options::CoreOptionsHandler::OnPreferenceChanged(service, pref_name); | 408 ::options::CoreOptionsHandler::OnPreferenceChanged(service, pref_name); |
406 } | 409 } |
407 | 410 |
408 void CoreChromeOSOptionsHandler::NotifySettingsChanged( | 411 void CoreChromeOSOptionsHandler::NotifySettingsChanged( |
409 const std::string& setting_name) { | 412 const std::string& setting_name) { |
410 DCHECK(CrosSettings::Get()->IsCrosSettings(setting_name)); | 413 DCHECK(CrosSettings::Get()->IsCrosSettings(setting_name)); |
411 std::unique_ptr<base::Value> value(FetchPref(setting_name)); | 414 std::unique_ptr<base::Value> value(FetchPref(setting_name)); |
412 if (!value.get()) | 415 if (!value.get()) |
413 NOTREACHED(); | 416 NOTREACHED(); |
414 DispatchPrefChangeNotification(setting_name, std::move(value)); | 417 DispatchPrefChangeNotification(setting_name, std::move(value)); |
415 } | 418 } |
416 | 419 |
417 void CoreChromeOSOptionsHandler::NotifyProxyPrefsChanged() { | 420 void CoreChromeOSOptionsHandler::NotifyProxyPrefsChanged() { |
418 proxy_config_service_.UpdateFromPrefs(); | 421 proxy_config_service_.UpdateFromPrefs(); |
419 for (size_t i = 0; i < kProxySettingsCount; ++i) { | 422 for (size_t i = 0; i < proxy_cros_settings_parser::kProxySettingsCount; ++i) { |
420 base::Value* value = NULL; | 423 base::Value* value = NULL; |
421 proxy_cros_settings_parser::GetProxyPrefValue( | 424 proxy_cros_settings_parser::GetProxyPrefValue( |
422 proxy_config_service_, kProxySettings[i], &value); | 425 proxy_config_service_, proxy_cros_settings_parser::kProxySettings[i], |
| 426 &value); |
423 DCHECK(value); | 427 DCHECK(value); |
424 std::unique_ptr<base::Value> ptr(value); | 428 std::unique_ptr<base::Value> ptr(value); |
425 DispatchPrefChangeNotification(kProxySettings[i], std::move(ptr)); | 429 DispatchPrefChangeNotification( |
| 430 proxy_cros_settings_parser::kProxySettings[i], std::move(ptr)); |
426 } | 431 } |
427 } | 432 } |
428 | 433 |
429 } // namespace options | 434 } // namespace options |
430 } // namespace chromeos | 435 } // namespace chromeos |
OLD | NEW |