| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/net/network_pref_state_observer.h" |
| 6 |
| 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chromeos/network/network_handler.h" |
| 11 #include "content/public/browser/notification_service.h" |
| 12 |
| 13 namespace chromeos { |
| 14 |
| 15 NetworkPrefStateObserver::NetworkPrefStateObserver() { |
| 16 // Initialize NetworkHandler with device prefs only. |
| 17 InitializeNetworkPrefServices(nullptr /* profile */); |
| 18 |
| 19 notification_registrar_.Add(this, |
| 20 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 21 content::NotificationService::AllSources()); |
| 22 } |
| 23 |
| 24 NetworkPrefStateObserver::~NetworkPrefStateObserver() { |
| 25 NetworkHandler::Get()->ShutdownPrefServices(); |
| 26 } |
| 27 |
| 28 void NetworkPrefStateObserver::Observe( |
| 29 int type, |
| 30 const content::NotificationSource& source, |
| 31 const content::NotificationDetails& details) { |
| 32 DCHECK_EQ(chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, type); |
| 33 Profile* profile = content::Details<Profile>(details).ptr(); |
| 34 DCHECK(profile); |
| 35 InitializeNetworkPrefServices(profile); |
| 36 } |
| 37 |
| 38 void NetworkPrefStateObserver::InitializeNetworkPrefServices(Profile* profile) { |
| 39 DCHECK(g_browser_process); |
| 40 NetworkHandler::Get()->InitializePrefServices( |
| 41 profile ? profile->GetPrefs() : nullptr, |
| 42 g_browser_process->local_state()); |
| 43 } |
| 44 |
| 45 } // namespace chromeos |
| OLD | NEW |