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

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

Issue 11415014: Stop using shell::GetInstance()->system_tray() in system tray items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modified CL to provide TrayItems and Tray*Views with parent pointers instead. Created 8 years, 1 month 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_list_detailed_view_base.h" 8 #include "ash/system/chromeos/network/network_list_detailed_view_base.h"
9 #include "ash/system/tray/system_tray.h"
9 #include "ash/system/tray/system_tray_delegate.h" 10 #include "ash/system/tray/system_tray_delegate.h"
10 #include "ash/system/tray/tray_constants.h" 11 #include "ash/system/tray/tray_constants.h"
11 #include "ash/system/tray/tray_item_more.h" 12 #include "ash/system/tray/tray_item_more.h"
12 #include "grit/ash_strings.h" 13 #include "grit/ash_strings.h"
13 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
14 15
15 namespace ash { 16 namespace ash {
16 namespace internal { 17 namespace internal {
17 18
18 namespace tray { 19 namespace tray {
19 20
20 class VpnDefaultView : public TrayItemMore { 21 class VpnDefaultView : public TrayItemMore {
21 public: 22 public:
22 VpnDefaultView(SystemTrayItem* owner, bool show_more) 23 VpnDefaultView(SystemTrayItem* tray, bool show_more)
23 : TrayItemMore(owner, show_more) { 24 : TrayItemMore(tray, show_more) {
24 Update(); 25 Update();
25 } 26 }
26 27
27 virtual ~VpnDefaultView() {} 28 virtual ~VpnDefaultView() {}
28 29
29 void Update() { 30 void Update() {
30 NetworkIconInfo info; 31 NetworkIconInfo info;
31 Shell::GetInstance()->tray_delegate()->GetVirtualNetworkIcon(&info); 32 Shell::GetInstance()->tray_delegate()->GetVirtualNetworkIcon(&info);
32 SetImage(&info.image); 33 SetImage(&info.image);
33 SetLabel(info.description); 34 SetLabel(info.description);
34 SetAccessibleName(info.description); 35 SetAccessibleName(info.description);
35 } 36 }
36 37
37 private: 38 private:
38 DISALLOW_COPY_AND_ASSIGN(VpnDefaultView); 39 DISALLOW_COPY_AND_ASSIGN(VpnDefaultView);
39 }; 40 };
40 41
41 class VpnListDetailedView : public NetworkListDetailedViewBase { 42 class VpnListDetailedView : public NetworkListDetailedViewBase {
42 public: 43 public:
43 VpnListDetailedView(user::LoginStatus login, int header_string_id) 44 VpnListDetailedView(SystemTrayItem* tray,
44 : NetworkListDetailedViewBase(login, header_string_id), 45 user::LoginStatus login,
46 int header_string_id)
47 : NetworkListDetailedViewBase(tray, login, header_string_id),
45 other_vpn_(NULL) { 48 other_vpn_(NULL) {
46 } 49 }
47 virtual ~VpnListDetailedView() { 50 virtual ~VpnListDetailedView() {
48 } 51 }
49 52
50 // Overridden from NetworkListDetailedViewBase: 53 // Overridden from NetworkListDetailedViewBase:
51 54
52 virtual void AppendHeaderButtons() OVERRIDE { 55 virtual void AppendHeaderButtons() OVERRIDE {
53 AppendInfoButtonToHeader(); 56 AppendInfoButtonToHeader();
54 } 57 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 112 }
110 113
111 private: 114 private:
112 TrayPopupLabelButton* other_vpn_; 115 TrayPopupLabelButton* other_vpn_;
113 116
114 DISALLOW_COPY_AND_ASSIGN(VpnListDetailedView); 117 DISALLOW_COPY_AND_ASSIGN(VpnListDetailedView);
115 }; 118 };
116 119
117 } // namespace tray 120 } // namespace tray
118 121
119 TrayVPN::TrayVPN() 122 TrayVPN::TrayVPN(SystemTray* system_tray)
120 : default_(NULL), 123 : SystemTrayItem(system_tray),
124 default_(NULL),
121 detailed_(NULL) { 125 detailed_(NULL) {
122 } 126 }
123 127
124 TrayVPN::~TrayVPN() { 128 TrayVPN::~TrayVPN() {
125 } 129 }
126 130
127 views::View* TrayVPN::CreateTrayView(user::LoginStatus status) { 131 views::View* TrayVPN::CreateTrayView(user::LoginStatus status) {
128 return NULL; 132 return NULL;
129 } 133 }
130 134
131 views::View* TrayVPN::CreateDefaultView(user::LoginStatus status) { 135 views::View* TrayVPN::CreateDefaultView(user::LoginStatus status) {
132 CHECK(default_ == NULL); 136 CHECK(default_ == NULL);
133 if (status == user::LOGGED_IN_NONE) 137 if (status == user::LOGGED_IN_NONE)
134 return NULL; 138 return NULL;
135 139
136 // Do not show VPN line in uber tray bubble if VPN is not configured. 140 // Do not show VPN line in uber tray bubble if VPN is not configured.
137 std::vector<NetworkIconInfo> list; 141 std::vector<NetworkIconInfo> list;
138 Shell::GetInstance()->tray_delegate()->GetVirtualNetworks(&list); 142 Shell::GetInstance()->tray_delegate()->GetVirtualNetworks(&list);
139 if (list.size() == 0) 143 if (list.size() == 0)
140 return NULL; 144 return NULL;
141 145
142 default_ = new tray::VpnDefaultView(this, status != user::LOGGED_IN_LOCKED); 146 default_ = new tray::VpnDefaultView(this, status != user::LOGGED_IN_LOCKED);
143 return default_; 147 return default_;
144 } 148 }
145 149
146 views::View* TrayVPN::CreateDetailedView(user::LoginStatus status) { 150 views::View* TrayVPN::CreateDetailedView(user::LoginStatus status) {
147 CHECK(detailed_ == NULL); 151 CHECK(detailed_ == NULL);
148 detailed_ = new tray::VpnListDetailedView(status, IDS_ASH_STATUS_TRAY_VPN); 152 detailed_ = new tray::VpnListDetailedView(
153 this, status, IDS_ASH_STATUS_TRAY_VPN);
149 detailed_->Init(); 154 detailed_->Init();
150 return detailed_; 155 return detailed_;
151 } 156 }
152 157
153 views::View* TrayVPN::CreateNotificationView(user::LoginStatus status) { 158 views::View* TrayVPN::CreateNotificationView(user::LoginStatus status) {
154 return NULL; 159 return NULL;
155 } 160 }
156 161
157 void TrayVPN::DestroyTrayView() { 162 void TrayVPN::DestroyTrayView() {
158 } 163 }
(...skipping 30 matching lines...) Expand all
189 } 194 }
190 195
191 void TrayVPN::ClearNetworkMessage(MessageType message_type) { 196 void TrayVPN::ClearNetworkMessage(MessageType message_type) {
192 } 197 }
193 198
194 void TrayVPN::OnWillToggleWifi() { 199 void TrayVPN::OnWillToggleWifi() {
195 } 200 }
196 201
197 } // namespace internal 202 } // namespace internal
198 } // namespace ash 203 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698