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

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

Issue 23712002: Cleanup network type matching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit test in Debug. Created 7 years, 3 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/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/chromeos/network/network_icon_animation.h" 8 #include "ash/system/chromeos/network/network_icon_animation.h"
9 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" 9 #include "ash/system/chromeos/network/network_state_list_detailed_view.h"
10 #include "ash/system/tray/system_tray.h" 10 #include "ash/system/tray/system_tray.h"
11 #include "ash/system/tray/system_tray_delegate.h" 11 #include "ash/system/tray/system_tray_delegate.h"
12 #include "ash/system/tray/tray_constants.h" 12 #include "ash/system/tray/tray_constants.h"
13 #include "ash/system/tray/tray_item_more.h" 13 #include "ash/system/tray/tray_item_more.h"
14 #include "ash/system/tray/tray_popup_label_button.h" 14 #include "ash/system/tray/tray_popup_label_button.h"
15 #include "chromeos/network/network_state.h" 15 #include "chromeos/network/network_state.h"
16 #include "chromeos/network/network_state_handler.h" 16 #include "chromeos/network/network_state_handler.h"
17 #include "chromeos/network/shill_property_util.h"
17 #include "grit/ash_strings.h" 18 #include "grit/ash_strings.h"
18 #include "third_party/cros_system_api/dbus/service_constants.h" 19 #include "third_party/cros_system_api/dbus/service_constants.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
21 22
22 using chromeos::NetworkHandler; 23 using chromeos::NetworkHandler;
23 using chromeos::NetworkState; 24 using chromeos::NetworkState;
24 using chromeos::NetworkStateHandler; 25 using chromeos::NetworkStateHandler;
26 using chromeos::NetworkTypePattern;
25 27
26 namespace ash { 28 namespace ash {
27 namespace internal { 29 namespace internal {
28 30
29 namespace tray { 31 namespace tray {
30 32
31 class VpnDefaultView : public TrayItemMore, 33 class VpnDefaultView : public TrayItemMore,
32 public network_icon::AnimationObserver { 34 public network_icon::AnimationObserver {
33 public: 35 public:
34 VpnDefaultView(SystemTrayItem* owner, bool show_more) 36 VpnDefaultView(SystemTrayItem* owner, bool show_more)
35 : TrayItemMore(owner, show_more) { 37 : TrayItemMore(owner, show_more) {
36 Update(); 38 Update();
37 } 39 }
38 40
39 virtual ~VpnDefaultView() { 41 virtual ~VpnDefaultView() {
40 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); 42 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this);
41 } 43 }
42 44
43 static bool ShouldShow() { 45 static bool ShouldShow() {
44 // Do not show VPN line in uber tray bubble if VPN is not configured. 46 // Do not show VPN line in uber tray bubble if VPN is not configured.
45 NetworkStateHandler* handler = 47 NetworkStateHandler* handler =
46 NetworkHandler::Get()->network_state_handler(); 48 NetworkHandler::Get()->network_state_handler();
47 const NetworkState* vpn = handler->FirstNetworkByType(flimflam::kTypeVPN); 49 const NetworkState* vpn =
50 handler->FirstNetworkByType(NetworkTypePattern::VPN());
48 return vpn != NULL; 51 return vpn != NULL;
49 } 52 }
50 53
51 void Update() { 54 void Update() {
52 gfx::ImageSkia image; 55 gfx::ImageSkia image;
53 base::string16 label; 56 base::string16 label;
54 bool animating = false; 57 bool animating = false;
55 GetNetworkStateHandlerImageAndLabel(&image, &label, &animating); 58 GetNetworkStateHandlerImageAndLabel(&image, &label, &animating);
56 if (animating) 59 if (animating)
57 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); 60 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this);
58 else 61 else
59 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); 62 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this);
60 SetImage(&image); 63 SetImage(&image);
61 SetLabel(label); 64 SetLabel(label);
62 SetAccessibleName(label); 65 SetAccessibleName(label);
63 } 66 }
64 67
65 // network_icon::AnimationObserver 68 // network_icon::AnimationObserver
66 virtual void NetworkIconChanged() OVERRIDE { 69 virtual void NetworkIconChanged() OVERRIDE {
67 Update(); 70 Update();
68 } 71 }
69 72
70 private: 73 private:
71 void GetNetworkStateHandlerImageAndLabel(gfx::ImageSkia* image, 74 void GetNetworkStateHandlerImageAndLabel(gfx::ImageSkia* image,
72 base::string16* label, 75 base::string16* label,
73 bool* animating) { 76 bool* animating) {
74 NetworkStateHandler* handler = 77 NetworkStateHandler* handler =
75 NetworkHandler::Get()->network_state_handler(); 78 NetworkHandler::Get()->network_state_handler();
76 const NetworkState* vpn = handler->FirstNetworkByType( 79 const NetworkState* vpn =
77 flimflam::kTypeVPN); 80 handler->FirstNetworkByType(NetworkTypePattern::VPN());
78 if (!vpn || (vpn->connection_state() == flimflam::kStateIdle)) { 81 if (!vpn || (vpn->connection_state() == flimflam::kStateIdle)) {
79 *image = network_icon::GetImageForDisconnectedNetwork( 82 *image = network_icon::GetImageForDisconnectedNetwork(
80 network_icon::ICON_TYPE_DEFAULT_VIEW, flimflam::kTypeVPN); 83 network_icon::ICON_TYPE_DEFAULT_VIEW, flimflam::kTypeVPN);
81 if (label) { 84 if (label) {
82 *label = l10n_util::GetStringUTF16( 85 *label = l10n_util::GetStringUTF16(
83 IDS_ASH_STATUS_TRAY_VPN_DISCONNECTED); 86 IDS_ASH_STATUS_TRAY_VPN_DISCONNECTED);
84 } 87 }
85 *animating = false; 88 *animating = false;
86 return; 89 return;
87 } 90 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 168 }
166 } 169 }
167 170
168 void TrayVPN::NetworkServiceChanged(const chromeos::NetworkState* network) { 171 void TrayVPN::NetworkServiceChanged(const chromeos::NetworkState* network) {
169 if (detailed_) 172 if (detailed_)
170 detailed_->NetworkServiceChanged(network); 173 detailed_->NetworkServiceChanged(network);
171 } 174 }
172 175
173 } // namespace internal 176 } // namespace internal
174 } // namespace ash 177 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/network/tray_network.cc ('k') | chrome/browser/chromeos/extensions/info_private_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698