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

Side by Side 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 unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698