Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/vpn_provider/vpn_service.h" | 5 #include "extensions/browser/api/vpn_provider/vpn_service.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 const std::string& configuration_name) { | 424 const std::string& configuration_name) { |
| 425 const std::string key = GetKey(extension_id, configuration_name); | 425 const std::string key = GetKey(extension_id, configuration_name); |
| 426 return ContainsKey(key_to_configuration_map_, key); | 426 return ContainsKey(key_to_configuration_map_, key); |
| 427 } | 427 } |
| 428 | 428 |
| 429 bool VpnService::VerifyConfigIsConnectedForTesting( | 429 bool VpnService::VerifyConfigIsConnectedForTesting( |
| 430 const std::string& extension_id) { | 430 const std::string& extension_id) { |
| 431 return DoesActiveConfigurationExistAndIsAccessAuthorized(extension_id); | 431 return DoesActiveConfigurationExistAndIsAccessAuthorized(extension_id); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void VpnService::OnExtensionUninstalled( | 434 void VpnService::DestroyConfigurationsForExtension( |
| 435 content::BrowserContext* browser_context, | 435 const extensions::Extension* extension) { |
| 436 const extensions::Extension* extension, | |
| 437 extensions::UninstallReason reason) { | |
| 438 if (browser_context != browser_context_) { | |
| 439 NOTREACHED(); | |
| 440 return; | |
| 441 } | |
| 442 | |
| 443 std::vector<VpnConfiguration*> to_be_destroyed; | 436 std::vector<VpnConfiguration*> to_be_destroyed; |
| 444 for (const auto& iter : key_to_configuration_map_) { | 437 for (const auto& iter : key_to_configuration_map_) { |
| 445 if (iter.second->extension_id() == extension->id()) { | 438 if (iter.second->extension_id() == extension->id()) { |
| 446 to_be_destroyed.push_back(iter.second); | 439 to_be_destroyed.push_back(iter.second); |
| 447 } | 440 } |
| 448 } | 441 } |
| 449 | 442 |
| 450 for (auto& iter : to_be_destroyed) { | 443 for (auto& iter : to_be_destroyed) { |
| 451 DestroyConfiguration(extension->id(), // Extension ID | 444 DestroyConfiguration(extension->id(), // Extension ID |
| 452 iter->configuration_name(), // Configuration name | 445 iter->configuration_name(), // Configuration name |
| 453 base::Bind(base::DoNothing), | 446 base::Bind(base::DoNothing), |
| 454 base::Bind(DoNothingFailureCallback)); | 447 base::Bind(DoNothingFailureCallback)); |
| 455 } | 448 } |
| 456 } | 449 } |
| 457 | 450 |
| 451 void VpnService::OnExtensionUninstalled( | |
| 452 content::BrowserContext* browser_context, | |
| 453 const extensions::Extension* extension, | |
| 454 extensions::UninstallReason reason) { | |
| 455 if (browser_context != browser_context_) { | |
| 456 NOTREACHED(); | |
| 457 return; | |
| 458 } | |
| 459 | |
| 460 DestroyConfigurationsForExtension(extension); | |
| 461 } | |
| 462 | |
| 458 void VpnService::OnExtensionUnloaded( | 463 void VpnService::OnExtensionUnloaded( |
| 459 content::BrowserContext* browser_context, | 464 content::BrowserContext* browser_context, |
| 460 const extensions::Extension* extension, | 465 const extensions::Extension* extension, |
| 461 extensions::UnloadedExtensionInfo::Reason reason) { | 466 extensions::UnloadedExtensionInfo::Reason reason) { |
| 462 if (browser_context != browser_context_) { | 467 if (browser_context != browser_context_) { |
| 463 NOTREACHED(); | 468 NOTREACHED(); |
| 464 return; | 469 return; |
| 465 } | 470 } |
| 466 | 471 |
| 467 if (active_configuration_ && | 472 if (active_configuration_ && |
| 468 active_configuration_->extension_id() == extension->id()) { | 473 active_configuration_->extension_id() == extension->id()) { |
| 469 shill_client_->UpdateConnectionState( | 474 shill_client_->UpdateConnectionState( |
| 470 active_configuration_->object_path(), | 475 active_configuration_->object_path(), |
| 471 static_cast<uint32_t>(api_vpn::VPN_CONNECTION_STATE_FAILURE), | 476 static_cast<uint32_t>(api_vpn::VPN_CONNECTION_STATE_FAILURE), |
| 472 base::Bind(base::DoNothing), base::Bind(DoNothingFailureCallback)); | 477 base::Bind(base::DoNothing), base::Bind(DoNothingFailureCallback)); |
| 473 } | 478 } |
| 479 if (extension_registry_->disabled_extensions().Contains(extension->id())) { | |
|
pneubeck (no reviews)
2015/03/24 08:55:25
The documentation at
ExtensionRegistryObserver::O
kaliamoorthi
2015/03/24 10:14:46
We discussed this.
| |
| 480 DestroyConfigurationsForExtension(extension); | |
| 481 } | |
|
pneubeck (no reviews)
2015/03/24 08:55:25
nit: remove {}
kaliamoorthi
2015/03/24 10:14:46
This is not relevant anymore.
| |
| 474 } | 482 } |
| 475 | 483 |
| 476 void VpnService::OnCreateConfigurationSuccess( | 484 void VpnService::OnCreateConfigurationSuccess( |
| 477 const VpnService::SuccessCallback& callback, | 485 const VpnService::SuccessCallback& callback, |
| 478 VpnConfiguration* configuration, | 486 VpnConfiguration* configuration, |
| 479 const std::string& service_path) { | 487 const std::string& service_path) { |
| 480 configuration->set_service_path(service_path); | 488 configuration->set_service_path(service_path); |
| 481 service_path_to_configuration_map_[service_path] = configuration; | 489 service_path_to_configuration_map_[service_path] = configuration; |
| 482 shill_client_->AddShillThirdPartyVpnObserver(configuration->object_path(), | 490 shill_client_->AddShillThirdPartyVpnObserver(configuration->object_path(), |
| 483 configuration); | 491 configuration); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 delete configuration; | 551 delete configuration; |
| 544 } | 552 } |
| 545 | 553 |
| 546 bool VpnService::DoesActiveConfigurationExistAndIsAccessAuthorized( | 554 bool VpnService::DoesActiveConfigurationExistAndIsAccessAuthorized( |
| 547 const std::string& extension_id) { | 555 const std::string& extension_id) { |
| 548 return active_configuration_ && | 556 return active_configuration_ && |
| 549 active_configuration_->extension_id() == extension_id; | 557 active_configuration_->extension_id() == extension_id; |
| 550 } | 558 } |
| 551 | 559 |
| 552 } // namespace chromeos | 560 } // namespace chromeos |
| OLD | NEW |