Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: ash/system/chromeos/network/tray_vpn.cc

Issue 351353004: chromeos: Move some network related UI in ui/chromeos/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix-build Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/chromeos/network/network_icon_animation.h"
10 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" 9 #include "ash/system/chromeos/network/network_state_list_detailed_view.h"
11 #include "ash/system/tray/system_tray.h" 10 #include "ash/system/tray/system_tray.h"
12 #include "ash/system/tray/system_tray_delegate.h" 11 #include "ash/system/tray/system_tray_delegate.h"
13 #include "ash/system/tray/tray_constants.h" 12 #include "ash/system/tray/tray_constants.h"
14 #include "ash/system/tray/tray_item_more.h" 13 #include "ash/system/tray/tray_item_more.h"
15 #include "ash/system/tray/tray_popup_label_button.h" 14 #include "ash/system/tray/tray_popup_label_button.h"
16 #include "chromeos/network/network_state.h" 15 #include "chromeos/network/network_state.h"
17 #include "chromeos/network/network_state_handler.h" 16 #include "chromeos/network/network_state_handler.h"
18 #include "grit/ash_strings.h" 17 #include "grit/ash_strings.h"
19 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
20 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/chromeos/network/network_icon_animation.h"
22 22
23 using chromeos::NetworkHandler; 23 using chromeos::NetworkHandler;
24 using chromeos::NetworkState; 24 using chromeos::NetworkState;
25 using chromeos::NetworkStateHandler; 25 using chromeos::NetworkStateHandler;
26 using chromeos::NetworkTypePattern; 26 using chromeos::NetworkTypePattern;
27 27
28 namespace ash { 28 namespace ash {
29 namespace tray { 29 namespace tray {
30 30
31 class VpnDefaultView : public TrayItemMore, 31 class VpnDefaultView : public TrayItemMore,
32 public network_icon::AnimationObserver { 32 public ui::network_icon::AnimationObserver {
33 public: 33 public:
34 VpnDefaultView(SystemTrayItem* owner, bool show_more) 34 VpnDefaultView(SystemTrayItem* owner, bool show_more)
35 : TrayItemMore(owner, show_more) { 35 : TrayItemMore(owner, show_more) {
36 Update(); 36 Update();
37 } 37 }
38 38
39 virtual ~VpnDefaultView() { 39 virtual ~VpnDefaultView() {
40 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); 40 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this);
41 } 41 }
42 42
43 static bool ShouldShow() { 43 static bool ShouldShow() {
44 // Do not show VPN line in uber tray bubble if VPN is not configured. 44 // Do not show VPN line in uber tray bubble if VPN is not configured.
45 NetworkStateHandler* handler = 45 NetworkStateHandler* handler =
46 NetworkHandler::Get()->network_state_handler(); 46 NetworkHandler::Get()->network_state_handler();
47 const NetworkState* vpn = 47 const NetworkState* vpn =
48 handler->FirstNetworkByType(NetworkTypePattern::VPN()); 48 handler->FirstNetworkByType(NetworkTypePattern::VPN());
49 return vpn != NULL; 49 return vpn != NULL;
50 } 50 }
51 51
52 void Update() { 52 void Update() {
53 gfx::ImageSkia image; 53 gfx::ImageSkia image;
54 base::string16 label; 54 base::string16 label;
55 bool animating = false; 55 bool animating = false;
56 GetNetworkStateHandlerImageAndLabel(&image, &label, &animating); 56 GetNetworkStateHandlerImageAndLabel(&image, &label, &animating);
57 if (animating) 57 if (animating)
58 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); 58 ui::network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this);
59 else 59 else
60 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); 60 ui::network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(
61 this);
61 SetImage(&image); 62 SetImage(&image);
62 SetLabel(label); 63 SetLabel(label);
63 SetAccessibleName(label); 64 SetAccessibleName(label);
64 } 65 }
65 66
66 // network_icon::AnimationObserver 67 // ui::network_icon::AnimationObserver
67 virtual void NetworkIconChanged() OVERRIDE { 68 virtual void NetworkIconChanged() OVERRIDE {
68 Update(); 69 Update();
69 } 70 }
70 71
71 private: 72 private:
72 void GetNetworkStateHandlerImageAndLabel(gfx::ImageSkia* image, 73 void GetNetworkStateHandlerImageAndLabel(gfx::ImageSkia* image,
73 base::string16* label, 74 base::string16* label,
74 bool* animating) { 75 bool* animating) {
75 NetworkStateHandler* handler = 76 NetworkStateHandler* handler =
76 NetworkHandler::Get()->network_state_handler(); 77 NetworkHandler::Get()->network_state_handler();
77 const NetworkState* vpn = 78 const NetworkState* vpn =
78 handler->FirstNetworkByType(NetworkTypePattern::VPN()); 79 handler->FirstNetworkByType(NetworkTypePattern::VPN());
79 if (!vpn || (vpn->connection_state() == shill::kStateIdle)) { 80 if (!vpn || (vpn->connection_state() == shill::kStateIdle)) {
80 *image = network_icon::GetImageForDisconnectedNetwork( 81 *image = ui::network_icon::GetImageForDisconnectedNetwork(
81 network_icon::ICON_TYPE_DEFAULT_VIEW, shill::kTypeVPN); 82 ui::network_icon::ICON_TYPE_DEFAULT_VIEW, shill::kTypeVPN);
82 if (label) { 83 if (label) {
83 *label = l10n_util::GetStringUTF16( 84 *label = l10n_util::GetStringUTF16(
84 IDS_ASH_STATUS_TRAY_VPN_DISCONNECTED); 85 IDS_ASH_STATUS_TRAY_VPN_DISCONNECTED);
85 } 86 }
86 *animating = false; 87 *animating = false;
87 return; 88 return;
88 } 89 }
89 *animating = vpn->IsConnectingState(); 90 *animating = vpn->IsConnectingState();
90 *image = network_icon::GetImageForNetwork( 91 *image = ui::network_icon::GetImageForNetwork(
91 vpn, network_icon::ICON_TYPE_DEFAULT_VIEW); 92 vpn, ui::network_icon::ICON_TYPE_DEFAULT_VIEW);
92 if (label) { 93 if (label) {
93 *label = network_icon::GetLabelForNetwork( 94 *label = ui::network_icon::GetLabelForNetwork(
94 vpn, network_icon::ICON_TYPE_DEFAULT_VIEW); 95 vpn, ui::network_icon::ICON_TYPE_DEFAULT_VIEW);
95 } 96 }
96 } 97 }
97 98
98 DISALLOW_COPY_AND_ASSIGN(VpnDefaultView); 99 DISALLOW_COPY_AND_ASSIGN(VpnDefaultView);
99 }; 100 };
100 101
101 } // namespace tray 102 } // namespace tray
102 103
103 TrayVPN::TrayVPN(SystemTray* system_tray) 104 TrayVPN::TrayVPN(SystemTray* system_tray)
104 : SystemTrayItem(system_tray), 105 : SystemTrayItem(system_tray),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 detailed_->ManagerChanged(); 168 detailed_->ManagerChanged();
168 } 169 }
169 } 170 }
170 171
171 void TrayVPN::NetworkServiceChanged(const chromeos::NetworkState* network) { 172 void TrayVPN::NetworkServiceChanged(const chromeos::NetworkState* network) {
172 if (detailed_) 173 if (detailed_)
173 detailed_->NetworkServiceChanged(network); 174 detailed_->NetworkServiceChanged(network);
174 } 175 }
175 176
176 } // namespace ash 177 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/network/tray_network_state_observer.cc ('k') | chrome/browser/chromeos/status/network_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698