OLD | NEW |
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 const std::string service_path_; | 117 const std::string service_path_; |
118 | 118 |
119 views::LabelButton* disconnect_button_ = nullptr; | 119 views::LabelButton* disconnect_button_ = nullptr; |
120 | 120 |
121 DISALLOW_COPY_AND_ASSIGN(VPNListNetworkEntry); | 121 DISALLOW_COPY_AND_ASSIGN(VPNListNetworkEntry); |
122 }; | 122 }; |
123 | 123 |
124 VPNListEntryBase::VPNListEntryBase(VPNListView* parent) | 124 VPNListEntryBase::VPNListEntryBase(VPNListView* parent) |
125 : HoverHighlightView(parent) { | 125 : HoverHighlightView(parent) { |
126 SetBorder( | 126 SetBorder(views::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, 0)); |
127 views::Border::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, 0)); | |
128 } | 127 } |
129 | 128 |
130 VPNListProviderEntry::VPNListProviderEntry(VPNListView* parent, | 129 VPNListProviderEntry::VPNListProviderEntry(VPNListView* parent, |
131 const std::string& name) | 130 const std::string& name) |
132 : VPNListEntryBase(parent) { | 131 : VPNListEntryBase(parent) { |
133 views::Label* const label = | 132 views::Label* const label = |
134 AddLabel(base::UTF8ToUTF16(name), gfx::ALIGN_LEFT, false /* highlight */); | 133 AddLabel(base::UTF8ToUTF16(name), gfx::ALIGN_LEFT, false /* highlight */); |
135 label->SetBorder(views::Border::CreateEmptyBorder(5, 0, 5, 0)); | 134 label->SetBorder(views::CreateEmptyBorder(5, 0, 5, 0)); |
136 } | 135 } |
137 | 136 |
138 VPNListNetworkEntry::VPNListNetworkEntry(VPNListView* parent, | 137 VPNListNetworkEntry::VPNListNetworkEntry(VPNListView* parent, |
139 const chromeos::NetworkState* network) | 138 const chromeos::NetworkState* network) |
140 : VPNListEntryBase(parent), service_path_(network->path()) { | 139 : VPNListEntryBase(parent), service_path_(network->path()) { |
141 UpdateFromNetworkState(network); | 140 UpdateFromNetworkState(network); |
142 } | 141 } |
143 | 142 |
144 VPNListNetworkEntry::~VPNListNetworkEntry() { | 143 VPNListNetworkEntry::~VPNListNetworkEntry() { |
145 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 144 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 network_icon::GetLabelForNetwork(network, network_icon::ICON_TYPE_LIST), | 218 network_icon::GetLabelForNetwork(network, network_icon::ICON_TYPE_LIST), |
220 IsConnectedOrConnecting(network)); | 219 IsConnectedOrConnecting(network)); |
221 if (IsConnectedOrConnecting(network)) { | 220 if (IsConnectedOrConnecting(network)) { |
222 if (UseMd()) { | 221 if (UseMd()) { |
223 disconnect_button_ = CreateTrayPopupButton( | 222 disconnect_button_ = CreateTrayPopupButton( |
224 this, l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_VPN_DISCONNECT)); | 223 this, l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_VPN_DISCONNECT)); |
225 } else { | 224 } else { |
226 disconnect_button_ = new DisconnectButton(this); | 225 disconnect_button_ = new DisconnectButton(this); |
227 } | 226 } |
228 AddChildView(disconnect_button_); | 227 AddChildView(disconnect_button_); |
229 SetBorder(views::Border::CreateEmptyBorder( | 228 SetBorder( |
230 0, kTrayPopupPaddingHorizontal, 0, | 229 views::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, |
231 UseMd() ? kTrayPopupButtonEndMargin : 3)); | 230 UseMd() ? kTrayPopupButtonEndMargin : 3)); |
232 } else { | 231 } else { |
233 SetBorder( | 232 SetBorder(views::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, 0)); |
234 views::Border::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, 0)); | |
235 } | 233 } |
236 | 234 |
237 // The icon and the disconnect button are always set to their preferred size. | 235 // The icon and the disconnect button are always set to their preferred size. |
238 // All remaining space is used for the network name. | 236 // All remaining space is used for the network name. |
239 views::BoxLayout* layout = | 237 views::BoxLayout* layout = |
240 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, UseMd() ? 0 : 3, | 238 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, UseMd() ? 0 : 3, |
241 kTrayPopupPaddingBetweenItems); | 239 kTrayPopupPaddingBetweenItems); |
242 if (UseMd()) { | 240 if (UseMd()) { |
243 layout->set_cross_axis_alignment( | 241 layout->set_cross_axis_alignment( |
244 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); | 242 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 428 } |
431 } | 429 } |
432 | 430 |
433 // Add providers without any configured networks, in the order that the | 431 // Add providers without any configured networks, in the order that the |
434 // providers were returned by the extensions system. | 432 // providers were returned by the extensions system. |
435 for (const VPNProvider& provider : providers) | 433 for (const VPNProvider& provider : providers) |
436 AddProviderAndNetworks(provider.key, provider.name, networks); | 434 AddProviderAndNetworks(provider.key, provider.name, networks); |
437 } | 435 } |
438 | 436 |
439 } // namespace ash | 437 } // namespace ash |
OLD | NEW |