| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/chromeos/network/network_icon_animation.h" | 9 #include "ash/system/chromeos/network/network_icon_animation.h" |
| 10 #include "ash/system/chromeos/network/network_list_detailed_view.h" | |
| 11 #include "ash/system/chromeos/network/network_list_detailed_view_base.h" | |
| 12 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" | 10 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" |
| 13 #include "ash/system/chromeos/network/network_state_notifier.h" | 11 #include "ash/system/chromeos/network/network_state_notifier.h" |
| 14 #include "ash/system/chromeos/network/network_tray_delegate.h" | 12 #include "ash/system/chromeos/network/network_tray_delegate.h" |
| 15 #include "ash/system/tray/system_tray.h" | 13 #include "ash/system/tray/system_tray.h" |
| 16 #include "ash/system/tray/system_tray_delegate.h" | 14 #include "ash/system/tray/system_tray_delegate.h" |
| 17 #include "ash/system/tray/system_tray_notifier.h" | 15 #include "ash/system/tray/system_tray_notifier.h" |
| 18 #include "ash/system/tray/tray_constants.h" | 16 #include "ash/system/tray/tray_constants.h" |
| 19 #include "ash/system/tray/tray_item_more.h" | 17 #include "ash/system/tray/tray_item_more.h" |
| 20 #include "ash/system/tray/tray_item_view.h" | 18 #include "ash/system/tray/tray_item_view.h" |
| 21 #include "ash/system/tray/tray_notification_view.h" | 19 #include "ash/system/tray/tray_notification_view.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 case NetworkObserver::MESSAGE_DATA_PROMO: | 53 case NetworkObserver::MESSAGE_DATA_PROMO: |
| 56 if (network_type == TrayNetwork::NETWORK_CELLULAR_LTE) | 54 if (network_type == TrayNetwork::NETWORK_CELLULAR_LTE) |
| 57 return IDR_AURA_UBER_TRAY_NOTIFICATION_LTE; | 55 return IDR_AURA_UBER_TRAY_NOTIFICATION_LTE; |
| 58 else | 56 else |
| 59 return IDR_AURA_UBER_TRAY_NOTIFICATION_3G; | 57 return IDR_AURA_UBER_TRAY_NOTIFICATION_3G; |
| 60 } | 58 } |
| 61 NOTREACHED(); | 59 NOTREACHED(); |
| 62 return 0; | 60 return 0; |
| 63 } | 61 } |
| 64 | 62 |
| 65 bool UseNewNetworkHandlers() { | |
| 66 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 67 ash::switches::kAshDisableNewNetworkStatusArea) && | |
| 68 NetworkStateHandler::IsInitialized(); | |
| 69 } | |
| 70 | |
| 71 } // namespace | 63 } // namespace |
| 72 | 64 |
| 73 namespace ash { | 65 namespace ash { |
| 74 namespace internal { | 66 namespace internal { |
| 75 | 67 |
| 76 namespace tray { | 68 namespace tray { |
| 77 | 69 |
| 78 class NetworkMessages { | 70 class NetworkMessages { |
| 79 public: | 71 public: |
| 80 struct Message { | 72 struct Message { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 109 public: | 101 public: |
| 110 explicit NetworkTrayView(TrayNetwork* network_tray) | 102 explicit NetworkTrayView(TrayNetwork* network_tray) |
| 111 : TrayItemView(network_tray), | 103 : TrayItemView(network_tray), |
| 112 network_tray_(network_tray) { | 104 network_tray_(network_tray) { |
| 113 SetLayoutManager( | 105 SetLayoutManager( |
| 114 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 106 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 115 | 107 |
| 116 image_view_ = new views::ImageView; | 108 image_view_ = new views::ImageView; |
| 117 AddChildView(image_view_); | 109 AddChildView(image_view_); |
| 118 | 110 |
| 119 NetworkIconInfo info; | 111 UpdateNetworkStateHandlerIcon(); |
| 120 if (UseNewNetworkHandlers()) { | |
| 121 UpdateNetworkStateHandlerIcon(); | |
| 122 } else { | |
| 123 Shell::GetInstance()->system_tray_delegate()-> | |
| 124 GetMostRelevantNetworkIcon(&info, false); | |
| 125 UpdateIcon(info.tray_icon_visible, info.image); | |
| 126 } | |
| 127 } | 112 } |
| 128 | 113 |
| 129 virtual ~NetworkTrayView() { | 114 virtual ~NetworkTrayView() { |
| 130 if (UseNewNetworkHandlers()) | 115 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 131 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | |
| 132 } | 116 } |
| 133 | 117 |
| 134 virtual const char* GetClassName() const OVERRIDE { | 118 virtual const char* GetClassName() const OVERRIDE { |
| 135 return "NetworkTrayView"; | 119 return "NetworkTrayView"; |
| 136 } | 120 } |
| 137 | 121 |
| 138 void Update(const NetworkIconInfo& info) { | |
| 139 if (UseNewNetworkHandlers()) | |
| 140 return; | |
| 141 UpdateIcon(info.tray_icon_visible, info.image); | |
| 142 UpdateConnectionStatus(info.name, info.connected); | |
| 143 } | |
| 144 | |
| 145 void UpdateNetworkStateHandlerIcon() { | 122 void UpdateNetworkStateHandlerIcon() { |
| 146 DCHECK(UseNewNetworkHandlers()); | |
| 147 NetworkStateHandler* handler = NetworkStateHandler::Get(); | 123 NetworkStateHandler* handler = NetworkStateHandler::Get(); |
| 148 gfx::ImageSkia image; | 124 gfx::ImageSkia image; |
| 149 base::string16 name; | 125 base::string16 name; |
| 150 bool animating = false; | 126 bool animating = false; |
| 151 network_tray_->GetNetworkStateHandlerImageAndLabel( | 127 network_tray_->GetNetworkStateHandlerImageAndLabel( |
| 152 network_icon::ICON_TYPE_TRAY, &image, &name, &animating); | 128 network_icon::ICON_TYPE_TRAY, &image, &name, &animating); |
| 153 bool show_in_tray = !image.isNull(); | 129 bool show_in_tray = !image.isNull(); |
| 154 UpdateIcon(show_in_tray, image); | 130 UpdateIcon(show_in_tray, image); |
| 155 if (animating) | 131 if (animating) |
| 156 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); | 132 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); |
| 157 else | 133 else |
| 158 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 134 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 159 // Update accessibility. | 135 // Update accessibility. |
| 160 const NetworkState* connected_network = handler->ConnectedNetworkByType( | 136 const NetworkState* connected_network = handler->ConnectedNetworkByType( |
| 161 NetworkStateHandler::kMatchTypeNonVirtual); | 137 NetworkStateHandler::kMatchTypeNonVirtual); |
| 162 if (connected_network) | 138 if (connected_network) |
| 163 UpdateConnectionStatus(UTF8ToUTF16(connected_network->name()), true); | 139 UpdateConnectionStatus(UTF8ToUTF16(connected_network->name()), true); |
| 164 else | 140 else |
| 165 UpdateConnectionStatus(base::string16(), false); | 141 UpdateConnectionStatus(base::string16(), false); |
| 166 } | 142 } |
| 167 | 143 |
| 168 // views::View override. | 144 // views::View override. |
| 169 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE { | 145 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE { |
| 170 state->name = connection_status_string_; | 146 state->name = connection_status_string_; |
| 171 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | 147 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; |
| 172 } | 148 } |
| 173 | 149 |
| 174 // network_icon::AnimationObserver | 150 // network_icon::AnimationObserver |
| 175 virtual void NetworkIconChanged() OVERRIDE { | 151 virtual void NetworkIconChanged() OVERRIDE { |
| 176 if (UseNewNetworkHandlers()) | 152 UpdateNetworkStateHandlerIcon(); |
| 177 UpdateNetworkStateHandlerIcon(); | |
| 178 } | 153 } |
| 179 | 154 |
| 180 private: | 155 private: |
| 181 // Updates connection status and notifies accessibility event when necessary. | 156 // Updates connection status and notifies accessibility event when necessary. |
| 182 void UpdateConnectionStatus(const base::string16& network_name, | 157 void UpdateConnectionStatus(const base::string16& network_name, |
| 183 bool connected) { | 158 bool connected) { |
| 184 base::string16 new_connection_status_string; | 159 base::string16 new_connection_status_string; |
| 185 if (connected) { | 160 if (connected) { |
| 186 new_connection_status_string = l10n_util::GetStringFUTF16( | 161 new_connection_status_string = l10n_util::GetStringFUTF16( |
| 187 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTED, network_name); | 162 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTED, network_name); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 209 class NetworkDefaultView : public TrayItemMore, | 184 class NetworkDefaultView : public TrayItemMore, |
| 210 public network_icon::AnimationObserver { | 185 public network_icon::AnimationObserver { |
| 211 public: | 186 public: |
| 212 NetworkDefaultView(TrayNetwork* network_tray, bool show_more) | 187 NetworkDefaultView(TrayNetwork* network_tray, bool show_more) |
| 213 : TrayItemMore(network_tray, show_more), | 188 : TrayItemMore(network_tray, show_more), |
| 214 network_tray_(network_tray) { | 189 network_tray_(network_tray) { |
| 215 Update(); | 190 Update(); |
| 216 } | 191 } |
| 217 | 192 |
| 218 virtual ~NetworkDefaultView() { | 193 virtual ~NetworkDefaultView() { |
| 219 if (UseNewNetworkHandlers()) | 194 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 220 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | |
| 221 } | 195 } |
| 222 | 196 |
| 223 void Update() { | 197 void Update() { |
| 224 if (UseNewNetworkHandlers()) { | 198 gfx::ImageSkia image; |
| 225 gfx::ImageSkia image; | 199 base::string16 label; |
| 226 base::string16 label; | 200 bool animating = false; |
| 227 bool animating = false; | 201 network_tray_->GetNetworkStateHandlerImageAndLabel( |
| 228 network_tray_->GetNetworkStateHandlerImageAndLabel( | 202 network_icon::ICON_TYPE_DEFAULT_VIEW, &image, &label, &animating); |
| 229 network_icon::ICON_TYPE_DEFAULT_VIEW, &image, &label, &animating); | 203 if (animating) |
| 230 if (animating) | 204 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); |
| 231 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); | 205 else |
| 232 else | 206 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 233 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 207 SetImage(&image); |
| 234 SetImage(&image); | 208 SetLabel(label); |
| 235 SetLabel(label); | 209 SetAccessibleName(label); |
| 236 SetAccessibleName(label); | |
| 237 } else { | |
| 238 NetworkIconInfo info; | |
| 239 Shell::GetInstance()->system_tray_delegate()-> | |
| 240 GetMostRelevantNetworkIcon(&info, true); | |
| 241 SetImage(&info.image); | |
| 242 SetLabel(info.description); | |
| 243 SetAccessibleName(info.description); | |
| 244 } | |
| 245 } | 210 } |
| 246 | 211 |
| 247 // network_icon::AnimationObserver | 212 // network_icon::AnimationObserver |
| 248 virtual void NetworkIconChanged() OVERRIDE { | 213 virtual void NetworkIconChanged() OVERRIDE { |
| 249 Update(); | 214 Update(); |
| 250 } | 215 } |
| 251 | 216 |
| 252 private: | 217 private: |
| 253 TrayNetwork* network_tray_; | 218 TrayNetwork* network_tray_; |
| 254 | 219 |
| 255 DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView); | 220 DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView); |
| 256 }; | 221 }; |
| 257 | 222 |
| 258 class NetworkWifiDetailedView : public NetworkDetailedView { | 223 class NetworkWifiDetailedView : public NetworkDetailedView { |
| 259 public: | 224 public: |
| 260 NetworkWifiDetailedView(SystemTrayItem* owner, bool wifi_enabled) | 225 explicit NetworkWifiDetailedView(SystemTrayItem* owner) |
| 261 : NetworkDetailedView(owner) { | 226 : NetworkDetailedView(owner) { |
| 262 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 227 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| 263 kTrayPopupPaddingHorizontal, | 228 kTrayPopupPaddingHorizontal, |
| 264 10, | 229 10, |
| 265 kTrayPopupPaddingBetweenItems)); | 230 kTrayPopupPaddingBetweenItems)); |
| 266 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 231 image_view_ = new views::ImageView; |
| 267 views::ImageView* image = new views::ImageView; | 232 AddChildView(image_view_); |
| 268 const int image_id = wifi_enabled ? | |
| 269 IDR_AURA_UBER_TRAY_WIFI_ENABLED : IDR_AURA_UBER_TRAY_WIFI_DISABLED; | |
| 270 image->SetImage(bundle.GetImageNamed(image_id).ToImageSkia()); | |
| 271 AddChildView(image); | |
| 272 | 233 |
| 273 const int string_id = wifi_enabled ? | 234 label_view_ = new views::Label(); |
| 274 IDS_ASH_STATUS_TRAY_NETWORK_WIFI_ENABLED: | 235 label_view_->SetMultiLine(true); |
| 275 IDS_ASH_STATUS_TRAY_NETWORK_WIFI_DISABLED; | 236 label_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 276 views::Label* label = | 237 AddChildView(label_view_); |
| 277 new views::Label(bundle.GetLocalizedString(string_id)); | 238 |
| 278 label->SetMultiLine(true); | 239 Update(); |
| 279 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 280 AddChildView(label); | |
| 281 } | 240 } |
| 282 | 241 |
| 283 virtual ~NetworkWifiDetailedView() {} | 242 virtual ~NetworkWifiDetailedView() { |
| 243 } |
| 284 | 244 |
| 285 // Overridden from NetworkDetailedView: | 245 // Overridden from NetworkDetailedView: |
| 286 | 246 |
| 287 virtual void Init() OVERRIDE { | 247 virtual void Init() OVERRIDE { |
| 288 } | 248 } |
| 289 | 249 |
| 290 virtual NetworkDetailedView::DetailedViewType GetViewType() const OVERRIDE { | 250 virtual NetworkDetailedView::DetailedViewType GetViewType() const OVERRIDE { |
| 291 return NetworkDetailedView::WIFI_VIEW; | 251 return NetworkDetailedView::WIFI_VIEW; |
| 292 } | 252 } |
| 293 | 253 |
| 294 virtual void ManagerChanged() OVERRIDE { | 254 virtual void ManagerChanged() OVERRIDE { |
| 255 Update(); |
| 295 } | 256 } |
| 296 | 257 |
| 297 virtual void NetworkListChanged() OVERRIDE { | 258 virtual void NetworkListChanged() OVERRIDE { |
| 298 } | 259 } |
| 299 | 260 |
| 300 virtual void NetworkServiceChanged( | 261 virtual void NetworkServiceChanged( |
| 301 const chromeos::NetworkState* network) OVERRIDE { | 262 const chromeos::NetworkState* network) OVERRIDE { |
| 302 } | 263 } |
| 303 | 264 |
| 304 private: | 265 private: |
| 266 void Update() { |
| 267 bool wifi_enabled = |
| 268 NetworkStateHandler::Get()->IsTechnologyEnabled(flimflam::kTypeWifi); |
| 269 const int image_id = wifi_enabled ? |
| 270 IDR_AURA_UBER_TRAY_WIFI_ENABLED : IDR_AURA_UBER_TRAY_WIFI_DISABLED; |
| 271 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 272 image_view_->SetImage(bundle.GetImageNamed(image_id).ToImageSkia()); |
| 273 |
| 274 const int string_id = wifi_enabled ? |
| 275 IDS_ASH_STATUS_TRAY_NETWORK_WIFI_ENABLED : |
| 276 IDS_ASH_STATUS_TRAY_NETWORK_WIFI_DISABLED; |
| 277 label_view_->SetText(bundle.GetLocalizedString(string_id)); |
| 278 } |
| 279 |
| 280 views::ImageView* image_view_; |
| 281 views::Label* label_view_; |
| 282 |
| 305 DISALLOW_COPY_AND_ASSIGN(NetworkWifiDetailedView); | 283 DISALLOW_COPY_AND_ASSIGN(NetworkWifiDetailedView); |
| 306 }; | 284 }; |
| 307 | 285 |
| 308 class NetworkMessageView : public views::View, | 286 class NetworkMessageView : public views::View, |
| 309 public views::LinkListener { | 287 public views::LinkListener { |
| 310 public: | 288 public: |
| 311 NetworkMessageView(TrayNetwork* tray_network, | 289 NetworkMessageView(TrayNetwork* tray_network, |
| 312 NetworkObserver::MessageType message_type, | 290 NetworkObserver::MessageType message_type, |
| 313 const NetworkMessages::Message& network_msg) | 291 const NetworkMessages::Message& network_msg) |
| 314 : tray_network_(tray_network), | 292 : tray_network_(tray_network), |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 } // namespace tray | 392 } // namespace tray |
| 415 | 393 |
| 416 TrayNetwork::TrayNetwork(SystemTray* system_tray) | 394 TrayNetwork::TrayNetwork(SystemTray* system_tray) |
| 417 : SystemTrayItem(system_tray), | 395 : SystemTrayItem(system_tray), |
| 418 tray_(NULL), | 396 tray_(NULL), |
| 419 default_(NULL), | 397 default_(NULL), |
| 420 detailed_(NULL), | 398 detailed_(NULL), |
| 421 notification_(NULL), | 399 notification_(NULL), |
| 422 messages_(new tray::NetworkMessages()), | 400 messages_(new tray::NetworkMessages()), |
| 423 request_wifi_view_(false) { | 401 request_wifi_view_(false) { |
| 424 if (UseNewNetworkHandlers()) | 402 network_state_observer_.reset(new TrayNetworkStateObserver(this)); |
| 425 network_state_observer_.reset(new TrayNetworkStateObserver(this)); | |
| 426 if (NetworkStateHandler::IsInitialized()) | 403 if (NetworkStateHandler::IsInitialized()) |
| 427 network_state_notifier_.reset(new NetworkStateNotifier()); | 404 network_state_notifier_.reset(new NetworkStateNotifier()); |
| 428 Shell::GetInstance()->system_tray_notifier()->AddNetworkObserver(this); | 405 Shell::GetInstance()->system_tray_notifier()->AddNetworkObserver(this); |
| 429 } | 406 } |
| 430 | 407 |
| 431 TrayNetwork::~TrayNetwork() { | 408 TrayNetwork::~TrayNetwork() { |
| 432 network_state_notifier_.reset(); | 409 network_state_notifier_.reset(); |
| 433 Shell::GetInstance()->system_tray_notifier()->RemoveNetworkObserver(this); | 410 Shell::GetInstance()->system_tray_notifier()->RemoveNetworkObserver(this); |
| 434 } | 411 } |
| 435 | 412 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 446 this, status != user::LOGGED_IN_LOCKED); | 423 this, status != user::LOGGED_IN_LOCKED); |
| 447 return default_; | 424 return default_; |
| 448 } | 425 } |
| 449 | 426 |
| 450 views::View* TrayNetwork::CreateDetailedView(user::LoginStatus status) { | 427 views::View* TrayNetwork::CreateDetailedView(user::LoginStatus status) { |
| 451 CHECK(detailed_ == NULL); | 428 CHECK(detailed_ == NULL); |
| 452 // Clear any notifications when showing the detailed view. | 429 // Clear any notifications when showing the detailed view. |
| 453 messages_->messages().clear(); | 430 messages_->messages().clear(); |
| 454 HideNotificationView(); | 431 HideNotificationView(); |
| 455 if (request_wifi_view_) { | 432 if (request_wifi_view_) { |
| 456 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 433 detailed_ = new tray::NetworkWifiDetailedView(this); |
| 457 // The Wi-Fi state is not toggled yet at this point. | |
| 458 detailed_ = new tray::NetworkWifiDetailedView(this, | |
| 459 !delegate->GetWifiEnabled()); | |
| 460 request_wifi_view_ = false; | 434 request_wifi_view_ = false; |
| 461 } else { | 435 } else { |
| 462 if (UseNewNetworkHandlers()) { | 436 detailed_ = new tray::NetworkStateListDetailedView( |
| 463 detailed_ = new tray::NetworkStateListDetailedView( | 437 this, tray::NetworkStateListDetailedView::LIST_TYPE_NETWORK, status); |
| 464 this, tray::NetworkStateListDetailedView::LIST_TYPE_NETWORK, status); | |
| 465 } else { | |
| 466 detailed_ = new tray::NetworkListDetailedView( | |
| 467 this, status, IDS_ASH_STATUS_TRAY_NETWORK); | |
| 468 } | |
| 469 detailed_->Init(); | 438 detailed_->Init(); |
| 470 } | 439 } |
| 471 return detailed_; | 440 return detailed_; |
| 472 } | 441 } |
| 473 | 442 |
| 474 views::View* TrayNetwork::CreateNotificationView(user::LoginStatus status) { | 443 views::View* TrayNetwork::CreateNotificationView(user::LoginStatus status) { |
| 475 CHECK(notification_ == NULL); | 444 CHECK(notification_ == NULL); |
| 476 if (messages_->messages().empty()) | 445 if (messages_->messages().empty()) |
| 477 return NULL; // Message has already been cleared. | 446 return NULL; // Message has already been cleared. |
| 478 notification_ = new tray::NetworkNotificationView(this); | 447 notification_ = new tray::NetworkNotificationView(this); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 495 notification_ = NULL; | 464 notification_ = NULL; |
| 496 } | 465 } |
| 497 | 466 |
| 498 void TrayNetwork::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 467 void TrayNetwork::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
| 499 } | 468 } |
| 500 | 469 |
| 501 void TrayNetwork::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | 470 void TrayNetwork::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
| 502 SetTrayImageItemBorder(tray_, alignment); | 471 SetTrayImageItemBorder(tray_, alignment); |
| 503 } | 472 } |
| 504 | 473 |
| 505 void TrayNetwork::OnNetworkRefresh(const NetworkIconInfo& info) { | |
| 506 if (tray_) | |
| 507 tray_->Update(info); | |
| 508 if (default_) | |
| 509 default_->Update(); | |
| 510 if (detailed_) | |
| 511 detailed_->ManagerChanged(); | |
| 512 } | |
| 513 | |
| 514 void TrayNetwork::SetNetworkMessage(NetworkTrayDelegate* delegate, | 474 void TrayNetwork::SetNetworkMessage(NetworkTrayDelegate* delegate, |
| 515 MessageType message_type, | 475 MessageType message_type, |
| 516 NetworkType network_type, | 476 NetworkType network_type, |
| 517 const base::string16& title, | 477 const base::string16& title, |
| 518 const base::string16& message, | 478 const base::string16& message, |
| 519 const std::vector<base::string16>& links) { | 479 const std::vector<base::string16>& links) { |
| 520 messages_->messages()[message_type] = tray::NetworkMessages::Message( | 480 messages_->messages()[message_type] = tray::NetworkMessages::Message( |
| 521 delegate, network_type, title, message, links); | 481 delegate, network_type, title, message, links); |
| 522 if (!Shell::GetInstance()->system_tray_delegate()->IsOobeCompleted()) | 482 if (!Shell::GetInstance()->system_tray_delegate()->IsOobeCompleted()) |
| 523 return; | 483 return; |
| 524 if (notification_) | 484 if (notification_) |
| 525 notification_->Update(); | 485 notification_->Update(); |
| 526 else | 486 else |
| 527 ShowNotificationView(); | 487 ShowNotificationView(); |
| 528 } | 488 } |
| 529 | 489 |
| 530 void TrayNetwork::ClearNetworkMessage(MessageType message_type) { | 490 void TrayNetwork::ClearNetworkMessage(MessageType message_type) { |
| 531 messages_->messages().erase(message_type); | 491 messages_->messages().erase(message_type); |
| 532 if (messages_->messages().empty()) { | 492 if (messages_->messages().empty()) { |
| 533 HideNotificationView(); | 493 HideNotificationView(); |
| 534 return; | 494 return; |
| 535 } | 495 } |
| 536 if (notification_) | 496 if (notification_) |
| 537 notification_->Update(); | 497 notification_->Update(); |
| 538 else | 498 else |
| 539 ShowNotificationView(); | 499 ShowNotificationView(); |
| 540 } | 500 } |
| 541 | 501 |
| 542 void TrayNetwork::OnWillToggleWifi() { | 502 void TrayNetwork::RequestToggleWifi() { |
| 543 // Triggered by a user action (e.g. keyboard shortcut) | 503 // This will always be triggered by a user action (e.g. keyboard shortcut) |
| 544 if (!detailed_ || | 504 if (!detailed_ || |
| 545 detailed_->GetViewType() == tray::NetworkDetailedView::WIFI_VIEW) { | 505 detailed_->GetViewType() == tray::NetworkDetailedView::WIFI_VIEW) { |
| 546 request_wifi_view_ = true; | 506 request_wifi_view_ = true; |
| 547 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); | 507 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); |
| 548 } | 508 } |
| 509 NetworkStateHandler* handler = NetworkStateHandler::Get(); |
| 510 bool enabled = handler->IsTechnologyEnabled(flimflam::kTypeWifi); |
| 511 handler->SetTechnologyEnabled( |
| 512 flimflam::kTypeWifi, !enabled, |
| 513 chromeos::network_handler::ErrorCallback()); |
| 514 } |
| 515 |
| 516 void TrayNetwork::NetworkManagerChanged() { |
| 517 if (detailed_) |
| 518 detailed_->ManagerChanged(); |
| 549 } | 519 } |
| 550 | 520 |
| 551 void TrayNetwork::NetworkStateChanged(bool list_changed) { | 521 void TrayNetwork::NetworkStateChanged(bool list_changed) { |
| 552 if (tray_ && UseNewNetworkHandlers()) | 522 if (tray_) |
| 553 tray_->UpdateNetworkStateHandlerIcon(); | 523 tray_->UpdateNetworkStateHandlerIcon(); |
| 554 if (default_) | 524 if (default_) |
| 555 default_->Update(); | 525 default_->Update(); |
| 556 if (detailed_) { | 526 if (detailed_) { |
| 557 if (list_changed) | 527 if (list_changed) |
| 558 detailed_->NetworkListChanged(); | 528 detailed_->NetworkListChanged(); |
| 559 else | 529 else |
| 560 detailed_->ManagerChanged(); | 530 detailed_->ManagerChanged(); |
| 561 } | 531 } |
| 562 } | 532 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 | 608 |
| 639 void TrayNetwork::LinkClicked(MessageType message_type, int link_id) { | 609 void TrayNetwork::LinkClicked(MessageType message_type, int link_id) { |
| 640 tray::NetworkMessages::MessageMap::const_iterator iter = | 610 tray::NetworkMessages::MessageMap::const_iterator iter = |
| 641 messages()->messages().find(message_type); | 611 messages()->messages().find(message_type); |
| 642 if (iter != messages()->messages().end() && iter->second.delegate) | 612 if (iter != messages()->messages().end() && iter->second.delegate) |
| 643 iter->second.delegate->NotificationLinkClicked(message_type, link_id); | 613 iter->second.delegate->NotificationLinkClicked(message_type, link_id); |
| 644 } | 614 } |
| 645 | 615 |
| 646 } // namespace internal | 616 } // namespace internal |
| 647 } // namespace ash | 617 } // namespace ash |
| OLD | NEW |