OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 CHROME_UTILITY_NETWORKING_PRIVATE_HANDLER_H_ |
| 6 #define CHROME_UTILITY_NETWORKING_PRIVATE_HANDLER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "chrome/utility/utility_message_handler.h" |
| 15 #include "chrome/utility/wifi/wifi_service.h" |
| 16 |
| 17 namespace base { |
| 18 class DictionaryValue; |
| 19 class Thread; |
| 20 } |
| 21 |
| 22 using wifi::WiFiService; |
| 23 |
| 24 namespace chrome { |
| 25 |
| 26 // Dispatches IPCs for out of process networkingPrivate API calls. |
| 27 class NetworkingPrivateHandler : public UtilityMessageHandler { |
| 28 public: |
| 29 NetworkingPrivateHandler(); |
| 30 virtual ~NetworkingPrivateHandler(); |
| 31 |
| 32 // IPC::Listener: |
| 33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 34 // Send IPC message from UtilityThread. |
| 35 static bool Send(IPC::Message* message); |
| 36 |
| 37 private: |
| 38 // IPC Message Handlers. |
| 39 |
| 40 // Use WiFiServiceMock with |parameters| for unit testing. |
| 41 void OnSetUpForTest(const base::DictionaryValue& parameters); |
| 42 |
| 43 // Common callback from WiFiService when error with |error_name| occurs. |
| 44 // Sends |NetworkingPrivateMsg_API_Error| back to browser process. |
| 45 // |message_id| is used to by NetworkingPrivateProcessClient to find matching |
| 46 // request. |
| 47 void WiFiApiError(int message_id, |
| 48 const std::string& error_name, |
| 49 scoped_ptr<base::DictionaryValue> error_data); |
| 50 |
| 51 // Get properties of network identified by |network_guid|. |
| 52 void OnGetPropertiesStart(int message_id, const std::string& network_guid); |
| 53 |
| 54 // Callback from |WiFiService| to send |properties| back to browser process. |
| 55 void WiFiGetPropertiesSucceeded( |
| 56 int message_id, |
| 57 const std::string& network_guid, |
| 58 const WiFiService::NetworkProperties& properties); |
| 59 |
| 60 // Set properties of network identified by |network_guid|. |
| 61 void OnSetPropertiesStart(int message_id, |
| 62 const std::string& network_guid, |
| 63 const base::DictionaryValue& properties); |
| 64 |
| 65 // Callback from |WiFiService| to report set properties success back to |
| 66 // browser process. |
| 67 void WiFiSetPropertiesSucceeded(int message_id, |
| 68 const std::string& network_guid); |
| 69 |
| 70 // Start connect to network identified by |network_guid|. Does not wait for |
| 71 // connect to succeed. If another network is connected, it will be remembered |
| 72 // and disconnected prior to connect. |
| 73 void OnStartConnectStart(int message_id, const std::string& network_guid); |
| 74 |
| 75 // Callback from |WiFiService| to report start connect success back to |
| 76 // browser process. Does not wait for connect to actually succeed. If/When |
| 77 // connect succeeds the |NetworksChanged| event will be generated. |
| 78 void WiFiStartConnectSucceeded(int message_id, |
| 79 const std::string& network_guid); |
| 80 |
| 81 // Start disconnect from network identified by |network_guid|. Does not wait |
| 82 // for disconnect to succeed. |
| 83 void OnStartDisconnectStart(int message_id, const std::string& network_guid); |
| 84 |
| 85 // Callback from |WiFiService| to report start disconnect success back to |
| 86 // browser process. Does not wait for disconnect to actually succeed. If/When |
| 87 // disconnect succeeds the |NetworksChanged| event will be generated. |
| 88 void WiFiStartDisconnectSucceeded(int message_id, |
| 89 const std::string& network_guid); |
| 90 |
| 91 // Request network scan. Does not wait for scan to complete. |
| 92 void OnRequestNetworkScan(); |
| 93 |
| 94 // Callback from |WiFiService| to report that network scan has succeded. |
| 95 // Generates |NetworkListChanged| event based on current |network_list|. |
| 96 void WiFiNetworkScanSucceeded(const WiFiService::NetworkList& network_list); |
| 97 |
| 98 // Get current list of visible networks. |
| 99 void OnGetVisibleNetworks(int message_id); |
| 100 |
| 101 // Callback from |WiFiService| to report list of visible networks. |
| 102 void WiFiGetVisibleNetworksSucceeded( |
| 103 int message_id, |
| 104 const WiFiService::NetworkList& network_list); |
| 105 |
| 106 // Send |NetworkListChanged| event with |network_guid_list|. |
| 107 void WiFiNetworkListChangedEvent( |
| 108 const WiFiService::NetworkGuidList& network_guid_list); |
| 109 |
| 110 // Send |NetworksChanged| event with |network_guid_list|. |
| 111 void WiFiNetworksChangedEvent( |
| 112 const WiFiService::NetworkGuidList& network_guid_list); |
| 113 |
| 114 // Platform-specific WiFi service. |
| 115 scoped_ptr<wifi::WiFiService> wifi_service_; |
| 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateHandler); |
| 118 }; |
| 119 |
| 120 } // namespace chrome |
| 121 |
| 122 #endif // CHROME_UTILITY_NETWORKING_PRIVATE_HANDLER_H_ |
OLD | NEW |