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

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

Issue 2602483002: [ash-md] Stacks child layers properly for sticky header rows (Closed)
Patch Set: Created 4 years 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/common/system/chromeos/network/vpn_list_view.h" 5 #include "ash/common/system/chromeos/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
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 // A list entry that represents a VPN provider with Material Design. 92 // A list entry that represents a VPN provider with Material Design.
93 class VPNListProviderEntryMd : public views::ButtonListener, 93 class VPNListProviderEntryMd : public views::ButtonListener,
94 public views::View { 94 public views::View {
95 public: 95 public:
96 VPNListProviderEntryMd(ViewClickListener* parent, 96 VPNListProviderEntryMd(ViewClickListener* parent,
97 bool top_item, 97 bool top_item,
98 const std::string& name, 98 const std::string& name,
99 int button_accessible_name_id) 99 int button_accessible_name_id)
100 : parent_(parent) { 100 : parent_(parent) {
101 // TODO(varkha): Make this a sticky section header. 101 TrayPopupUtils::ConfigureAsStickyHeader(this);
102 SetLayoutManager(new views::FillLayout); 102 SetLayoutManager(new views::FillLayout);
103 TriView* tri_view = TrayPopupUtils::CreateSubHeaderRowView(); 103 TriView* tri_view = TrayPopupUtils::CreateSubHeaderRowView();
104 AddChildView(tri_view); 104 AddChildView(tri_view);
105 105
106 // Sets up the border. When the provider header is the first item in the
107 // list (i.e. when the list was empty before adding the provider row) there
108 // is already |kMenuSeparatorVerticalPadding| padding at the top of the
109 // scroll contents, so only add that padding when the list was not |empty|.
110 // TODO(varkha): Delete this special handling when we allow the header to be
111 // sticky and just use ConfigureAsStickyHeader() instead.
112 tri_view->SetBorder(
113 views::CreateEmptyBorder(top_item ? 0 : kMenuSeparatorVerticalPadding,
114 0, kMenuSeparatorVerticalPadding, 0));
115
116 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); 106 views::Label* label = TrayPopupUtils::CreateDefaultLabel();
117 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER); 107 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER);
118 style.SetupLabel(label); 108 style.SetupLabel(label);
119 label->SetText(base::ASCIIToUTF16(name)); 109 label->SetText(base::ASCIIToUTF16(name));
120 tri_view->AddView(TriView::Container::CENTER, label); 110 tri_view->AddView(TriView::Container::CENTER, label);
121 111
122 gfx::ImageSkia icon = gfx::CreateVectorIcon(kSystemMenuAddConnectionIcon, 112 gfx::ImageSkia icon = gfx::CreateVectorIcon(kSystemMenuAddConnectionIcon,
123 style.GetIconColor()); 113 style.GetIconColor());
124 SystemMenuButton* add_vpn_button = 114 SystemMenuButton* add_vpn_button =
125 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, icon, 115 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, icon,
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 378 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
389 } 379 }
390 380
391 // Get the list of available VPN networks, in shill's priority order. 381 // Get the list of available VPN networks, in shill's priority order.
392 chromeos::NetworkStateHandler::NetworkStateList networks; 382 chromeos::NetworkStateHandler::NetworkStateList networks;
393 chromeos::NetworkHandler::Get() 383 chromeos::NetworkHandler::Get()
394 ->network_state_handler() 384 ->network_state_handler()
395 ->GetVisibleNetworkListByType(chromeos::NetworkTypePattern::VPN(), 385 ->GetVisibleNetworkListByType(chromeos::NetworkTypePattern::VPN(),
396 &networks); 386 &networks);
397 387
398 if (!networks.empty() && IsConnectedOrConnecting(networks.front())) {
399 // If there is a connected or connecting network, show that network first.
400 AddNetwork(networks.front());
401 networks.erase(networks.begin());
402 }
403
404 // Show all VPN providers and all networks that are currently disconnected. 388 // Show all VPN providers and all networks that are currently disconnected.
405 AddProvidersAndNetworks(networks); 389 AddProvidersAndNetworks(networks);
406 390
407 // Determine whether one of the new list entries corresponds to the entry that 391 // Determine whether one of the new list entries corresponds to the entry that
408 // the user was previously hovering over. If such an entry is found, the list 392 // the user was previously hovering over. If such an entry is found, the list
409 // will be scrolled to ensure the entry is visible. 393 // will be scrolled to ensure the entry is visible.
410 const views::View* scroll_to_show_view = nullptr; 394 const views::View* scroll_to_show_view = nullptr;
411 if (hovered_provider_key) { 395 if (hovered_provider_key) {
412 for (const std::pair<const views::View* const, VPNProvider::Key>& provider : 396 for (const std::pair<const views::View* const, VPNProvider::Key>& provider :
413 provider_view_key_map_) { 397 provider_view_key_map_) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 } 508 }
525 } 509 }
526 510
527 // Add providers without any configured networks, in the order that the 511 // Add providers without any configured networks, in the order that the
528 // providers were returned by the extensions system. 512 // providers were returned by the extensions system.
529 for (const VPNProvider& provider : providers) 513 for (const VPNProvider& provider : providers)
530 AddProviderAndNetworks(provider.key, provider.name, networks); 514 AddProviderAndNetworks(provider.key, provider.name, networks);
531 } 515 }
532 516
533 } // namespace ash 517 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/network/network_list_md.cc ('k') | ash/common/system/tray/tray_details_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698