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

Unified Diff: extensions/browser/api/vpn_provider/vpn_service.cc

Issue 974443002: Make vpn destroyConfig generate disconnect message for connected configuration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/vpn_provider/vpn_service.cc
diff --git a/extensions/browser/api/vpn_provider/vpn_service.cc b/extensions/browser/api/vpn_provider/vpn_service.cc
index 7a51aac70dad68758c332cc4fb1fc6e35abfd96e..54002bce3fe08803b9d2a3ef1b0e530df9d9542d 100644
--- a/extensions/browser/api/vpn_provider/vpn_service.cc
+++ b/extensions/browser/api/vpn_provider/vpn_service.cc
@@ -25,6 +25,7 @@
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_type_pattern.h"
#include "crypto/sha2.h"
+#include "extensions/browser/app_window/app_window.h"
bartfab (slow) 2015/03/10 13:28:40 Nit: No longer needed.
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_registry.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -137,6 +138,7 @@ void VpnService::VpnConfiguration::OnPlatformMessage(uint32_t message) {
VpnService::VpnService(
content::BrowserContext* browser_context,
const std::string& userid_hash,
+ extensions::AppWindowRegistry* app_window_registry,
bartfab (slow) 2015/03/10 13:28:40 Nit: No longer needed.
extensions::ExtensionRegistry* extension_registry,
extensions::EventRouter* event_router,
ShillThirdPartyVpnDriverClient* shill_client,
@@ -145,6 +147,7 @@ VpnService::VpnService(
NetworkStateHandler* network_state_handler)
: browser_context_(browser_context),
userid_hash_(userid_hash),
+ app_window_registry_(app_window_registry),
bartfab (slow) 2015/03/10 13:28:40 Nit: No longer needed.
extension_registry_(extension_registry),
event_router_(event_router),
shill_client_(shill_client),
@@ -153,6 +156,7 @@ VpnService::VpnService(
network_state_handler_(network_state_handler),
active_configuration_(nullptr),
weak_factory_(this) {
+ app_window_registry_->AddObserver(this);
bartfab (slow) 2015/03/10 13:28:40 Nit: No longer needed.
extension_registry_->AddObserver(this);
network_state_handler_->AddObserver(this, FROM_HERE);
network_configuration_handler_->AddObserver(this);
@@ -162,6 +166,7 @@ VpnService::~VpnService() {
network_configuration_handler_->RemoveObserver(this);
network_state_handler_->RemoveObserver(this, FROM_HERE);
extension_registry_->RemoveObserver(this);
+ app_window_registry_->RemoveObserver(this);
bartfab (slow) 2015/03/10 13:28:40 Nit: No longer needed.
STLDeleteContainerPairSecondPointers(key_to_configuration_map_.begin(),
key_to_configuration_map_.end());
}
@@ -342,6 +347,9 @@ void VpnService::DestroyConfiguration(const std::string& extension_id,
VpnConfiguration* configuration = key_to_configuration_map_[key];
const std::string service_path = configuration->service_path();
+ if (active_configuration_ == configuration) {
+ configuration->OnPlatformMessage(api_vpn::PLATFORM_MESSAGE_DISCONNECTED);
+ }
DestroyConfigurationInternal(configuration);
network_configuration_handler_->RemoveConfiguration(
@@ -421,6 +429,34 @@ void VpnService::OnExtensionUninstalled(
}
}
+void VpnService::OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ extensions::UnloadedExtensionInfo::Reason reason) {
+ if (browser_context != browser_context_) {
+ NOTREACHED();
+ return;
+ }
+
+ if (active_configuration_ &&
+ active_configuration_->extension_id() == extension->id()) {
+ shill_client_->UpdateConnectionState(
+ active_configuration_->object_path(),
+ static_cast<uint32_t>(api_vpn::VPN_CONNECTION_STATE_FAILURE),
+ base::Bind(base::DoNothing), base::Bind(DoNothingFailureCallback));
+ }
+}
+
+void VpnService::OnAppWindowRemoved(extensions::AppWindow* app_window) {
bartfab (slow) 2015/03/10 13:28:40 Nit: As discussed offline, we do not need this.
+ if (active_configuration_ &&
+ active_configuration_->extension_id() == app_window->extension_id()) {
+ shill_client_->UpdateConnectionState(
+ active_configuration_->object_path(),
+ static_cast<uint32_t>(api_vpn::VPN_CONNECTION_STATE_FAILURE),
+ base::Bind(base::DoNothing), base::Bind(DoNothingFailureCallback));
+ }
+}
+
void VpnService::OnCreateConfigurationSuccess(
const VpnService::SuccessCallback& callback,
VpnConfiguration* configuration,

Powered by Google App Engine
This is Rietveld 408576698