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

Unified Diff: chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc

Issue 8102019: redesign and reimplement proxy config service and tracker, revise proxy ui on cros (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc
===================================================================
--- chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc (revision 108608)
+++ chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc (working copy)
@@ -9,7 +9,10 @@
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "chrome/browser/chromeos/cros_settings.h"
+#include "chrome/browser/prefs/pref_set_observer.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/pref_names.h"
#include "content/browser/user_metrics.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
@@ -20,9 +23,29 @@
: handling_change_(false) {
}
+CoreChromeOSOptionsHandler::~CoreChromeOSOptionsHandler() {}
+
+void CoreChromeOSOptionsHandler::Initialize() {
+ proxy_prefs_.reset(PrefSetObserver::CreateProxyPrefSetObserver(
+ Profile::FromWebUI(web_ui_)->GetPrefs(), this));
+}
+
Value* CoreChromeOSOptionsHandler::FetchPref(const std::string& pref_name) {
- if (!CrosSettings::IsCrosSettings(pref_name))
+ if (!CrosSettings::IsCrosSettings(pref_name)) {
+ // Specially handle kUseSharedProxies because kProxy controls it to
+ // determine if it's managed by policy/extension.
+ if (pref_name == prefs::kUseSharedProxies) {
+ PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs();
+ const PrefService::Preference* pref =
+ pref_service->FindPreference(prefs::kUseSharedProxies);
+ if (!pref)
+ return Value::CreateNullValue();
+ const PrefService::Preference* controlling_pref =
+ pref_service->FindPreference(prefs::kProxy);
+ return CreateValueForPref(pref, controlling_pref);
+ }
return ::CoreOptionsHandler::FetchPref(pref_name);
+ }
Value* pref_value = NULL;
CrosSettings::Get()->Get(pref_name, &pref_value);
@@ -70,6 +93,18 @@
NotifySettingsChanged(content::Details<std::string>(details).ptr());
return;
}
+ // Special handling for preferences kUseSharedProxies and kProxy, the latter
+ // controls the former and decides if it's managed by policy/extension.
+ if (type == chrome::NOTIFICATION_PREF_CHANGED) {
+ const PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs();
+ std::string* pref_name = content::Details<std::string>(details).ptr();
+ if (content::Source<PrefService>(source).ptr() == pref_service &&
+ (proxy_prefs_->IsObserved(*pref_name) ||
+ *pref_name == prefs::kUseSharedProxies)) {
+ NotifyPrefChanged(prefs::kUseSharedProxies, prefs::kProxy);
+ return;
+ }
+ }
::CoreOptionsHandler::Observe(type, source, details);
}

Powered by Google App Engine
This is Rietveld 408576698