| 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/network/tray_network.h" | 5 #include "ash/system/network/tray_network.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 const ErrorMap& messages() const { return messages_; } | 137 const ErrorMap& messages() const { return messages_; } |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 ErrorMap messages_; | 140 ErrorMap messages_; |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 class NetworkTrayView : public TrayItemView { | 143 class NetworkTrayView : public TrayItemView { |
| 144 public: | 144 public: |
| 145 NetworkTrayView(ColorTheme size, bool tray_icon) | 145 NetworkTrayView(ColorTheme size, bool tray_icon) |
| 146 : color_theme_(size), tray_icon_(tray_icon) { | 146 : color_theme_(size), tray_icon_(tray_icon) { |
| 147 SetLayoutManager(new views::FillLayout()); | 147 SetLayoutManager( |
| 148 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 148 | 149 |
| 149 image_view_ = color_theme_ == DARK ? | 150 image_view_ = color_theme_ == DARK ? |
| 150 new FixedSizedImageView(0, kTrayPopupItemHeight) : | 151 new FixedSizedImageView(0, kTrayPopupItemHeight) : |
| 151 new views::ImageView; | 152 new views::ImageView; |
| 152 AddChildView(image_view_); | 153 AddChildView(image_view_); |
| 153 | 154 |
| 154 NetworkIconInfo info; | 155 NetworkIconInfo info; |
| 155 Shell::GetInstance()->tray_delegate()-> | 156 Shell::GetInstance()->tray_delegate()-> |
| 156 GetMostRelevantNetworkIcon(&info, false); | 157 GetMostRelevantNetworkIcon(&info, false); |
| 157 Update(info); | 158 Update(info); |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 notification_(NULL), | 714 notification_(NULL), |
| 714 errors_(new tray::NetworkErrors()) { | 715 errors_(new tray::NetworkErrors()) { |
| 715 } | 716 } |
| 716 | 717 |
| 717 TrayNetwork::~TrayNetwork() { | 718 TrayNetwork::~TrayNetwork() { |
| 718 } | 719 } |
| 719 | 720 |
| 720 views::View* TrayNetwork::CreateTrayView(user::LoginStatus status) { | 721 views::View* TrayNetwork::CreateTrayView(user::LoginStatus status) { |
| 721 CHECK(tray_ == NULL); | 722 CHECK(tray_ == NULL); |
| 722 tray_ = new tray::NetworkTrayView(tray::LIGHT, true /*tray_icon*/); | 723 tray_ = new tray::NetworkTrayView(tray::LIGHT, true /*tray_icon*/); |
| 724 UpdateAfterShelfAlignmentChange( |
| 725 ash::Shell::GetInstance()->system_tray()->shelf_alignment()); |
| 723 return tray_; | 726 return tray_; |
| 724 } | 727 } |
| 725 | 728 |
| 726 views::View* TrayNetwork::CreateDefaultView(user::LoginStatus status) { | 729 views::View* TrayNetwork::CreateDefaultView(user::LoginStatus status) { |
| 727 CHECK(default_ == NULL); | 730 CHECK(default_ == NULL); |
| 728 default_ = new tray::NetworkDefaultView(this); | 731 default_ = new tray::NetworkDefaultView(this); |
| 729 return default_; | 732 return default_; |
| 730 } | 733 } |
| 731 | 734 |
| 732 views::View* TrayNetwork::CreateDetailedView(user::LoginStatus status) { | 735 views::View* TrayNetwork::CreateDetailedView(user::LoginStatus status) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 755 detailed_ = NULL; | 758 detailed_ = NULL; |
| 756 } | 759 } |
| 757 | 760 |
| 758 void TrayNetwork::DestroyNotificationView() { | 761 void TrayNetwork::DestroyNotificationView() { |
| 759 notification_ = NULL; | 762 notification_ = NULL; |
| 760 } | 763 } |
| 761 | 764 |
| 762 void TrayNetwork::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 765 void TrayNetwork::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
| 763 } | 766 } |
| 764 | 767 |
| 768 void TrayNetwork::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
| 769 SetTrayImageItemBorder(tray_, alignment); |
| 770 } |
| 771 |
| 765 void TrayNetwork::OnNetworkRefresh(const NetworkIconInfo& info) { | 772 void TrayNetwork::OnNetworkRefresh(const NetworkIconInfo& info) { |
| 766 if (tray_) | 773 if (tray_) |
| 767 tray_->Update(info); | 774 tray_->Update(info); |
| 768 if (default_) | 775 if (default_) |
| 769 default_->Update(); | 776 default_->Update(); |
| 770 if (detailed_) | 777 if (detailed_) |
| 771 detailed_->Update(); | 778 detailed_->Update(); |
| 772 } | 779 } |
| 773 | 780 |
| 774 void TrayNetwork::SetNetworkError(NetworkTrayDelegate* delegate, | 781 void TrayNetwork::SetNetworkError(NetworkTrayDelegate* delegate, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 799 | 806 |
| 800 void TrayNetwork::LinkClicked(ErrorType error_type) { | 807 void TrayNetwork::LinkClicked(ErrorType error_type) { |
| 801 tray::NetworkErrors::ErrorMap::const_iterator iter = | 808 tray::NetworkErrors::ErrorMap::const_iterator iter = |
| 802 errors()->messages().find(error_type); | 809 errors()->messages().find(error_type); |
| 803 if (iter != errors()->messages().end() && iter->second.delegate) | 810 if (iter != errors()->messages().end() && iter->second.delegate) |
| 804 iter->second.delegate->NotificationLinkClicked(); | 811 iter->second.delegate->NotificationLinkClicked(); |
| 805 } | 812 } |
| 806 | 813 |
| 807 } // namespace internal | 814 } // namespace internal |
| 808 } // namespace ash | 815 } // namespace ash |
| OLD | NEW |