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

Unified 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: virtual -> override 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 side-by-side diff with in-line comments
Download patch
Index: components/wifi_sync/wifi_credential_syncable_service_factory.cc
diff --git a/components/wifi_sync/wifi_credential_syncable_service_factory.cc b/components/wifi_sync/wifi_credential_syncable_service_factory.cc
index dbc2fec526097c424271b341804ce25433fe412b..cf3b46020cc7d1c61b50313e0da097190e90d282 100644
--- a/components/wifi_sync/wifi_credential_syncable_service_factory.cc
+++ b/components/wifi_sync/wifi_credential_syncable_service_factory.cc
@@ -4,11 +4,44 @@
#include "components/wifi_sync/wifi_credential_syncable_service_factory.h"
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/wifi_sync/wifi_credential_syncable_service.h"
+#if defined(OS_CHROMEOS)
+#include "chromeos/login/login_state.h"
+#include "chromeos/network/network_handler.h"
+#include "components/wifi_sync/wifi_config_delegate_chromeos.h"
+#endif
+
namespace wifi_sync {
+namespace {
+
+scoped_ptr<WifiConfigDelegate> BuildConfigDelegate(
+ content::BrowserContext* context) {
+#if defined(OS_CHROMEOS)
+ const chromeos::LoginState* login_state = chromeos::LoginState::Get();
+ DCHECK(login_state->IsUserLoggedIn());
+ DCHECK(!login_state->primary_user_hash().empty());
+ // TODO(quiche): Verify that |context| is the primary user's context.
+
+ // Note: NetworkHandler is a singleton that is managed by
+ // ChromeBrowserMainPartsChromeos, and destroyed after all
+ // KeyedService instances are destroyed.
+ chromeos::NetworkHandler* network_handler = chromeos::NetworkHandler::Get();
+ return make_scoped_ptr(new WifiConfigDelegateChromeOs(
+ login_state->primary_user_hash(),
+ network_handler->managed_network_configuration_handler()));
+#else
+ NOTREACHED();
+ return nullptr;
+#endif
+}
+
+} // namespace
+
// static
WifiCredentialSyncableService*
WifiCredentialSyncableServiceFactory::GetForBrowserContext(
@@ -38,7 +71,7 @@ KeyedService* WifiCredentialSyncableServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
// TODO(quiche): Figure out if this behaves properly for multi-profile.
// crbug.com/430681.
- return new WifiCredentialSyncableService();
+ return new WifiCredentialSyncableService(BuildConfigDelegate(context));
}
} // namespace wifi_sync

Powered by Google App Engine
This is Rietveld 408576698