Index: components/wifi_sync/wifi_credential_syncable_service.h |
diff --git a/components/wifi_sync/wifi_credential_syncable_service.h b/components/wifi_sync/wifi_credential_syncable_service.h |
index fbd82f4bf1fbe1b79251302789b8ab73b0e83e53..e7825a8522ef8c0d624578f3d31cdd676fd73591 100644 |
--- a/components/wifi_sync/wifi_credential_syncable_service.h |
+++ b/components/wifi_sync/wifi_credential_syncable_service.h |
@@ -5,13 +5,17 @@ |
#ifndef COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_ |
#define COMPONENTS_WIFI_SYNC_WIFI_CREDENTIAL_SYNCABLE_SERVICE_H_ |
+#include <string> |
+ |
#include "base/macros.h" |
#include "base/memory/scoped_ptr.h" |
#include "components/keyed_service/core/keyed_service.h" |
+#include "components/wifi_sync/wifi_config_delegate.h" |
#include "sync/api/sync_change_processor.h" |
#include "sync/api/syncable_service.h" |
namespace wifi_sync { |
+class WifiCredential; |
// KeyedService that synchronizes WiFi credentials between local settings, |
// and Chrome Sync. |
@@ -19,10 +23,19 @@ namespace wifi_sync { |
// This service does not necessarily own the storage for WiFi |
// credentials. In particular, on ChromeOS, WiFi credential storage is |
// managed by the ChromeOS connection manager ("Shill"). |
+// |
+// On ChromeOS, this class should only be instantiated |
+// for the primary user profile, as that is the only profile for |
+// which a Shill profile is loaded. |
class WifiCredentialSyncableService |
: public syncer::SyncableService, public KeyedService { |
public: |
- WifiCredentialSyncableService(); |
+ // Constructs a syncable service. Changes from Chrome Sync will be |
+ // applied locally by |network_config_delegate|. Local changes will |
+ // be propagated to Chrome Sync using the |sync_processor| provided |
+ // in the call to MergeDataAndStartSyncing. |
+ explicit WifiCredentialSyncableService( |
+ scoped_ptr<WifiConfigDelegate> network_config_delegate); |
~WifiCredentialSyncableService() override; |
// syncer::SyncableService implementation. |
@@ -37,11 +50,22 @@ class WifiCredentialSyncableService |
const tracked_objects::Location& caller_location, |
const syncer::SyncChangeList& change_list) override; |
+ // Adds a WiFiCredential to Chrome Sync. |item_id| is a persistent |
+ // identifier which can be used to later remove the credential. It |
+ // is permitted to change an existing network by adding it again. It |
+ // is an error to call this method before |
+ // MergeDataAndStartSyncing(), or after StopSyncing(). |
+ bool AddToSyncedNetworks( |
+ const std::string& item_id, const WifiCredential& credential); |
+ |
private: |
// The syncer::ModelType that this SyncableService processes and |
// generates updates for. |
static const syncer::ModelType kModelType; |
+ // The object we use to change local network configuration. |
+ const scoped_ptr<WifiConfigDelegate> network_config_delegate_; |
+ |
// Our SyncChangeProcessor instance. Used to push changes into |
// Chrome Sync. |
scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; |