| OLD | NEW |
| 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/sync_wifi/wifi_credential_syncable_service_factory.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 13 #include "components/wifi_sync/wifi_config_delegate.h" | 13 #include "components/sync_wifi/wifi_config_delegate.h" |
| 14 #include "components/wifi_sync/wifi_credential_syncable_service.h" | 14 #include "components/sync_wifi/wifi_credential_syncable_service.h" |
| 15 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
| 16 | 16 |
| 17 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
| 18 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
| 19 #include "chromeos/login/login_state.h" | 19 #include "chromeos/login/login_state.h" |
| 20 #include "chromeos/network/network_handler.h" | 20 #include "chromeos/network/network_handler.h" |
| 21 #include "components/wifi_sync/wifi_config_delegate_chromeos.h" | 21 #include "components/sync_wifi/wifi_config_delegate_chromeos.h" |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace wifi_sync { | 24 namespace sync_wifi { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 #if defined(OS_CHROMEOS) | 28 #if defined(OS_CHROMEOS) |
| 29 // Returns a string identifying a ChromeOS network settings profile, | 29 // Returns a string identifying a ChromeOS network settings profile, |
| 30 // by that profile's UserHash property. This value may be communicated | 30 // by that profile's UserHash property. This value may be communicated |
| 31 // to the ChromeOS connection manager ("Shill"), but must not be | 31 // to the ChromeOS connection manager ("Shill"), but must not be |
| 32 // exposed to any untrusted code (e.g., via web APIs). | 32 // exposed to any untrusted code (e.g., via web APIs). |
| 33 std::string GetUserHash(content::BrowserContext* context, | 33 std::string GetUserHash(content::BrowserContext* context, |
| 34 bool use_login_state) { | 34 bool use_login_state) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 61 // static | 61 // static |
| 62 WifiCredentialSyncableServiceFactory* | 62 WifiCredentialSyncableServiceFactory* |
| 63 WifiCredentialSyncableServiceFactory::GetInstance() { | 63 WifiCredentialSyncableServiceFactory::GetInstance() { |
| 64 return base::Singleton<WifiCredentialSyncableServiceFactory>::get(); | 64 return base::Singleton<WifiCredentialSyncableServiceFactory>::get(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Private methods. | 67 // Private methods. |
| 68 | 68 |
| 69 WifiCredentialSyncableServiceFactory::WifiCredentialSyncableServiceFactory() | 69 WifiCredentialSyncableServiceFactory::WifiCredentialSyncableServiceFactory() |
| 70 : BrowserContextKeyedServiceFactory( | 70 : BrowserContextKeyedServiceFactory( |
| 71 "WifiCredentialSyncableService", | 71 "WifiCredentialSyncableService", |
| 72 BrowserContextDependencyManager::GetInstance()) { | 72 BrowserContextDependencyManager::GetInstance()) {} |
| 73 } | |
| 74 | 73 |
| 75 WifiCredentialSyncableServiceFactory::~WifiCredentialSyncableServiceFactory() { | 74 WifiCredentialSyncableServiceFactory::~WifiCredentialSyncableServiceFactory() {} |
| 76 } | |
| 77 | 75 |
| 78 KeyedService* WifiCredentialSyncableServiceFactory::BuildServiceInstanceFor( | 76 KeyedService* WifiCredentialSyncableServiceFactory::BuildServiceInstanceFor( |
| 79 content::BrowserContext* context) const { | 77 content::BrowserContext* context) const { |
| 80 // TODO(quiche): Figure out if this behaves properly for multi-profile. | 78 // TODO(quiche): Figure out if this behaves properly for multi-profile. |
| 81 // crbug.com/430681. | 79 // crbug.com/430681. |
| 82 #if defined(OS_CHROMEOS) | 80 #if defined(OS_CHROMEOS) |
| 83 return new WifiCredentialSyncableService( | 81 return new WifiCredentialSyncableService( |
| 84 BuildWifiConfigDelegateChromeOs(context)); | 82 BuildWifiConfigDelegateChromeOs(context)); |
| 85 #else | 83 #else |
| 86 NOTREACHED(); | 84 NOTREACHED(); |
| 87 return nullptr; | 85 return nullptr; |
| 88 #endif | 86 #endif |
| 89 } | 87 } |
| 90 | 88 |
| 91 #if defined(OS_CHROMEOS) | 89 #if defined(OS_CHROMEOS) |
| 92 std::unique_ptr<WifiConfigDelegate> | 90 std::unique_ptr<WifiConfigDelegate> |
| 93 WifiCredentialSyncableServiceFactory::BuildWifiConfigDelegateChromeOs( | 91 WifiCredentialSyncableServiceFactory::BuildWifiConfigDelegateChromeOs( |
| 94 content::BrowserContext* context) const { | 92 content::BrowserContext* context) const { |
| 95 // Note: NetworkHandler is a singleton that is managed by | 93 // Note: NetworkHandler is a singleton that is managed by |
| 96 // ChromeBrowserMainPartsChromeos, and destroyed after all | 94 // ChromeBrowserMainPartsChromeos, and destroyed after all |
| 97 // KeyedService instances are destroyed. | 95 // KeyedService instances are destroyed. |
| 98 chromeos::NetworkHandler* network_handler = chromeos::NetworkHandler::Get(); | 96 chromeos::NetworkHandler* network_handler = chromeos::NetworkHandler::Get(); |
| 99 return base::MakeUnique<WifiConfigDelegateChromeOs>( | 97 return base::MakeUnique<WifiConfigDelegateChromeOs>( |
| 100 GetUserHash(context, !ignore_login_state_for_test_), | 98 GetUserHash(context, !ignore_login_state_for_test_), |
| 101 network_handler->managed_network_configuration_handler()); | 99 network_handler->managed_network_configuration_handler()); |
| 102 } | 100 } |
| 103 #endif | 101 #endif |
| 104 | 102 |
| 105 } // namespace wifi_sync | 103 } // namespace sync_wifi |
| OLD | NEW |