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

Side by Side Diff: components/wifi_sync/wifi_credential_syncable_service_factory.cc

Issue 836303004: wifi_sync: implement ACTION_ADD in WifiCredentialSyncableService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@submit-4.2-wifi-config-delegate
Patch Set: rebase Created 5 years, 11 months 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h" 5 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h"
6 6
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
7 #include "components/keyed_service/content/browser_context_dependency_manager.h" 9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
8 #include "components/wifi_sync/wifi_credential_syncable_service.h" 10 #include "components/wifi_sync/wifi_credential_syncable_service.h"
9 11
12 #if defined(OS_CHROMEOS)
13 #include "chromeos/login/login_state.h"
14 #include "chromeos/network/network_handler.h"
15 #include "components/wifi_sync/wifi_config_delegate_chromeos.h"
16 #endif
17
10 namespace wifi_sync { 18 namespace wifi_sync {
11 19
20 namespace {
21
22 scoped_ptr<WifiConfigDelegate> BuildConfigDelegate(
23 content::BrowserContext* context) {
24 #if defined(OS_CHROMEOS)
25 const chromeos::LoginState* login_state = chromeos::LoginState::Get();
26 DCHECK(login_state->IsUserLoggedIn());
27 DCHECK(!login_state->primary_user_hash().empty());
28 // TODO(quiche): Verify that |context| is the primary user's context.
29
30 // It is safe for us to pass WifiConfigDelegateChromeOs a raw
31 // pointer to the ManagedNetworkConfigurationHandler instance,
32 // because: 1) The scoped_ptr that we return will be owned by a
33 // KeyedService, 2) KeyedServices are destroyed before the
34 // chromeos::internal::DBusServices singleton, 3) The DBusServices
35 // singleton owns the chromeos::NetworkHandler singleton, and 4) The
36 // NetworkHandler singleton owns the
37 // ManagedNetworkConfigurationHandler singleton.
stevenjb 2015/01/14 00:12:49 This comment is overly complicated. All you need t
mukesh agrawal 2015/01/20 21:13:15 Done.
38 chromeos::NetworkHandler* network_handler = chromeos::NetworkHandler::Get();
39 return make_scoped_ptr(new WifiConfigDelegateChromeOs(
40 login_state->primary_user_hash(),
41 network_handler->managed_network_configuration_handler()));
42 #else
43 NOTIMPLEMENTED();
erikwright (departed) 2015/01/13 19:21:59 Do you intend for this to CHECK on other platforms
mukesh agrawal 2015/01/20 21:13:15 True -- I don't expect this to be called at all on
44 return nullptr;
45 #endif
46 }
47
48 } // namespace
49
12 // static 50 // static
13 WifiCredentialSyncableService* 51 WifiCredentialSyncableService*
14 WifiCredentialSyncableServiceFactory::GetForBrowserContext( 52 WifiCredentialSyncableServiceFactory::GetForBrowserContext(
15 content::BrowserContext* browser_context) { 53 content::BrowserContext* browser_context) {
16 return static_cast<WifiCredentialSyncableService*>( 54 return static_cast<WifiCredentialSyncableService*>(
17 GetInstance()->GetServiceForBrowserContext(browser_context, true)); 55 GetInstance()->GetServiceForBrowserContext(browser_context, true));
18 } 56 }
19 57
20 // static 58 // static
21 WifiCredentialSyncableServiceFactory* 59 WifiCredentialSyncableServiceFactory*
22 WifiCredentialSyncableServiceFactory::GetInstance() { 60 WifiCredentialSyncableServiceFactory::GetInstance() {
23 return Singleton<WifiCredentialSyncableServiceFactory>::get(); 61 return Singleton<WifiCredentialSyncableServiceFactory>::get();
24 } 62 }
25 63
26 // Private methods. 64 // Private methods.
27 65
28 WifiCredentialSyncableServiceFactory::WifiCredentialSyncableServiceFactory() 66 WifiCredentialSyncableServiceFactory::WifiCredentialSyncableServiceFactory()
29 : BrowserContextKeyedServiceFactory( 67 : BrowserContextKeyedServiceFactory(
30 "WifiCredentialSyncableService", 68 "WifiCredentialSyncableService",
31 BrowserContextDependencyManager::GetInstance()) { 69 BrowserContextDependencyManager::GetInstance()) {
32 } 70 }
33 71
34 WifiCredentialSyncableServiceFactory::~WifiCredentialSyncableServiceFactory() { 72 WifiCredentialSyncableServiceFactory::~WifiCredentialSyncableServiceFactory() {
35 } 73 }
36 74
37 KeyedService* WifiCredentialSyncableServiceFactory::BuildServiceInstanceFor( 75 KeyedService* WifiCredentialSyncableServiceFactory::BuildServiceInstanceFor(
38 content::BrowserContext* context) const { 76 content::BrowserContext* context) const {
39 // TODO(quiche): Figure out if this behaves properly for multi-profile. 77 // TODO(quiche): Figure out if this behaves properly for multi-profile.
40 // crbug.com/430681. 78 // crbug.com/430681.
41 return new WifiCredentialSyncableService(); 79 return new WifiCredentialSyncableService(BuildConfigDelegate(context));
42 } 80 }
43 81
44 } // namespace wifi_sync 82 } // namespace wifi_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698