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/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/chromeos/network/network_list_detailed_view_base.h" | 8 #include "ash/system/chromeos/network/network_list_detailed_view_base.h" |
9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 MessageMap& messages() { return messages_; } | 73 MessageMap& messages() { return messages_; } |
74 const MessageMap& messages() const { return messages_; } | 74 const MessageMap& messages() const { return messages_; } |
75 | 75 |
76 private: | 76 private: |
77 MessageMap messages_; | 77 MessageMap messages_; |
78 }; | 78 }; |
79 | 79 |
80 class NetworkTrayView : public TrayItemView { | 80 class NetworkTrayView : public TrayItemView { |
81 public: | 81 public: |
82 NetworkTrayView(ColorTheme size, bool tray_icon) | 82 NetworkTrayView(SystemTrayItem* tray, ColorTheme size, bool tray_icon) |
83 : color_theme_(size), tray_icon_(tray_icon) { | 83 : TrayItemView(tray), color_theme_(size), tray_icon_(tray_icon) { |
84 SetLayoutManager( | 84 SetLayoutManager( |
85 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 85 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
86 | 86 |
87 image_view_ = color_theme_ == DARK ? | 87 image_view_ = color_theme_ == DARK ? |
88 new FixedSizedImageView(0, kTrayPopupItemHeight) : | 88 new FixedSizedImageView(0, kTrayPopupItemHeight) : |
89 new views::ImageView; | 89 new views::ImageView; |
90 AddChildView(image_view_); | 90 AddChildView(image_view_); |
91 | 91 |
92 NetworkIconInfo info; | 92 NetworkIconInfo info; |
93 Shell::GetInstance()->tray_delegate()-> | 93 Shell::GetInstance()->tray_delegate()-> |
(...skipping 13 matching lines...) Expand all Loading... |
107 private: | 107 private: |
108 views::ImageView* image_view_; | 108 views::ImageView* image_view_; |
109 ColorTheme color_theme_; | 109 ColorTheme color_theme_; |
110 bool tray_icon_; | 110 bool tray_icon_; |
111 | 111 |
112 DISALLOW_COPY_AND_ASSIGN(NetworkTrayView); | 112 DISALLOW_COPY_AND_ASSIGN(NetworkTrayView); |
113 }; | 113 }; |
114 | 114 |
115 class NetworkDefaultView : public TrayItemMore { | 115 class NetworkDefaultView : public TrayItemMore { |
116 public: | 116 public: |
117 NetworkDefaultView(SystemTrayItem* owner, bool show_more) | 117 NetworkDefaultView(SystemTrayItem* tray, bool show_more) |
118 : TrayItemMore(owner, show_more) { | 118 : TrayItemMore(tray, show_more) { |
119 Update(); | 119 Update(); |
120 } | 120 } |
121 | 121 |
122 virtual ~NetworkDefaultView() {} | 122 virtual ~NetworkDefaultView() {} |
123 | 123 |
124 void Update() { | 124 void Update() { |
125 NetworkIconInfo info; | 125 NetworkIconInfo info; |
126 Shell::GetInstance()->tray_delegate()-> | 126 Shell::GetInstance()->tray_delegate()-> |
127 GetMostRelevantNetworkIcon(&info, true); | 127 GetMostRelevantNetworkIcon(&info, true); |
128 SetImage(&info.image); | 128 SetImage(&info.image); |
129 SetLabel(info.description); | 129 SetLabel(info.description); |
130 SetAccessibleName(info.description); | 130 SetAccessibleName(info.description); |
131 } | 131 } |
132 | 132 |
133 private: | 133 private: |
134 DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView); | 134 DISALLOW_COPY_AND_ASSIGN(NetworkDefaultView); |
135 }; | 135 }; |
136 | 136 |
137 class NetworkListDetailedView : public NetworkListDetailedViewBase { | 137 class NetworkListDetailedView : public NetworkListDetailedViewBase { |
138 public: | 138 public: |
139 NetworkListDetailedView(user::LoginStatus login, int header_string_id) | 139 NetworkListDetailedView(SystemTrayItem* tray, |
140 : NetworkListDetailedViewBase(login, header_string_id), | 140 user::LoginStatus login, |
| 141 int header_string_id) |
| 142 : NetworkListDetailedViewBase(tray, login, header_string_id), |
141 airplane_(NULL), | 143 airplane_(NULL), |
142 button_wifi_(NULL), | 144 button_wifi_(NULL), |
143 button_mobile_(NULL), | 145 button_mobile_(NULL), |
144 view_mobile_account_(NULL), | 146 view_mobile_account_(NULL), |
145 setup_mobile_account_(NULL), | 147 setup_mobile_account_(NULL), |
146 other_wifi_(NULL), | 148 other_wifi_(NULL), |
147 turn_on_wifi_(NULL), | 149 turn_on_wifi_(NULL), |
148 other_mobile_(NULL) { | 150 other_mobile_(NULL) { |
149 } | 151 } |
150 | 152 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 views::View* setup_mobile_account_; | 356 views::View* setup_mobile_account_; |
355 TrayPopupLabelButton* other_wifi_; | 357 TrayPopupLabelButton* other_wifi_; |
356 TrayPopupLabelButton* turn_on_wifi_; | 358 TrayPopupLabelButton* turn_on_wifi_; |
357 TrayPopupLabelButton* other_mobile_; | 359 TrayPopupLabelButton* other_mobile_; |
358 | 360 |
359 DISALLOW_COPY_AND_ASSIGN(NetworkListDetailedView); | 361 DISALLOW_COPY_AND_ASSIGN(NetworkListDetailedView); |
360 }; | 362 }; |
361 | 363 |
362 class NetworkWifiDetailedView : public NetworkDetailedView { | 364 class NetworkWifiDetailedView : public NetworkDetailedView { |
363 public: | 365 public: |
364 explicit NetworkWifiDetailedView(bool wifi_enabled) { | 366 NetworkWifiDetailedView(SystemTrayItem* tray, bool wifi_enabled) |
| 367 : NetworkDetailedView(tray) { |
365 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 368 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
366 kTrayPopupPaddingHorizontal, | 369 kTrayPopupPaddingHorizontal, |
367 10, | 370 10, |
368 kTrayPopupPaddingBetweenItems)); | 371 kTrayPopupPaddingBetweenItems)); |
369 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 372 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
370 views::ImageView* image = new views::ImageView; | 373 views::ImageView* image = new views::ImageView; |
371 const int image_id = wifi_enabled ? | 374 const int image_id = wifi_enabled ? |
372 IDR_AURA_UBER_TRAY_WIFI_ENABLED : IDR_AURA_UBER_TRAY_WIFI_DISABLED; | 375 IDR_AURA_UBER_TRAY_WIFI_ENABLED : IDR_AURA_UBER_TRAY_WIFI_DISABLED; |
373 image->SetImage(bundle.GetImageNamed(image_id).ToImageSkia()); | 376 image->SetImage(bundle.GetImageNamed(image_id).ToImageSkia()); |
374 AddChildView(image); | 377 AddChildView(image); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 new NetworkMessageView(tray_network(), iter->first, iter->second); | 501 new NetworkMessageView(tray_network(), iter->first, iter->second); |
499 } | 502 } |
500 | 503 |
501 tray::NetworkMessageView* network_message_view_; | 504 tray::NetworkMessageView* network_message_view_; |
502 | 505 |
503 DISALLOW_COPY_AND_ASSIGN(NetworkNotificationView); | 506 DISALLOW_COPY_AND_ASSIGN(NetworkNotificationView); |
504 }; | 507 }; |
505 | 508 |
506 } // namespace tray | 509 } // namespace tray |
507 | 510 |
508 TrayNetwork::TrayNetwork() | 511 TrayNetwork::TrayNetwork(SystemTray* system_tray) |
509 : tray_(NULL), | 512 : SystemTrayItem(system_tray), |
| 513 tray_(NULL), |
510 default_(NULL), | 514 default_(NULL), |
511 detailed_(NULL), | 515 detailed_(NULL), |
512 notification_(NULL), | 516 notification_(NULL), |
513 messages_(new tray::NetworkMessages()), | 517 messages_(new tray::NetworkMessages()), |
514 request_wifi_view_(false) { | 518 request_wifi_view_(false) { |
515 } | 519 } |
516 | 520 |
517 TrayNetwork::~TrayNetwork() { | 521 TrayNetwork::~TrayNetwork() { |
518 } | 522 } |
519 | 523 |
520 views::View* TrayNetwork::CreateTrayView(user::LoginStatus status) { | 524 views::View* TrayNetwork::CreateTrayView(user::LoginStatus status) { |
521 CHECK(tray_ == NULL); | 525 CHECK(tray_ == NULL); |
522 tray_ = new tray::NetworkTrayView(tray::LIGHT, true /*tray_icon*/); | 526 tray_ = new tray::NetworkTrayView(this, tray::LIGHT, true /*tray_icon*/); |
523 return tray_; | 527 return tray_; |
524 } | 528 } |
525 | 529 |
526 views::View* TrayNetwork::CreateDefaultView(user::LoginStatus status) { | 530 views::View* TrayNetwork::CreateDefaultView(user::LoginStatus status) { |
527 CHECK(default_ == NULL); | 531 CHECK(default_ == NULL); |
528 default_ = | 532 default_ = |
529 new tray::NetworkDefaultView(this, status != user::LOGGED_IN_LOCKED); | 533 new tray::NetworkDefaultView(this, status != user::LOGGED_IN_LOCKED); |
530 return default_; | 534 return default_; |
531 } | 535 } |
532 | 536 |
533 views::View* TrayNetwork::CreateDetailedView(user::LoginStatus status) { | 537 views::View* TrayNetwork::CreateDetailedView(user::LoginStatus status) { |
534 CHECK(detailed_ == NULL); | 538 CHECK(detailed_ == NULL); |
535 // Clear any notifications when showing the detailed view. | 539 // Clear any notifications when showing the detailed view. |
536 messages_->messages().clear(); | 540 messages_->messages().clear(); |
537 HideNotificationView(); | 541 HideNotificationView(); |
538 if (request_wifi_view_) { | 542 if (request_wifi_view_) { |
539 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 543 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
540 // The Wi-Fi state is not toggled yet at this point. | 544 // The Wi-Fi state is not toggled yet at this point. |
541 detailed_ = new tray::NetworkWifiDetailedView(!delegate->GetWifiEnabled()); | 545 detailed_ = new tray::NetworkWifiDetailedView(this, |
| 546 !delegate->GetWifiEnabled()); |
542 request_wifi_view_ = false; | 547 request_wifi_view_ = false; |
543 } else { | 548 } else { |
544 detailed_ = new tray::NetworkListDetailedView( | 549 detailed_ = new tray::NetworkListDetailedView( |
545 status, IDS_ASH_STATUS_TRAY_NETWORK); | 550 this, status, IDS_ASH_STATUS_TRAY_NETWORK); |
546 detailed_->Init(); | 551 detailed_->Init(); |
547 } | 552 } |
548 return detailed_; | 553 return detailed_; |
549 } | 554 } |
550 | 555 |
551 views::View* TrayNetwork::CreateNotificationView(user::LoginStatus status) { | 556 views::View* TrayNetwork::CreateNotificationView(user::LoginStatus status) { |
552 CHECK(notification_ == NULL); | 557 CHECK(notification_ == NULL); |
553 if (messages_->messages().empty()) | 558 if (messages_->messages().empty()) |
554 return NULL; // Message has already been cleared. | 559 return NULL; // Message has already been cleared. |
555 notification_ = new tray::NetworkNotificationView(this); | 560 notification_ = new tray::NetworkNotificationView(this); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 | 628 |
624 void TrayNetwork::LinkClicked(MessageType message_type, int link_id) { | 629 void TrayNetwork::LinkClicked(MessageType message_type, int link_id) { |
625 tray::NetworkMessages::MessageMap::const_iterator iter = | 630 tray::NetworkMessages::MessageMap::const_iterator iter = |
626 messages()->messages().find(message_type); | 631 messages()->messages().find(message_type); |
627 if (iter != messages()->messages().end() && iter->second.delegate) | 632 if (iter != messages()->messages().end() && iter->second.delegate) |
628 iter->second.delegate->NotificationLinkClicked(link_id); | 633 iter->second.delegate->NotificationLinkClicked(link_id); |
629 } | 634 } |
630 | 635 |
631 } // namespace internal | 636 } // namespace internal |
632 } // namespace ash | 637 } // namespace ash |
OLD | NEW |