OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ |
7 | 7 |
8 #include "base/containers/scoped_ptr_hash_map.h" | 8 #include "base/containers/scoped_ptr_hash_map.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" |
10 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
12 | 13 |
13 class Profile; | 14 class Profile; |
14 | 15 |
| 16 namespace base { |
| 17 class DictionaryValue; |
| 18 } |
| 19 |
15 namespace chromeos { | 20 namespace chromeos { |
16 | 21 |
17 // This class is responsible for managing the various wake-on-wifi related bits | 22 // This class is responsible for managing the various wake-on-wifi related bits |
18 // of functionality in chrome. It is responsible for communicating the user's | 23 // of functionality in chrome. It is responsible for communicating the user's |
19 // preferences to shill as well as listening for connections to the Google GCM | 24 // preferences to shill as well as listening for connections to the Google GCM |
20 // servers and sending that connection information down to shill. This class is | 25 // servers and sending that connection information down to shill. This class is |
21 // owned by ChromeBrowserMainPartsChromeos. This class is also NOT thread-safe | 26 // owned by ChromeBrowserMainPartsChromeos. This class is also NOT thread-safe |
22 // and should only be called on the UI thread. | 27 // and should only be called on the UI thread. |
23 class WakeOnWifiManager : public content::NotificationObserver { | 28 class WakeOnWifiManager : public content::NotificationObserver { |
24 public: | 29 public: |
25 enum WakeOnWifiFeature { | 30 enum WakeOnWifiFeature { |
26 WAKE_ON_NONE = 0, | 31 WAKE_ON_NONE = 0x00, |
27 WAKE_ON_PACKET = 1, | 32 WAKE_ON_PACKET = 0x01, |
28 WAKE_ON_SSID = 2, | 33 WAKE_ON_SSID = 0x02, |
29 WAKE_ON_PACKET_AND_SSID = 3, | 34 WAKE_ON_PACKET_AND_SSID = 0x03, |
30 INVALID = 4, | 35 NOT_SUPPORTED = 0x04, |
| 36 INVALID = 0x08, |
31 }; | 37 }; |
32 | 38 |
33 static WakeOnWifiManager* Get(); | 39 static WakeOnWifiManager* Get(); |
34 | 40 |
35 WakeOnWifiManager(); | 41 WakeOnWifiManager(); |
36 ~WakeOnWifiManager() override; | 42 ~WakeOnWifiManager() override; |
37 | 43 |
38 // Should be called whenever the primary user changes their preference for the | 44 // Should be called whenever the primary user changes their preference for the |
39 // wake-on-wifi features that should be enabled. | 45 // wake-on-wifi features that should be enabled. |
40 void OnPreferenceChanged(WakeOnWifiFeature feature); | 46 void OnPreferenceChanged(WakeOnWifiFeature feature); |
41 | 47 |
| 48 // Returns true if wake-on-wifi features are supported. Returns false if we |
| 49 // have not yet determined whether wake-on-wifi features are supported. |
| 50 bool WakeOnWifiSupported(); |
| 51 |
| 52 // Callback for getting the Wi-Fi device properties. |
| 53 void GetDevicePropertiesCallback(const std::string& device_path, |
| 54 const base::DictionaryValue& properties); |
| 55 |
42 // content::NotificationObserver override. | 56 // content::NotificationObserver override. |
43 void Observe(int type, | 57 void Observe(int type, |
44 const content::NotificationSource& source, | 58 const content::NotificationSource& source, |
45 const content::NotificationDetails& details) override; | 59 const content::NotificationDetails& details) override; |
46 | 60 |
47 private: | 61 private: |
48 void OnProfileAdded(Profile* profile); | 62 void OnProfileAdded(Profile* profile); |
49 void OnProfileDestroyed(Profile* profile); | 63 void OnProfileDestroyed(Profile* profile); |
50 | 64 |
51 WakeOnWifiFeature current_feature_; | 65 WakeOnWifiFeature current_feature_; |
52 | 66 |
53 class WakeOnPacketConnectionObserver; | 67 class WakeOnPacketConnectionObserver; |
54 base::ScopedPtrHashMap<Profile*, WakeOnPacketConnectionObserver> | 68 base::ScopedPtrHashMap<Profile*, WakeOnPacketConnectionObserver> |
55 connection_observers_; | 69 connection_observers_; |
56 | 70 |
57 content::NotificationRegistrar registrar_; | 71 content::NotificationRegistrar registrar_; |
58 | 72 |
| 73 base::WeakPtrFactory<WakeOnWifiManager> weak_ptr_factory_; |
| 74 |
59 DISALLOW_COPY_AND_ASSIGN(WakeOnWifiManager); | 75 DISALLOW_COPY_AND_ASSIGN(WakeOnWifiManager); |
60 }; | 76 }; |
61 | 77 |
62 } // namespace chromeos | 78 } // namespace chromeos |
63 | 79 |
64 #endif // CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ | 80 #endif // CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ |
OLD | NEW |