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/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/system_tray_notifier.h" | 11 #include "ash/system/tray/system_tray_notifier.h" |
11 #include "ash/system/tray/tray_constants.h" | 12 #include "ash/system/tray/tray_constants.h" |
12 #include "ash/system/tray/tray_item_more.h" | 13 #include "ash/system/tray/tray_item_more.h" |
13 #include "grit/ash_strings.h" | 14 #include "grit/ash_strings.h" |
14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
15 | 16 |
16 namespace ash { | 17 namespace ash { |
17 namespace internal { | 18 namespace internal { |
18 | 19 |
19 namespace tray { | 20 namespace tray { |
20 | 21 |
21 class VpnDefaultView : public TrayItemMore { | 22 class VpnDefaultView : public TrayItemMore { |
22 public: | 23 public: |
23 VpnDefaultView(SystemTrayItem* owner, bool show_more) | 24 VpnDefaultView(SystemTrayItem* owner, bool show_more) |
24 : TrayItemMore(owner, show_more) { | 25 : TrayItemMore(owner, show_more) { |
25 Update(); | 26 Update(); |
26 } | 27 } |
27 | 28 |
28 virtual ~VpnDefaultView() {} | 29 virtual ~VpnDefaultView() {} |
29 | 30 |
| 31 static bool ShouldShow() { |
| 32 // Do not show VPN line in uber tray bubble if VPN is not configured. |
| 33 std::vector<NetworkIconInfo> list; |
| 34 Shell::GetInstance()->system_tray_delegate()->GetVirtualNetworks(&list); |
| 35 return list.size() != 0; |
| 36 } |
| 37 |
30 void Update() { | 38 void Update() { |
31 NetworkIconInfo info; | 39 NetworkIconInfo info; |
32 Shell::GetInstance()->system_tray_delegate()->GetVirtualNetworkIcon(&info); | 40 Shell::GetInstance()->system_tray_delegate()->GetVirtualNetworkIcon(&info); |
33 SetImage(&info.image); | 41 SetImage(&info.image); |
34 SetLabel(info.description); | 42 SetLabel(info.description); |
35 SetAccessibleName(info.description); | 43 SetAccessibleName(info.description); |
36 } | 44 } |
37 | 45 |
38 private: | 46 private: |
39 DISALLOW_COPY_AND_ASSIGN(VpnDefaultView); | 47 DISALLOW_COPY_AND_ASSIGN(VpnDefaultView); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 154 |
147 views::View* TrayVPN::CreateTrayView(user::LoginStatus status) { | 155 views::View* TrayVPN::CreateTrayView(user::LoginStatus status) { |
148 return NULL; | 156 return NULL; |
149 } | 157 } |
150 | 158 |
151 views::View* TrayVPN::CreateDefaultView(user::LoginStatus status) { | 159 views::View* TrayVPN::CreateDefaultView(user::LoginStatus status) { |
152 CHECK(default_ == NULL); | 160 CHECK(default_ == NULL); |
153 if (status == user::LOGGED_IN_NONE) | 161 if (status == user::LOGGED_IN_NONE) |
154 return NULL; | 162 return NULL; |
155 | 163 |
156 // Do not show VPN line in uber tray bubble if VPN is not configured. | 164 if (!tray::VpnDefaultView::ShouldShow()) |
157 std::vector<NetworkIconInfo> list; | |
158 Shell::GetInstance()->system_tray_delegate()->GetVirtualNetworks(&list); | |
159 if (list.size() == 0) | |
160 return NULL; | 165 return NULL; |
161 | 166 |
162 default_ = new tray::VpnDefaultView(this, status != user::LOGGED_IN_LOCKED); | 167 default_ = new tray::VpnDefaultView(this, status != user::LOGGED_IN_LOCKED); |
163 return default_; | 168 return default_; |
164 } | 169 } |
165 | 170 |
166 views::View* TrayVPN::CreateDetailedView(user::LoginStatus status) { | 171 views::View* TrayVPN::CreateDetailedView(user::LoginStatus status) { |
167 CHECK(detailed_ == NULL); | 172 CHECK(detailed_ == NULL); |
168 detailed_ = new tray::VpnListDetailedView( | 173 detailed_ = new tray::VpnListDetailedView( |
169 this, status, IDS_ASH_STATUS_TRAY_VPN); | 174 this, status, IDS_ASH_STATUS_TRAY_VPN); |
(...skipping 19 matching lines...) Expand all Loading... |
189 void TrayVPN::DestroyNotificationView() { | 194 void TrayVPN::DestroyNotificationView() { |
190 } | 195 } |
191 | 196 |
192 void TrayVPN::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 197 void TrayVPN::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
193 } | 198 } |
194 | 199 |
195 void TrayVPN::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | 200 void TrayVPN::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
196 } | 201 } |
197 | 202 |
198 void TrayVPN::OnNetworkRefresh(const NetworkIconInfo& info) { | 203 void TrayVPN::OnNetworkRefresh(const NetworkIconInfo& info) { |
199 if (default_) | 204 if (default_) { |
200 default_->Update(); | 205 default_->Update(); |
| 206 } else if (tray::VpnDefaultView::ShouldShow()) { |
| 207 if (system_tray()->HasSystemBubbleType( |
| 208 SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { |
| 209 // We created the default view without a VPN view, so rebuild it. |
| 210 system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
| 211 } |
| 212 } |
| 213 |
201 if (detailed_) | 214 if (detailed_) |
202 detailed_->ManagerChanged(); | 215 detailed_->ManagerChanged(); |
203 } | 216 } |
204 | 217 |
205 void TrayVPN::SetNetworkMessage(NetworkTrayDelegate* delegate, | 218 void TrayVPN::SetNetworkMessage(NetworkTrayDelegate* delegate, |
206 MessageType message_type, | 219 MessageType message_type, |
207 NetworkType network_type, | 220 NetworkType network_type, |
208 const string16& title, | 221 const string16& title, |
209 const string16& message, | 222 const string16& message, |
210 const std::vector<string16>& links) { | 223 const std::vector<string16>& links) { |
211 } | 224 } |
212 | 225 |
213 void TrayVPN::ClearNetworkMessage(MessageType message_type) { | 226 void TrayVPN::ClearNetworkMessage(MessageType message_type) { |
214 } | 227 } |
215 | 228 |
216 void TrayVPN::OnWillToggleWifi() { | 229 void TrayVPN::OnWillToggleWifi() { |
217 } | 230 } |
218 | 231 |
219 } // namespace internal | 232 } // namespace internal |
220 } // namespace ash | 233 } // namespace ash |
OLD | NEW |