OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_WIFI_SYNC_WIFI_CONFIG_OBSERVER_CHROMEOS_H_ |
| 6 #define COMPONENTS_WIFI_SYNC_WIFI_CONFIG_OBSERVER_CHROMEOS_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "chromeos/network/network_configuration_observer.h" |
| 15 #include "chromeos/network/network_state_handler_observer.h" |
| 16 #include "components/wifi_sync/wifi_config_observer.h" |
| 17 #include "components/wifi_sync/wifi_credential.h" |
| 18 |
| 19 namespace chromeos { |
| 20 class ManagedNetworkConfigurationHandler; |
| 21 class NetworkConfigurationHandler; |
| 22 class NetworkStateHandler; |
| 23 } |
| 24 |
| 25 namespace wifi_sync { |
| 26 |
| 27 class WifiCredentialSyncableService; |
| 28 |
| 29 // XXX doc |
| 30 class WifiConfigObserverChromeOs |
| 31 : public WifiConfigObserver, |
| 32 public chromeos::NetworkConfigurationObserver, // XXX check format |
| 33 public chromeos::NetworkStateHandlerObserver { |
| 34 public: |
| 35 // XXX doc |
| 36 // XXX handlers must outlive us |
| 37 WifiConfigObserverChromeOs( |
| 38 const std::string& user_hash, |
| 39 chromeos::ManagedNetworkConfigurationHandler* managed_net_config_handler, |
| 40 chromeos::NetworkConfigurationHandler* network_configuration_handler, |
| 41 chromeos::NetworkStateHandler* network_state_handler); |
| 42 ~WifiConfigObserverChromeOs() override; |
| 43 |
| 44 // WifiConfigObserver implementation. |
| 45 void StartSyncing( |
| 46 base::WeakPtr<WifiCredentialSyncableService> syncable_service) override; |
| 47 void StopSyncing() override; |
| 48 |
| 49 // chromeos::NetworkConfigurationObserver implementation. |
| 50 void OnConfigurationCreated( |
| 51 const std::string& service_path, |
| 52 const std::string& profile_path, |
| 53 const base::DictionaryValue& properties, |
| 54 NetworkConfigurationObserver::Source source) override; |
| 55 void OnConfigurationRemoved( |
| 56 const std::string& service_path, |
| 57 const std::string& guid, |
| 58 NetworkConfigurationObserver::Source source) override; |
| 59 void OnPropertiesSet( |
| 60 const std::string& service_path, |
| 61 const std::string& guid, |
| 62 const base::DictionaryValue& set_properties, |
| 63 NetworkConfigurationObserver::Source source) override; |
| 64 void OnConfigurationProfileChanged( |
| 65 const std::string& service_path, |
| 66 const std::string& profile_path, |
| 67 NetworkConfigurationObserver::Source source) override; |
| 68 |
| 69 // chromeos::NetworkStateHandlerObserver implementation. |
| 70 void NetworkConnectionStateChanged(const chromeos::NetworkState* network) |
| 71 override; |
| 72 |
| 73 private: |
| 74 // XXX |
| 75 void ProcessProperties( |
| 76 const std::string& guid, |
| 77 const base::DictionaryValue& service_properties, |
| 78 NetworkConfigurationObserver::Source source); |
| 79 |
| 80 // Updates |service_path_to_passphrase_|, using |service_properties| |
| 81 // to set the passphrase for |service_path|. |
| 82 void SavePassphraseForService( |
| 83 const std::string& service_path, |
| 84 const base::DictionaryValue& service_properties); |
| 85 |
| 86 // XXX move after next |
| 87 void TryToSyncNetwork(const chromeos::NetworkState* network); |
| 88 |
| 89 // The ChromeOS user-hash that should be used when querying |
| 90 // ManagedNetworkConfigurationHandler, about networks managed by |
| 91 // user-policy. |
| 92 const std::string user_hash_; |
| 93 |
| 94 // A reference to the ManagedNetworkConfigurationHandler |
| 95 // singleton. Stored here so that it can be mocked in tests. |
| 96 const chromeos::ManagedNetworkConfigurationHandler* const |
| 97 managed_network_configuration_handler_; |
| 98 |
| 99 // The object that will call our NetworkConfigurationObserver methods. |
| 100 chromeos::NetworkConfigurationHandler* const |
| 101 network_configuration_handler_; |
| 102 |
| 103 // The object that will call our NetworkStateHandlerObsever methods. |
| 104 chromeos::NetworkStateHandler* const network_state_handler_; |
| 105 |
| 106 // The object we use to propagate changes into Chrome Sync. |
| 107 base::WeakPtr<WifiCredentialSyncableService> syncable_service_; |
| 108 |
| 109 // GUIDs of the user-configured services that we are watching. When |
| 110 // a service in this set connects successfully, we will send a |
| 111 // corresponding WifiCredential to Chrome Sync. |
| 112 std::set<std::string> user_configured_service_guids_; |
| 113 |
| 114 // A mapping from network service GUIDs to their Wi-Fi passphrases. |
| 115 std::map<std::string, std::string> guid_to_passphrase_; |
| 116 |
| 117 // Credentials that are ready to be synced, once we're provided a |
| 118 // SyncableService. |
| 119 std::vector<WifiCredential> credentials_awaiting_syncable_service_; |
| 120 |
| 121 DISALLOW_COPY_AND_ASSIGN(WifiConfigObserverChromeOs); |
| 122 }; |
| 123 |
| 124 } // namespace wifi_sync |
| 125 |
| 126 #endif // COMPONENTS_WIFI_SYNC_WIFI_CONFIG_OBSERVER_CHROMEOS_H_ |
OLD | NEW |