| 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/common/system/chromeos/network/tray_vpn.h" | 5 #include "ash/common/system/chromeos/network/tray_vpn.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/system/chromeos/network/network_icon.h" | 8 #include "ash/common/system/chromeos/network/network_icon.h" |
| 9 #include "ash/common/system/chromeos/network/network_icon_animation.h" | 9 #include "ash/common/system/chromeos/network/network_icon_animation.h" |
| 10 #include "ash/common/system/chromeos/network/network_icon_animation_observer.h" | 10 #include "ash/common/system/chromeos/network/network_icon_animation_observer.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 using chromeos::NetworkState; | 28 using chromeos::NetworkState; |
| 29 using chromeos::NetworkStateHandler; | 29 using chromeos::NetworkStateHandler; |
| 30 using chromeos::NetworkTypePattern; | 30 using chromeos::NetworkTypePattern; |
| 31 | 31 |
| 32 namespace ash { | 32 namespace ash { |
| 33 namespace tray { | 33 namespace tray { |
| 34 | 34 |
| 35 class VpnDefaultView : public TrayItemMore, | 35 class VpnDefaultView : public TrayItemMore, |
| 36 public network_icon::AnimationObserver { | 36 public network_icon::AnimationObserver { |
| 37 public: | 37 public: |
| 38 VpnDefaultView(SystemTrayItem* owner, bool show_more) | 38 explicit VpnDefaultView(SystemTrayItem* owner) : TrayItemMore(owner) {} |
| 39 : TrayItemMore(owner, show_more) {} | |
| 40 | 39 |
| 41 ~VpnDefaultView() override { | 40 ~VpnDefaultView() override { |
| 42 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 41 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 43 } | 42 } |
| 44 | 43 |
| 45 static bool ShouldShow() { | 44 static bool ShouldShow() { |
| 46 // Show the VPN entry in the ash tray bubble if at least one third-party VPN | 45 // Show the VPN entry in the ash tray bubble if at least one third-party VPN |
| 47 // provider is installed. | 46 // provider is installed. |
| 48 if (WmShell::Get()->vpn_list()->HaveThirdPartyVPNProviders()) | 47 if (WmShell::Get()->vpn_list()->HaveThirdPartyVPNProviders()) |
| 49 return true; | 48 return true; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 68 SetImage(image); | 67 SetImage(image); |
| 69 SetLabel(label); | 68 SetLabel(label); |
| 70 SetAccessibleName(label); | 69 SetAccessibleName(label); |
| 71 } | 70 } |
| 72 | 71 |
| 73 // network_icon::AnimationObserver | 72 // network_icon::AnimationObserver |
| 74 void NetworkIconChanged() override { Update(); } | 73 void NetworkIconChanged() override { Update(); } |
| 75 | 74 |
| 76 protected: | 75 protected: |
| 77 // TrayItemMore: | 76 // TrayItemMore: |
| 78 std::unique_ptr<TrayPopupItemStyle> CreateStyle() const override { | 77 std::unique_ptr<TrayPopupItemStyle> HandleCreateStyle() const override { |
| 79 std::unique_ptr<TrayPopupItemStyle> style = TrayItemMore::CreateStyle(); | 78 std::unique_ptr<TrayPopupItemStyle> style = |
| 79 TrayItemMore::HandleCreateStyle(); |
| 80 style->set_color_style( | 80 style->set_color_style( |
| 81 !IsVpnEnabled() | 81 !IsVpnEnabled() |
| 82 ? TrayPopupItemStyle::ColorStyle::DISABLED | 82 ? TrayPopupItemStyle::ColorStyle::DISABLED |
| 83 : IsVpnConnected() ? TrayPopupItemStyle::ColorStyle::ACTIVE | 83 : IsVpnConnected() ? TrayPopupItemStyle::ColorStyle::ACTIVE |
| 84 : TrayPopupItemStyle::ColorStyle::INACTIVE); | 84 : TrayPopupItemStyle::ColorStyle::INACTIVE); |
| 85 return style; | 85 return style; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void UpdateStyle() override { | 88 void UpdateStyle() override { |
| 89 TrayItemMore::UpdateStyle(); | 89 TrayItemMore::UpdateStyle(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (!chromeos::NetworkHandler::IsInitialized()) | 156 if (!chromeos::NetworkHandler::IsInitialized()) |
| 157 return NULL; | 157 return NULL; |
| 158 if (status == LoginStatus::NOT_LOGGED_IN) | 158 if (status == LoginStatus::NOT_LOGGED_IN) |
| 159 return NULL; | 159 return NULL; |
| 160 if (!tray::VpnDefaultView::ShouldShow()) | 160 if (!tray::VpnDefaultView::ShouldShow()) |
| 161 return NULL; | 161 return NULL; |
| 162 | 162 |
| 163 const bool is_in_secondary_login_screen = | 163 const bool is_in_secondary_login_screen = |
| 164 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 164 WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 165 | 165 |
| 166 default_ = new tray::VpnDefaultView( | 166 default_ = new tray::VpnDefaultView(this); |
| 167 this, status != LoginStatus::LOCKED && !is_in_secondary_login_screen); | 167 default_->SetEnabled(status != LoginStatus::LOCKED && |
| 168 !is_in_secondary_login_screen); |
| 168 | 169 |
| 169 return default_; | 170 return default_; |
| 170 } | 171 } |
| 171 | 172 |
| 172 views::View* TrayVPN::CreateDetailedView(LoginStatus status) { | 173 views::View* TrayVPN::CreateDetailedView(LoginStatus status) { |
| 173 CHECK(detailed_ == NULL); | 174 CHECK(detailed_ == NULL); |
| 174 if (!chromeos::NetworkHandler::IsInitialized()) | 175 if (!chromeos::NetworkHandler::IsInitialized()) |
| 175 return NULL; | 176 return NULL; |
| 176 | 177 |
| 177 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_DETAILED_VPN_VIEW); | 178 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_DETAILED_VPN_VIEW); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 196 void TrayVPN::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {} | 197 void TrayVPN::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {} |
| 197 | 198 |
| 198 void TrayVPN::NetworkStateChanged() { | 199 void TrayVPN::NetworkStateChanged() { |
| 199 if (default_) | 200 if (default_) |
| 200 default_->Update(); | 201 default_->Update(); |
| 201 if (detailed_) | 202 if (detailed_) |
| 202 detailed_->Update(); | 203 detailed_->Update(); |
| 203 } | 204 } |
| 204 | 205 |
| 205 } // namespace ash | 206 } // namespace ash |
| OLD | NEW |