Index: components/wifi_sync/wifi_config_observer_chromeos.h |
diff --git a/components/wifi_sync/wifi_config_observer_chromeos.h b/components/wifi_sync/wifi_config_observer_chromeos.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..df36218a50b22d8b0b9e3dd0e8ba47a22e02a6eb |
--- /dev/null |
+++ b/components/wifi_sync/wifi_config_observer_chromeos.h |
@@ -0,0 +1,126 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_WIFI_SYNC_WIFI_CONFIG_OBSERVER_CHROMEOS_H_ |
+#define COMPONENTS_WIFI_SYNC_WIFI_CONFIG_OBSERVER_CHROMEOS_H_ |
+ |
+#include <map> |
+#include <set> |
+#include <string> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "chromeos/network/network_configuration_observer.h" |
+#include "chromeos/network/network_state_handler_observer.h" |
+#include "components/wifi_sync/wifi_config_observer.h" |
+#include "components/wifi_sync/wifi_credential.h" |
+ |
+namespace chromeos { |
+class ManagedNetworkConfigurationHandler; |
+class NetworkConfigurationHandler; |
+class NetworkStateHandler; |
+} |
+ |
+namespace wifi_sync { |
+ |
+class WifiCredentialSyncableService; |
+ |
+// XXX doc |
+class WifiConfigObserverChromeOs |
+ : public WifiConfigObserver, |
+ public chromeos::NetworkConfigurationObserver, // XXX check format |
+ public chromeos::NetworkStateHandlerObserver { |
+ public: |
+ // XXX doc |
+ // XXX handlers must outlive us |
+ WifiConfigObserverChromeOs( |
+ const std::string& user_hash, |
+ chromeos::ManagedNetworkConfigurationHandler* managed_net_config_handler, |
+ chromeos::NetworkConfigurationHandler* network_configuration_handler, |
+ chromeos::NetworkStateHandler* network_state_handler); |
+ ~WifiConfigObserverChromeOs() override; |
+ |
+ // WifiConfigObserver implementation. |
+ void StartSyncing( |
+ base::WeakPtr<WifiCredentialSyncableService> syncable_service) override; |
+ void StopSyncing() override; |
+ |
+ // chromeos::NetworkConfigurationObserver implementation. |
+ void OnConfigurationCreated( |
+ const std::string& service_path, |
+ const std::string& profile_path, |
+ const base::DictionaryValue& properties, |
+ NetworkConfigurationObserver::Source source) override; |
+ void OnConfigurationRemoved( |
+ const std::string& service_path, |
+ const std::string& guid, |
+ NetworkConfigurationObserver::Source source) override; |
+ void OnPropertiesSet( |
+ const std::string& service_path, |
+ const std::string& guid, |
+ const base::DictionaryValue& set_properties, |
+ NetworkConfigurationObserver::Source source) override; |
+ void OnConfigurationProfileChanged( |
+ const std::string& service_path, |
+ const std::string& profile_path, |
+ NetworkConfigurationObserver::Source source) override; |
+ |
+ // chromeos::NetworkStateHandlerObserver implementation. |
+ void NetworkConnectionStateChanged(const chromeos::NetworkState* network) |
+ override; |
+ |
+ private: |
+ // XXX |
+ void ProcessProperties( |
+ const std::string& guid, |
+ const base::DictionaryValue& service_properties, |
+ NetworkConfigurationObserver::Source source); |
+ |
+ // Updates |service_path_to_passphrase_|, using |service_properties| |
+ // to set the passphrase for |service_path|. |
+ void SavePassphraseForService( |
+ const std::string& service_path, |
+ const base::DictionaryValue& service_properties); |
+ |
+ // XXX move after next |
+ void TryToSyncNetwork(const chromeos::NetworkState* network); |
+ |
+ // The ChromeOS user-hash that should be used when querying |
+ // ManagedNetworkConfigurationHandler, about networks managed by |
+ // user-policy. |
+ const std::string user_hash_; |
+ |
+ // A reference to the ManagedNetworkConfigurationHandler |
+ // singleton. Stored here so that it can be mocked in tests. |
+ const chromeos::ManagedNetworkConfigurationHandler* const |
+ managed_network_configuration_handler_; |
+ |
+ // The object that will call our NetworkConfigurationObserver methods. |
+ chromeos::NetworkConfigurationHandler* const |
+ network_configuration_handler_; |
+ |
+ // The object that will call our NetworkStateHandlerObsever methods. |
+ chromeos::NetworkStateHandler* const network_state_handler_; |
+ |
+ // The object we use to propagate changes into Chrome Sync. |
+ base::WeakPtr<WifiCredentialSyncableService> syncable_service_; |
+ |
+ // GUIDs of the user-configured services that we are watching. When |
+ // a service in this set connects successfully, we will send a |
+ // corresponding WifiCredential to Chrome Sync. |
+ std::set<std::string> user_configured_service_guids_; |
+ |
+ // A mapping from network service GUIDs to their Wi-Fi passphrases. |
+ std::map<std::string, std::string> guid_to_passphrase_; |
+ |
+ // Credentials that are ready to be synced, once we're provided a |
+ // SyncableService. |
+ std::vector<WifiCredential> credentials_awaiting_syncable_service_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WifiConfigObserverChromeOs); |
+}; |
+ |
+} // namespace wifi_sync |
+ |
+#endif // COMPONENTS_WIFI_SYNC_WIFI_CONFIG_OBSERVER_CHROMEOS_H_ |