Chromium Code Reviews| 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 NetworkHandlwer with device prefs only. | |
|
emaxx
2016/11/02 18:18:05
nit: s/NetworkHandlwer/NetworkHandler/
stevenjb
2016/11/02 19:47:33
Done.
| |
| 17 InitializeNetworkPrefServices(nullptr /* profile */); | |
| 18 | |
| 19 notification_registrar_.Add(this, | |
| 20 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | |
|
emaxx
2016/11/02 18:18:05
Isn't the usage of NotificationType discouraged in
stevenjb
2016/11/02 19:47:33
I am not aware of any alternative, and we rely on
| |
| 21 content::NotificationService::AllSources()); | |
| 22 } | |
| 23 | |
| 24 NetworkPrefStateObserver::~NetworkPrefStateObserver() {} | |
| 25 | |
| 26 void NetworkPrefStateObserver::Observe( | |
| 27 int type, | |
| 28 const content::NotificationSource& source, | |
| 29 const content::NotificationDetails& details) { | |
| 30 DCHECK_EQ(chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, type); | |
| 31 Profile* profile = content::Details<Profile>(details).ptr(); | |
| 32 DCHECK(profile); | |
| 33 InitializeNetworkPrefServices(profile); | |
| 34 } | |
| 35 | |
| 36 void NetworkPrefStateObserver::InitializeNetworkPrefServices(Profile* profile) { | |
| 37 DCHECK(g_browser_process); | |
| 38 NetworkHandler::Get()->InitializePrefServices( | |
| 39 profile ? profile->GetPrefs() : nullptr, | |
| 40 g_browser_process->local_state()); | |
| 41 } | |
| 42 | |
| 43 } // namespace chromeos | |
| OLD | NEW |