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

Side by Side Diff: ash/system/network/vpn_list_view.cc

Issue 2843163003: Remove NetworkListDelegate (Closed)
Patch Set: Cleanup Created 3 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/network/vpn_list_view.h" 5 #include "ash/system/network/vpn_list_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/ash_view_ids.h" 11 #include "ash/ash_view_ids.h"
12 #include "ash/resources/vector_icons/vector_icons.h" 12 #include "ash/resources/vector_icons/vector_icons.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/shell_port.h" 14 #include "ash/shell_port.h"
15 #include "ash/strings/grit/ash_strings.h" 15 #include "ash/strings/grit/ash_strings.h"
16 #include "ash/system/network/network_icon.h" 16 #include "ash/system/network/network_icon.h"
17 #include "ash/system/network/network_icon_animation.h" 17 #include "ash/system/network/network_icon_animation.h"
18 #include "ash/system/network/network_icon_animation_observer.h" 18 #include "ash/system/network/network_icon_animation_observer.h"
19 #include "ash/system/network/network_list_delegate.h" 19 #include "ash/system/network/network_state_list_detailed_view.h"
20 #include "ash/system/network/vpn_list.h" 20 #include "ash/system/network/vpn_list.h"
21 #include "ash/system/tray/hover_highlight_view.h" 21 #include "ash/system/tray/hover_highlight_view.h"
22 #include "ash/system/tray/system_menu_button.h" 22 #include "ash/system/tray/system_menu_button.h"
23 #include "ash/system/tray/system_tray_controller.h" 23 #include "ash/system/tray/system_tray_controller.h"
24 #include "ash/system/tray/throbber_view.h" 24 #include "ash/system/tray/throbber_view.h"
25 #include "ash/system/tray/tray_constants.h" 25 #include "ash/system/tray/tray_constants.h"
26 #include "ash/system/tray/tray_popup_utils.h" 26 #include "ash/system/tray/tray_popup_utils.h"
27 #include "ash/system/tray/tri_view.h" 27 #include "ash/system/tray/tri_view.h"
28 #include "base/bind.h" 28 #include "base/bind.h"
29 #include "base/bind_helpers.h" 29 #include "base/bind_helpers.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 tri_view()->AddView(TriView::Container::END, disconnect_button_); 214 tri_view()->AddView(TriView::Container::END, disconnect_button_);
215 tri_view()->SetContainerVisible(TriView::Container::END, true); 215 tri_view()->SetContainerVisible(TriView::Container::END, true);
216 tri_view()->SetContainerBorder( 216 tri_view()->SetContainerBorder(
217 TriView::Container::END, 217 TriView::Container::END,
218 views::CreateEmptyBorder(0, 0, 0, kTrayPopupButtonEndMargin)); 218 views::CreateEmptyBorder(0, 0, 0, kTrayPopupButtonEndMargin));
219 } 219 }
220 Layout(); 220 Layout();
221 } 221 }
222 222
223 // TODO(varkha): Consolidate with a similar method in tray_bluetooth.cc. 223 // TODO(varkha): Consolidate with a similar method in tray_bluetooth.cc.
224 void VPNListNetworkEntry::SetupConnectedItem(const base::string16& text, 224 void VPNListNetworkEntry::SetupConnectedItem(const base::string16& text,
tdanderson 2017/04/28 16:36:20 Any way to share this code with the SetupConnect{e
mohsen 2017/04/28 21:51:32 I have more refactorings planned which make sharin
225 const gfx::ImageSkia& image) { 225 const gfx::ImageSkia& image) {
226 AddIconAndLabels( 226 AddIconAndLabels(
227 image, text, 227 image, text,
228 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED)); 228 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED));
229 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::CAPTION); 229 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::CAPTION);
230 style.set_color_style(TrayPopupItemStyle::ColorStyle::CONNECTED); 230 style.set_color_style(TrayPopupItemStyle::ColorStyle::CONNECTED);
231 style.SetupLabel(sub_text_label()); 231 style.SetupLabel(sub_text_label());
232 } 232 }
233 233
234 // TODO(varkha): Consolidate with a similar method in tray_bluetooth.cc. 234 // TODO(varkha): Consolidate with a similar method in tray_bluetooth.cc.
235 void VPNListNetworkEntry::SetupConnectingItem(const base::string16& text, 235 void VPNListNetworkEntry::SetupConnectingItem(const base::string16& text,
236 const gfx::ImageSkia& image) { 236 const gfx::ImageSkia& image) {
237 AddIconAndLabels( 237 AddIconAndLabels(
238 image, text, 238 image, text,
239 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING)); 239 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING));
240 ThrobberView* throbber = new ThrobberView; 240 ThrobberView* throbber = new ThrobberView;
241 throbber->Start(); 241 throbber->Start();
242 AddRightView(throbber); 242 AddRightView(throbber);
243 } 243 }
244 244
245 } // namespace 245 } // namespace
246 246
247 VPNListView::VPNListView(NetworkListDelegate* delegate) : delegate_(delegate) { 247 VPNListView::VPNListView(tray::NetworkStateListDetailedView* detailed_view)
248 : NetworkListViewBase(detailed_view) {
248 Shell::Get()->vpn_list()->AddObserver(this); 249 Shell::Get()->vpn_list()->AddObserver(this);
249 } 250 }
250 251
251 VPNListView::~VPNListView() { 252 VPNListView::~VPNListView() {
252 Shell::Get()->vpn_list()->RemoveObserver(this); 253 Shell::Get()->vpn_list()->RemoveObserver(this);
253 } 254 }
254 255
255 void VPNListView::Update() { 256 void VPNListView::Update() {
256 // Before updating the list, determine whether the user was hovering over one 257 // Before updating the list, determine whether the user was hovering over one
257 // of the VPN provider or network entries. 258 // of the VPN provider or network entries.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 network_view_guid_map_) { 308 network_view_guid_map_) {
308 if (entry.second == hovered_network_guid) { 309 if (entry.second == hovered_network_guid) {
309 scroll_to_show_view = entry.first; 310 scroll_to_show_view = entry.first;
310 break; 311 break;
311 } 312 }
312 } 313 }
313 } 314 }
314 315
315 // Layout the updated list. 316 // Layout the updated list.
316 container()->SizeToPreferredSize(); 317 container()->SizeToPreferredSize();
317 delegate_->RelayoutScrollList(); 318 detailed_view()->RelayoutScrollList();
318 319
319 if (scroll_to_show_view) { 320 if (scroll_to_show_view) {
320 // Scroll the list so that |scroll_to_show_view| is in view. 321 // Scroll the list so that |scroll_to_show_view| is in view.
321 container()->ScrollRectToVisible(scroll_to_show_view->bounds()); 322 container()->ScrollRectToVisible(scroll_to_show_view->bounds());
322 } 323 }
323 } 324 }
324 325
325 bool VPNListView::IsNetworkEntry(views::View* view, std::string* guid) const { 326 bool VPNListView::IsNetworkEntry(views::View* view, std::string* guid) const {
326 const auto& entry = network_view_guid_map_.find(view); 327 const auto& entry = network_view_guid_map_.find(view);
327 if (entry == network_view_guid_map_.end()) 328 if (entry == network_view_guid_map_.end())
(...skipping 22 matching lines...) Expand all
350 UMA_STATUS_AREA_VPN_ADD_BUILT_IN_CLICKED); 351 UMA_STATUS_AREA_VPN_ADD_BUILT_IN_CLICKED);
351 Shell::Get()->system_tray_controller()->ShowNetworkCreate( 352 Shell::Get()->system_tray_controller()->ShowNetworkCreate(
352 shill::kTypeVPN); 353 shill::kTypeVPN);
353 } 354 }
354 return; 355 return;
355 } 356 }
356 357
357 // If the user clicked on a network entry, let the |delegate_| trigger a 358 // If the user clicked on a network entry, let the |delegate_| trigger a
358 // connection attempt (if the network is currently disconnected) or show a 359 // connection attempt (if the network is currently disconnected) or show a
359 // configuration dialog (if the network is currently connected or connecting). 360 // configuration dialog (if the network is currently connected or connecting).
360 delegate_->OnNetworkEntryClicked(sender); 361 detailed_view()->OnNetworkEntryClicked(sender);
361 } 362 }
362 363
363 void VPNListView::AddNetwork(const chromeos::NetworkState* network) { 364 void VPNListView::AddNetwork(const chromeos::NetworkState* network) {
364 views::View* entry(new VPNListNetworkEntry(this, network)); 365 views::View* entry(new VPNListNetworkEntry(this, network));
365 container()->AddChildView(entry); 366 container()->AddChildView(entry);
366 network_view_guid_map_[entry] = network->guid(); 367 network_view_guid_map_[entry] = network->guid();
367 list_empty_ = false; 368 list_empty_ = false;
368 } 369 }
369 370
370 void VPNListView::AddProviderAndNetworks( 371 void VPNListView::AddProviderAndNetworks(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 414 }
414 } 415 }
415 416
416 // Add providers without any configured networks, in the order that the 417 // Add providers without any configured networks, in the order that the
417 // providers were returned by the extensions system. 418 // providers were returned by the extensions system.
418 for (const VPNProvider& provider : providers) 419 for (const VPNProvider& provider : providers)
419 AddProviderAndNetworks(provider, networks); 420 AddProviderAndNetworks(provider, networks);
420 } 421 }
421 422
422 } // namespace ash 423 } // namespace ash
OLDNEW
« ash/system/network/network_list_view_base.cc ('K') | « ash/system/network/vpn_list_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698