| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/chromeos/network/tray_network.h" | 5 #include "ash/system/chromeos/network/tray_network.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/common/shelf/wm_shelf_util.h" | 8 #include "ash/common/shelf/wm_shelf_util.h" |
| 9 #include "ash/common/system/tray/system_tray_delegate.h" | 9 #include "ash/common/system/tray/system_tray_delegate.h" |
| 10 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
| 11 #include "ash/common/system/tray/tray_item_more.h" | 11 #include "ash/common/system/tray/tray_item_more.h" |
| 12 #include "ash/common/system/tray/tray_item_view.h" | 12 #include "ash/common/system/tray/tray_item_view.h" |
| 13 #include "ash/common/system/tray/tray_utils.h" | 13 #include "ash/common/system/tray/tray_utils.h" |
| 14 #include "ash/metrics/user_metrics_recorder.h" | 14 #include "ash/common/wm_shell.h" |
| 15 #include "ash/shelf/shelf_util.h" | 15 #include "ash/shelf/shelf_util.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" | 17 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" |
| 18 #include "ash/system/chromeos/network/tray_network_state_observer.h" | 18 #include "ash/system/chromeos/network/tray_network_state_observer.h" |
| 19 #include "ash/system/tray/system_tray.h" | 19 #include "ash/system/tray/system_tray.h" |
| 20 #include "ash/system/tray/system_tray_notifier.h" | 20 #include "ash/system/tray/system_tray_notifier.h" |
| 21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "chromeos/network/network_state.h" | 23 #include "chromeos/network/network_state.h" |
| 24 #include "chromeos/network/network_state_handler.h" | 24 #include "chromeos/network/network_state_handler.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 CHECK(default_ == NULL); | 266 CHECK(default_ == NULL); |
| 267 if (!chromeos::NetworkHandler::IsInitialized()) | 267 if (!chromeos::NetworkHandler::IsInitialized()) |
| 268 return NULL; | 268 return NULL; |
| 269 CHECK(tray_ != NULL); | 269 CHECK(tray_ != NULL); |
| 270 default_ = new tray::NetworkDefaultView(this, status != LoginStatus::LOCKED); | 270 default_ = new tray::NetworkDefaultView(this, status != LoginStatus::LOCKED); |
| 271 return default_; | 271 return default_; |
| 272 } | 272 } |
| 273 | 273 |
| 274 views::View* TrayNetwork::CreateDetailedView(LoginStatus status) { | 274 views::View* TrayNetwork::CreateDetailedView(LoginStatus status) { |
| 275 CHECK(detailed_ == NULL); | 275 CHECK(detailed_ == NULL); |
| 276 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 276 WmShell::Get()->RecordUserMetricsAction( |
| 277 ash::UMA_STATUS_AREA_DETAILED_NETWORK_VIEW); | 277 UMA_STATUS_AREA_DETAILED_NETWORK_VIEW); |
| 278 if (!chromeos::NetworkHandler::IsInitialized()) | 278 if (!chromeos::NetworkHandler::IsInitialized()) |
| 279 return NULL; | 279 return NULL; |
| 280 if (request_wifi_view_) { | 280 if (request_wifi_view_) { |
| 281 detailed_ = new tray::NetworkWifiDetailedView(this); | 281 detailed_ = new tray::NetworkWifiDetailedView(this); |
| 282 request_wifi_view_ = false; | 282 request_wifi_view_ = false; |
| 283 } else { | 283 } else { |
| 284 detailed_ = new tray::NetworkStateListDetailedView( | 284 detailed_ = new tray::NetworkStateListDetailedView( |
| 285 this, tray::NetworkStateListDetailedView::LIST_TYPE_NETWORK, status); | 285 this, tray::NetworkStateListDetailedView::LIST_TYPE_NETWORK, status); |
| 286 detailed_->Init(); | 286 detailed_->Init(); |
| 287 } | 287 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 311 | 311 |
| 312 void TrayNetwork::RequestToggleWifi() { | 312 void TrayNetwork::RequestToggleWifi() { |
| 313 // This will always be triggered by a user action (e.g. keyboard shortcut) | 313 // This will always be triggered by a user action (e.g. keyboard shortcut) |
| 314 if (!detailed_ || | 314 if (!detailed_ || |
| 315 detailed_->GetViewType() == tray::NetworkDetailedView::WIFI_VIEW) { | 315 detailed_->GetViewType() == tray::NetworkDetailedView::WIFI_VIEW) { |
| 316 request_wifi_view_ = true; | 316 request_wifi_view_ = true; |
| 317 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); | 317 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); |
| 318 } | 318 } |
| 319 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 319 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
| 320 bool enabled = handler->IsTechnologyEnabled(NetworkTypePattern::WiFi()); | 320 bool enabled = handler->IsTechnologyEnabled(NetworkTypePattern::WiFi()); |
| 321 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 321 WmShell::Get()->RecordUserMetricsAction( |
| 322 enabled ? ash::UMA_STATUS_AREA_DISABLE_WIFI | 322 enabled ? UMA_STATUS_AREA_DISABLE_WIFI : UMA_STATUS_AREA_ENABLE_WIFI); |
| 323 : ash::UMA_STATUS_AREA_ENABLE_WIFI); | |
| 324 handler->SetTechnologyEnabled(NetworkTypePattern::WiFi(), !enabled, | 323 handler->SetTechnologyEnabled(NetworkTypePattern::WiFi(), !enabled, |
| 325 chromeos::network_handler::ErrorCallback()); | 324 chromeos::network_handler::ErrorCallback()); |
| 326 } | 325 } |
| 327 | 326 |
| 328 void TrayNetwork::OnCaptivePortalDetected( | 327 void TrayNetwork::OnCaptivePortalDetected( |
| 329 const std::string& /* service_path */) { | 328 const std::string& /* service_path */) { |
| 330 NetworkStateChanged(); | 329 NetworkStateChanged(); |
| 331 } | 330 } |
| 332 | 331 |
| 333 void TrayNetwork::NetworkStateChanged() { | 332 void TrayNetwork::NetworkStateChanged() { |
| 334 if (tray_) | 333 if (tray_) |
| 335 tray_->UpdateNetworkStateHandlerIcon(); | 334 tray_->UpdateNetworkStateHandlerIcon(); |
| 336 if (default_) | 335 if (default_) |
| 337 default_->Update(); | 336 default_->Update(); |
| 338 if (detailed_) | 337 if (detailed_) |
| 339 detailed_->Update(); | 338 detailed_->Update(); |
| 340 } | 339 } |
| 341 | 340 |
| 342 } // namespace ash | 341 } // namespace ash |
| OLD | NEW |