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 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" | 5 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/containers/scoped_ptr_hash_map.h" | 11 #include "base/containers/scoped_ptr_hash_map.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 18 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
19 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 19 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 20 #include "chromeos/chromeos_switches.h" |
20 #include "chromeos/login/login_state.h" | 21 #include "chromeos/login/login_state.h" |
21 #include "chromeos/network/device_state.h" | 22 #include "chromeos/network/device_state.h" |
22 #include "chromeos/network/network_device_handler.h" | 23 #include "chromeos/network/network_device_handler.h" |
23 #include "chromeos/network/network_handler.h" | 24 #include "chromeos/network/network_handler.h" |
24 #include "chromeos/network/network_state_handler.h" | 25 #include "chromeos/network/network_state_handler.h" |
25 #include "chromeos/network/network_type_pattern.h" | 26 #include "chromeos/network/network_type_pattern.h" |
26 #include "components/gcm_driver/gcm_connection_observer.h" | 27 #include "components/gcm_driver/gcm_connection_observer.h" |
27 #include "components/gcm_driver/gcm_driver.h" | 28 #include "components/gcm_driver/gcm_driver.h" |
28 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 166 |
166 WakeOnWifiManager::~WakeOnWifiManager() { | 167 WakeOnWifiManager::~WakeOnWifiManager() { |
167 DCHECK(g_wake_on_wifi_manager); | 168 DCHECK(g_wake_on_wifi_manager); |
168 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 169 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
169 g_wake_on_wifi_manager = NULL; | 170 g_wake_on_wifi_manager = NULL; |
170 } | 171 } |
171 | 172 |
172 void WakeOnWifiManager::OnPreferenceChanged( | 173 void WakeOnWifiManager::OnPreferenceChanged( |
173 WakeOnWifiManager::WakeOnWifiFeature feature) { | 174 WakeOnWifiManager::WakeOnWifiFeature feature) { |
174 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 175 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 176 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableWakeOnWifi)) |
| 177 return; |
175 if (feature == current_feature_) | 178 if (feature == current_feature_) |
176 return; | 179 return; |
177 | 180 |
178 current_feature_ = feature; | 181 current_feature_ = feature; |
179 | 182 |
180 const DeviceState* device = | 183 const DeviceState* device = |
181 NetworkHandler::Get()->network_state_handler()->GetDeviceStateByType( | 184 NetworkHandler::Get()->network_state_handler()->GetDeviceStateByType( |
182 NetworkTypePattern::WiFi()); | 185 NetworkTypePattern::WiFi()); |
183 if (!device) | 186 if (!device) |
184 return; | 187 return; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 ->WakeFromSuspendForHeartbeat( | 236 ->WakeFromSuspendForHeartbeat( |
234 IsWakeOnPacketEnabled(current_feature_)); | 237 IsWakeOnPacketEnabled(current_feature_)); |
235 } | 238 } |
236 } | 239 } |
237 | 240 |
238 void WakeOnWifiManager::OnProfileDestroyed(Profile* profile) { | 241 void WakeOnWifiManager::OnProfileDestroyed(Profile* profile) { |
239 connection_observers_.erase(profile); | 242 connection_observers_.erase(profile); |
240 } | 243 } |
241 | 244 |
242 } // namespace chromeos | 245 } // namespace chromeos |
OLD | NEW |