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 13 matching lines...) Expand all Loading... | |
| 24 #include "ash/common/system/tray/tri_view.h" | 24 #include "ash/common/system/tray/tri_view.h" |
| 25 #include "ash/common/wm_shell.h" | 25 #include "ash/common/wm_shell.h" |
| 26 #include "ash/resources/vector_icons/vector_icons.h" | 26 #include "ash/resources/vector_icons/vector_icons.h" |
| 27 #include "ash/shell.h" | 27 #include "ash/shell.h" |
| 28 #include "ash/strings/grit/ash_strings.h" | 28 #include "ash/strings/grit/ash_strings.h" |
| 29 #include "base/bind.h" | 29 #include "base/bind.h" |
| 30 #include "base/bind_helpers.h" | 30 #include "base/bind_helpers.h" |
| 31 #include "base/logging.h" | 31 #include "base/logging.h" |
| 32 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
| 33 #include "base/values.h" | 33 #include "base/values.h" |
| 34 #include "chromeos/network/network_connect.h" | |
| 34 #include "chromeos/network/network_connection_handler.h" | 35 #include "chromeos/network/network_connection_handler.h" |
|
stevenjb
2017/03/23 21:43:43
No longer needed?
varkha
2017/03/23 22:46:55
Done.
| |
| 35 #include "chromeos/network/network_handler.h" | 36 #include "chromeos/network/network_handler.h" |
| 36 #include "chromeos/network/network_state.h" | 37 #include "chromeos/network/network_state.h" |
| 37 #include "chromeos/network/network_type_pattern.h" | 38 #include "chromeos/network/network_type_pattern.h" |
| 38 #include "third_party/cros_system_api/dbus/service_constants.h" | 39 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 39 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
| 40 #include "ui/base/resource/resource_bundle.h" | 41 #include "ui/base/resource/resource_bundle.h" |
| 41 #include "ui/gfx/geometry/rect.h" | 42 #include "ui/gfx/geometry/rect.h" |
| 42 #include "ui/gfx/image/image_skia.h" | 43 #include "ui/gfx/image/image_skia.h" |
| 43 #include "ui/gfx/paint_vector_icon.h" | 44 #include "ui/gfx/paint_vector_icon.h" |
| 44 #include "ui/gfx/text_constants.h" | 45 #include "ui/gfx/text_constants.h" |
| 45 #include "ui/views/border.h" | 46 #include "ui/views/border.h" |
| 46 #include "ui/views/controls/button/button.h" | 47 #include "ui/views/controls/button/button.h" |
| 47 #include "ui/views/controls/button/label_button.h" | 48 #include "ui/views/controls/button/label_button.h" |
| 48 #include "ui/views/controls/label.h" | 49 #include "ui/views/controls/label.h" |
| 49 #include "ui/views/controls/separator.h" | 50 #include "ui/views/controls/separator.h" |
| 50 #include "ui/views/layout/box_layout.h" | 51 #include "ui/views/layout/box_layout.h" |
| 51 #include "ui/views/layout/fill_layout.h" | 52 #include "ui/views/layout/fill_layout.h" |
| 52 #include "ui/views/view.h" | 53 #include "ui/views/view.h" |
| 53 | 54 |
| 54 namespace ash { | 55 namespace ash { |
| 55 | 56 |
| 56 namespace { | 57 namespace { |
| 57 | 58 |
| 58 bool UseMd() { | 59 bool UseMd() { |
| 59 return MaterialDesignController::IsSystemTrayMenuMaterial(); | 60 return MaterialDesignController::IsSystemTrayMenuMaterial(); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void IgnoreDisconnectError(const std::string& error_name, | |
| 63 std::unique_ptr<base::DictionaryValue> error_data) {} | |
| 64 | |
| 65 // Indicates whether |network| belongs to this VPN provider. | 63 // Indicates whether |network| belongs to this VPN provider. |
| 66 bool VpnProviderMatchesNetwork(const VPNProvider& provider, | 64 bool VpnProviderMatchesNetwork(const VPNProvider& provider, |
| 67 const chromeos::NetworkState& network) { | 65 const chromeos::NetworkState& network) { |
| 68 if (network.type() != shill::kTypeVPN) | 66 if (network.type() != shill::kTypeVPN) |
| 69 return false; | 67 return false; |
| 70 const bool network_uses_third_party_provider = | 68 const bool network_uses_third_party_provider = |
| 71 network.vpn_provider_type() == shill::kProviderThirdPartyVpn; | 69 network.vpn_provider_type() == shill::kProviderThirdPartyVpn; |
| 72 if (!provider.third_party) | 70 if (!provider.third_party) |
| 73 return !network_uses_third_party_provider; | 71 return !network_uses_third_party_provider; |
| 74 return network_uses_third_party_provider && | 72 return network_uses_third_party_provider && |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 ->GetNetworkStateFromGuid(guid_)); | 197 ->GetNetworkStateFromGuid(guid_)); |
| 200 } | 198 } |
| 201 | 199 |
| 202 void VPNListNetworkEntry::ButtonPressed(Button* sender, | 200 void VPNListNetworkEntry::ButtonPressed(Button* sender, |
| 203 const ui::Event& event) { | 201 const ui::Event& event) { |
| 204 if (sender != disconnect_button_) { | 202 if (sender != disconnect_button_) { |
| 205 VPNListEntryBase::ButtonPressed(sender, event); | 203 VPNListEntryBase::ButtonPressed(sender, event); |
| 206 return; | 204 return; |
| 207 } | 205 } |
| 208 | 206 |
| 209 const chromeos::NetworkState* network = chromeos::NetworkHandler::Get() | 207 chromeos::NetworkConnect::Get()->DisconnectFromNetworkId(guid_); |
| 210 ->network_state_handler() | |
| 211 ->GetNetworkStateFromGuid(guid_); | |
| 212 if (!network) | |
| 213 return; | |
| 214 WmShell::Get()->RecordUserMetricsAction( | |
| 215 UMA_STATUS_AREA_VPN_DISCONNECT_CLICKED); | |
| 216 chromeos::NetworkHandler::Get() | |
| 217 ->network_connection_handler() | |
| 218 ->DisconnectNetwork(network->path(), base::Bind(&base::DoNothing), | |
| 219 base::Bind(&IgnoreDisconnectError)); | |
| 220 } | 208 } |
| 221 | 209 |
| 222 void VPNListNetworkEntry::UpdateFromNetworkState( | 210 void VPNListNetworkEntry::UpdateFromNetworkState( |
| 223 const chromeos::NetworkState* network) { | 211 const chromeos::NetworkState* network) { |
| 224 if (network && network->IsConnectingState()) | 212 if (network && network->IsConnectingState()) |
| 225 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); | 213 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); |
| 226 else | 214 else |
| 227 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 215 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 228 | 216 |
| 229 if (!network) { | 217 if (!network) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 } | 447 } |
| 460 } | 448 } |
| 461 | 449 |
| 462 // Add providers without any configured networks, in the order that the | 450 // Add providers without any configured networks, in the order that the |
| 463 // providers were returned by the extensions system. | 451 // providers were returned by the extensions system. |
| 464 for (const VPNProvider& provider : providers) | 452 for (const VPNProvider& provider : providers) |
| 465 AddProviderAndNetworks(provider, networks); | 453 AddProviderAndNetworks(provider, networks); |
| 466 } | 454 } |
| 467 | 455 |
| 468 } // namespace ash | 456 } // namespace ash |
| OLD | NEW |