Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 #include "ui/views/view.h" | 52 #include "ui/views/view.h" |
| 53 | 53 |
| 54 namespace ash { | 54 namespace ash { |
| 55 | 55 |
| 56 namespace { | 56 namespace { |
| 57 | 57 |
| 58 bool UseMd() { | 58 bool UseMd() { |
| 59 return MaterialDesignController::IsSystemTrayMenuMaterial(); | 59 return MaterialDesignController::IsSystemTrayMenuMaterial(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void IgnoreDisconnectError(const std::string& error_name, | |
| 63 std::unique_ptr<base::DictionaryValue> error_data) {} | |
| 64 | |
| 62 // Indicates whether |network| belongs to this VPN provider. | 65 // Indicates whether |network| belongs to this VPN provider. |
| 63 bool VpnProviderMatchesNetwork(const VPNProvider& provider, | 66 bool VpnProviderMatchesNetwork(const VPNProvider& provider, |
| 64 const chromeos::NetworkState& network) { | 67 const chromeos::NetworkState& network) { |
| 65 if (network.type() != shill::kTypeVPN) | 68 if (network.type() != shill::kTypeVPN) |
| 66 return false; | 69 return false; |
| 67 const bool network_uses_third_party_provider = | 70 const bool network_uses_third_party_provider = |
| 68 network.vpn_provider_type() == shill::kProviderThirdPartyVpn; | 71 network.vpn_provider_type() == shill::kProviderThirdPartyVpn; |
| 69 if (!provider.third_party) | 72 if (!provider.third_party) |
| 70 return !network_uses_third_party_provider; | 73 return !network_uses_third_party_provider; |
| 71 return network_uses_third_party_provider && | 74 return network_uses_third_party_provider && |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 class VPNListNetworkEntry : public VPNListEntryBase, | 153 class VPNListNetworkEntry : public VPNListEntryBase, |
| 151 public network_icon::AnimationObserver { | 154 public network_icon::AnimationObserver { |
| 152 public: | 155 public: |
| 153 VPNListNetworkEntry(VPNListView* parent, | 156 VPNListNetworkEntry(VPNListView* parent, |
| 154 const chromeos::NetworkState* network); | 157 const chromeos::NetworkState* network); |
| 155 ~VPNListNetworkEntry() override; | 158 ~VPNListNetworkEntry() override; |
| 156 | 159 |
| 157 // network_icon::AnimationObserver: | 160 // network_icon::AnimationObserver: |
| 158 void NetworkIconChanged() override; | 161 void NetworkIconChanged() override; |
| 159 | 162 |
| 163 // views::ButtonListener: | |
| 164 void ButtonPressed(Button* sender, const ui::Event& event) override; | |
| 165 | |
| 160 private: | 166 private: |
| 161 void UpdateFromNetworkState(const chromeos::NetworkState* network); | 167 void UpdateFromNetworkState(const chromeos::NetworkState* network); |
| 162 void SetupConnectedItemMd(const base::string16& text, | 168 void SetupConnectedItemMd(const base::string16& text, |
| 163 const gfx::ImageSkia& image); | 169 const gfx::ImageSkia& image); |
| 164 void SetupConnectingItemMd(const base::string16& text, | 170 void SetupConnectingItemMd(const base::string16& text, |
| 165 const gfx::ImageSkia& image); | 171 const gfx::ImageSkia& image); |
| 166 | 172 |
| 167 const std::string guid_; | 173 const std::string guid_; |
| 168 | 174 |
| 175 const std::string service_path_; | |
| 176 | |
| 169 views::LabelButton* disconnect_button_ = nullptr; | 177 views::LabelButton* disconnect_button_ = nullptr; |
| 170 | 178 |
| 171 DISALLOW_COPY_AND_ASSIGN(VPNListNetworkEntry); | 179 DISALLOW_COPY_AND_ASSIGN(VPNListNetworkEntry); |
| 172 }; | 180 }; |
| 173 | 181 |
| 174 VPNListEntryBase::VPNListEntryBase(VPNListView* parent) | 182 VPNListEntryBase::VPNListEntryBase(VPNListView* parent) |
| 175 : HoverHighlightView(parent) { | 183 : HoverHighlightView(parent) { |
| 176 if (!UseMd()) | 184 if (!UseMd()) |
| 177 SetBorder(views::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, 0)); | 185 SetBorder(views::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, 0)); |
| 178 } | 186 } |
| 179 | 187 |
| 180 VPNListNetworkEntry::VPNListNetworkEntry(VPNListView* parent, | 188 VPNListNetworkEntry::VPNListNetworkEntry(VPNListView* parent, |
| 181 const chromeos::NetworkState* network) | 189 const chromeos::NetworkState* network) |
| 182 : VPNListEntryBase(parent), guid_(network->guid()) { | 190 : VPNListEntryBase(parent), |
| 191 guid_(network->guid()), | |
| 192 service_path_(network->path()) { | |
| 183 UpdateFromNetworkState(network); | 193 UpdateFromNetworkState(network); |
| 184 } | 194 } |
| 185 | 195 |
| 186 VPNListNetworkEntry::~VPNListNetworkEntry() { | 196 VPNListNetworkEntry::~VPNListNetworkEntry() { |
| 187 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 197 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 188 } | 198 } |
| 189 | 199 |
| 190 void VPNListNetworkEntry::NetworkIconChanged() { | 200 void VPNListNetworkEntry::NetworkIconChanged() { |
| 191 UpdateFromNetworkState(chromeos::NetworkHandler::Get() | 201 UpdateFromNetworkState(chromeos::NetworkHandler::Get() |
| 192 ->network_state_handler() | 202 ->network_state_handler() |
| 193 ->GetNetworkStateFromGuid(guid_)); | 203 ->GetNetworkStateFromGuid(guid_)); |
|
tdanderson
2017/03/22 23:03:54
In the breaking CL, this query is instead performe
varkha
2017/03/23 00:00:31
Removing service_path_ was conscious choice - see
| |
| 194 } | 204 } |
| 195 | 205 |
| 206 void VPNListNetworkEntry::ButtonPressed(Button* sender, | |
| 207 const ui::Event& event) { | |
| 208 if (sender != disconnect_button_) { | |
| 209 VPNListEntryBase::ButtonPressed(sender, event); | |
| 210 return; | |
| 211 } | |
| 212 | |
| 213 WmShell::Get()->RecordUserMetricsAction( | |
| 214 UMA_STATUS_AREA_VPN_DISCONNECT_CLICKED); | |
| 215 chromeos::NetworkHandler::Get() | |
| 216 ->network_connection_handler() | |
| 217 ->DisconnectNetwork(service_path_, base::Bind(&base::DoNothing), | |
| 218 base::Bind(&IgnoreDisconnectError)); | |
| 219 } | |
| 220 | |
| 196 void VPNListNetworkEntry::UpdateFromNetworkState( | 221 void VPNListNetworkEntry::UpdateFromNetworkState( |
| 197 const chromeos::NetworkState* network) { | 222 const chromeos::NetworkState* network) { |
| 198 if (network && network->IsConnectingState()) | 223 if (network && network->IsConnectingState()) |
| 199 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); | 224 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); |
| 200 else | 225 else |
| 201 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 226 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 202 | 227 |
| 203 if (!network) { | 228 if (!network) { |
| 204 // This is a transient state where the network has been removed already but | 229 // This is a transient state where the network has been removed already but |
| 205 // the network list in the UI has not been updated yet. | 230 // the network list in the UI has not been updated yet. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 } | 458 } |
| 434 } | 459 } |
| 435 | 460 |
| 436 // Add providers without any configured networks, in the order that the | 461 // Add providers without any configured networks, in the order that the |
| 437 // providers were returned by the extensions system. | 462 // providers were returned by the extensions system. |
| 438 for (const VPNProvider& provider : providers) | 463 for (const VPNProvider& provider : providers) |
| 439 AddProviderAndNetworks(provider, networks); | 464 AddProviderAndNetworks(provider, networks); |
| 440 } | 465 } |
| 441 | 466 |
| 442 } // namespace ash | 467 } // namespace ash |
| OLD | NEW |