| 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_vpn.h" | 5 #include "ash/system/chromeos/network/tray_vpn.h" |
| 6 | 6 |
| 7 #include "ash/metrics/user_metrics_recorder.h" | 7 #include "ash/metrics/user_metrics_recorder.h" |
| 8 #include "ash/session/session_state_delegate.h" | 8 #include "ash/session/session_state_delegate.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" | 10 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" |
| 11 #include "ash/system/chromeos/network/vpn_delegate.h" |
| 11 #include "ash/system/tray/system_tray.h" | 12 #include "ash/system/tray/system_tray.h" |
| 12 #include "ash/system/tray/system_tray_delegate.h" | 13 #include "ash/system/tray/system_tray_delegate.h" |
| 13 #include "ash/system/tray/tray_constants.h" | 14 #include "ash/system/tray/tray_constants.h" |
| 14 #include "ash/system/tray/tray_item_more.h" | 15 #include "ash/system/tray/tray_item_more.h" |
| 15 #include "ash/system/tray/tray_popup_label_button.h" | 16 #include "ash/system/tray/tray_popup_label_button.h" |
| 16 #include "chromeos/network/network_state.h" | 17 #include "chromeos/network/network_state.h" |
| 17 #include "chromeos/network/network_state_handler.h" | 18 #include "chromeos/network/network_state_handler.h" |
| 18 #include "grit/ash_strings.h" | 19 #include "grit/ash_strings.h" |
| 19 #include "grit/ui_chromeos_strings.h" | 20 #include "grit/ui_chromeos_strings.h" |
| 20 #include "third_party/cros_system_api/dbus/service_constants.h" | 21 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/chromeos/network/network_icon.h" | 23 #include "ui/chromeos/network/network_icon.h" |
| 23 #include "ui/chromeos/network/network_icon_animation.h" | 24 #include "ui/chromeos/network/network_icon_animation.h" |
| 25 #include "ui/chromeos/network/network_icon_animation_observer.h" |
| 24 | 26 |
| 25 using chromeos::NetworkHandler; | 27 using chromeos::NetworkHandler; |
| 26 using chromeos::NetworkState; | 28 using chromeos::NetworkState; |
| 27 using chromeos::NetworkStateHandler; | 29 using chromeos::NetworkStateHandler; |
| 28 using chromeos::NetworkTypePattern; | 30 using chromeos::NetworkTypePattern; |
| 29 | 31 |
| 30 namespace ash { | 32 namespace ash { |
| 31 namespace tray { | 33 namespace tray { |
| 32 | 34 |
| 33 class VpnDefaultView : public TrayItemMore, | 35 class VpnDefaultView : public TrayItemMore, |
| 34 public ui::network_icon::AnimationObserver { | 36 public ui::network_icon::AnimationObserver { |
| 35 public: | 37 public: |
| 36 VpnDefaultView(SystemTrayItem* owner, bool show_more) | 38 VpnDefaultView(SystemTrayItem* owner, bool show_more) |
| 37 : TrayItemMore(owner, show_more) { | 39 : TrayItemMore(owner, show_more) { |
| 38 Update(); | 40 Update(); |
| 39 } | 41 } |
| 40 | 42 |
| 41 ~VpnDefaultView() override { | 43 ~VpnDefaultView() override { |
| 42 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 44 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 43 } | 45 } |
| 44 | 46 |
| 45 static bool ShouldShow() { | 47 static bool ShouldShow() { |
| 46 // Do not show VPN line in uber tray bubble if VPN is not configured. | 48 // Show the VPN entry in the ash tray bubble if at least one third-party VPN |
| 47 NetworkStateHandler* handler = | 49 // provider is installed. |
| 50 if (Shell::GetInstance() |
| 51 ->system_tray_delegate() |
| 52 ->GetVPNDelegate() |
| 53 ->HaveThirdPartyVPNProviders()) { |
| 54 return true; |
| 55 } |
| 56 |
| 57 // Also show the VPN entry if at least one VPN network is configured. |
| 58 NetworkStateHandler* const handler = |
| 48 NetworkHandler::Get()->network_state_handler(); | 59 NetworkHandler::Get()->network_state_handler(); |
| 49 const NetworkState* vpn = | 60 if (handler->FirstNetworkByType(NetworkTypePattern::VPN())) |
| 50 handler->FirstNetworkByType(NetworkTypePattern::VPN()); | 61 return true; |
| 51 return vpn != NULL; | 62 return false; |
| 52 } | 63 } |
| 53 | 64 |
| 54 void Update() { | 65 void Update() { |
| 55 gfx::ImageSkia image; | 66 gfx::ImageSkia image; |
| 56 base::string16 label; | 67 base::string16 label; |
| 57 bool animating = false; | 68 bool animating = false; |
| 58 GetNetworkStateHandlerImageAndLabel(&image, &label, &animating); | 69 GetNetworkStateHandlerImageAndLabel(&image, &label, &animating); |
| 59 if (animating) | 70 if (animating) |
| 60 ui::network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); | 71 ui::network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); |
| 61 else | 72 else |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 174 } |
| 164 | 175 |
| 165 void TrayVPN::NetworkStateChanged() { | 176 void TrayVPN::NetworkStateChanged() { |
| 166 if (default_) | 177 if (default_) |
| 167 default_->Update(); | 178 default_->Update(); |
| 168 if (detailed_) | 179 if (detailed_) |
| 169 detailed_->Update(); | 180 detailed_->Update(); |
| 170 } | 181 } |
| 171 | 182 |
| 172 } // namespace ash | 183 } // namespace ash |
| OLD | NEW |