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

Unified Diff: chrome/browser/chromeos/net/network_pref_state_observer.cc

Issue 2446893008: NetworkHandler: Add ui_proxy_config_service (Closed)
Patch Set: Add NetworkHandler::ShutdownPrefServices Created 4 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/chromeos/net/network_pref_state_observer.cc
diff --git a/chrome/browser/chromeos/net/network_pref_state_observer.cc b/chrome/browser/chromeos/net/network_pref_state_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7796cd173e69993de4ffb5e5bf965102c5cd694d
--- /dev/null
+++ b/chrome/browser/chromeos/net/network_pref_state_observer.cc
@@ -0,0 +1,45 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/net/network_pref_state_observer.h"
+
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chromeos/network/network_handler.h"
+#include "content/public/browser/notification_service.h"
+
+namespace chromeos {
+
+NetworkPrefStateObserver::NetworkPrefStateObserver() {
+ // Initialize NetworkHandler with device prefs only.
+ InitializeNetworkPrefServices(nullptr /* profile */);
+
+ notification_registrar_.Add(this,
+ chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
+ content::NotificationService::AllSources());
+}
+
+NetworkPrefStateObserver::~NetworkPrefStateObserver() {
+ NetworkHandler::Get()->ShutdownPrefServices();
+}
+
+void NetworkPrefStateObserver::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_EQ(chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, type);
+ Profile* profile = content::Details<Profile>(details).ptr();
+ DCHECK(profile);
+ InitializeNetworkPrefServices(profile);
+}
+
+void NetworkPrefStateObserver::InitializeNetworkPrefServices(Profile* profile) {
+ DCHECK(g_browser_process);
+ NetworkHandler::Get()->InitializePrefServices(
+ profile ? profile->GetPrefs() : nullptr,
+ g_browser_process->local_state());
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698