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

Side by Side Diff: extensions/browser/api/vpn_provider/vpn_service.cc

Issue 2236443003: extensions: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't add braces Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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 <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 network_configuration_handler_->AddObserver(this); 236 network_configuration_handler_->AddObserver(this);
237 base::ThreadTaskRunnerHandle::Get()->PostTask( 237 base::ThreadTaskRunnerHandle::Get()->PostTask(
238 FROM_HERE, 238 FROM_HERE,
239 base::Bind(&VpnService::NetworkListChanged, weak_factory_.GetWeakPtr())); 239 base::Bind(&VpnService::NetworkListChanged, weak_factory_.GetWeakPtr()));
240 } 240 }
241 241
242 VpnService::~VpnService() { 242 VpnService::~VpnService() {
243 network_configuration_handler_->RemoveObserver(this); 243 network_configuration_handler_->RemoveObserver(this);
244 network_state_handler_->RemoveObserver(this, FROM_HERE); 244 network_state_handler_->RemoveObserver(this, FROM_HERE);
245 extension_registry_->RemoveObserver(this); 245 extension_registry_->RemoveObserver(this);
246 STLDeleteContainerPairSecondPointers(key_to_configuration_map_.begin(), 246 base::STLDeleteContainerPairSecondPointers(key_to_configuration_map_.begin(),
247 key_to_configuration_map_.end()); 247 key_to_configuration_map_.end());
248 } 248 }
249 249
250 void VpnService::SendShowAddDialogToExtension(const std::string& extension_id) { 250 void VpnService::SendShowAddDialogToExtension(const std::string& extension_id) {
251 SendSignalToExtension(extension_id, 251 SendSignalToExtension(extension_id,
252 extensions::events::VPN_PROVIDER_ON_UI_EVENT, 252 extensions::events::VPN_PROVIDER_ON_UI_EVENT,
253 api_vpn::OnUIEvent::kEventName, 253 api_vpn::OnUIEvent::kEventName,
254 api_vpn::OnUIEvent::Create( 254 api_vpn::OnUIEvent::Create(
255 api_vpn::UI_EVENT_SHOWADDDIALOG, std::string())); 255 api_vpn::UI_EVENT_SHOWADDDIALOG, std::string()));
256 } 256 }
257 257
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 const std::string& extension_name, 386 const std::string& extension_name,
387 const std::string& configuration_name, 387 const std::string& configuration_name,
388 const SuccessCallback& success, 388 const SuccessCallback& success,
389 const FailureCallback& failure) { 389 const FailureCallback& failure) {
390 if (configuration_name.empty()) { 390 if (configuration_name.empty()) {
391 failure.Run(std::string(), std::string("Empty name not supported.")); 391 failure.Run(std::string(), std::string("Empty name not supported."));
392 return; 392 return;
393 } 393 }
394 394
395 const std::string key = GetKey(extension_id, configuration_name); 395 const std::string key = GetKey(extension_id, configuration_name);
396 if (ContainsKey(key_to_configuration_map_, key)) { 396 if (base::ContainsKey(key_to_configuration_map_, key)) {
397 failure.Run(std::string(), std::string("Name not unique.")); 397 failure.Run(std::string(), std::string("Name not unique."));
398 return; 398 return;
399 } 399 }
400 400
401 const NetworkProfile* profile = 401 const NetworkProfile* profile =
402 network_profile_handler_->GetProfileForUserhash(userid_hash_); 402 network_profile_handler_->GetProfileForUserhash(userid_hash_);
403 if (!profile) { 403 if (!profile) {
404 failure.Run( 404 failure.Run(
405 std::string(), 405 std::string(),
406 std::string("No user profile for unshared network configuration.")); 406 std::string("No user profile for unshared network configuration."));
(...skipping 29 matching lines...) Expand all
436 base::Bind(&VpnService::OnCreateConfigurationFailure, 436 base::Bind(&VpnService::OnCreateConfigurationFailure,
437 weak_factory_.GetWeakPtr(), failure, configuration)); 437 weak_factory_.GetWeakPtr(), failure, configuration));
438 } 438 }
439 439
440 void VpnService::DestroyConfiguration(const std::string& extension_id, 440 void VpnService::DestroyConfiguration(const std::string& extension_id,
441 const std::string& configuration_id, 441 const std::string& configuration_id,
442 const SuccessCallback& success, 442 const SuccessCallback& success,
443 const FailureCallback& failure) { 443 const FailureCallback& failure) {
444 // The ID is the configuration name for now. This may change in the future. 444 // The ID is the configuration name for now. This may change in the future.
445 const std::string key = GetKey(extension_id, configuration_id); 445 const std::string key = GetKey(extension_id, configuration_id);
446 if (!ContainsKey(key_to_configuration_map_, key)) { 446 if (!base::ContainsKey(key_to_configuration_map_, key)) {
447 failure.Run(std::string(), std::string("Unauthorized access.")); 447 failure.Run(std::string(), std::string("Unauthorized access."));
448 return; 448 return;
449 } 449 }
450 450
451 VpnConfiguration* configuration = key_to_configuration_map_[key]; 451 VpnConfiguration* configuration = key_to_configuration_map_[key];
452 const std::string service_path = configuration->service_path(); 452 const std::string service_path = configuration->service_path();
453 if (service_path.empty()) { 453 if (service_path.empty()) {
454 failure.Run(std::string(), std::string("Pending create.")); 454 failure.Run(std::string(), std::string("Pending create."));
455 return; 455 return;
456 } 456 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 509
510 shill_client_->UpdateConnectionState(active_configuration_->object_path(), 510 shill_client_->UpdateConnectionState(active_configuration_->object_path(),
511 static_cast<uint32_t>(state), success, 511 static_cast<uint32_t>(state), success,
512 failure); 512 failure);
513 } 513 }
514 514
515 bool VpnService::VerifyConfigExistsForTesting( 515 bool VpnService::VerifyConfigExistsForTesting(
516 const std::string& extension_id, 516 const std::string& extension_id,
517 const std::string& configuration_name) { 517 const std::string& configuration_name) {
518 const std::string key = GetKey(extension_id, configuration_name); 518 const std::string key = GetKey(extension_id, configuration_name);
519 return ContainsKey(key_to_configuration_map_, key); 519 return base::ContainsKey(key_to_configuration_map_, key);
520 } 520 }
521 521
522 bool VpnService::VerifyConfigIsConnectedForTesting( 522 bool VpnService::VerifyConfigIsConnectedForTesting(
523 const std::string& extension_id) { 523 const std::string& extension_id) {
524 return DoesActiveConfigurationExistAndIsAccessAuthorized(extension_id); 524 return DoesActiveConfigurationExistAndIsAccessAuthorized(extension_id);
525 } 525 }
526 526
527 void VpnService::DestroyConfigurationsForExtension( 527 void VpnService::DestroyConfigurationsForExtension(
528 const extensions::Extension* extension) { 528 const extensions::Extension* extension) {
529 std::vector<VpnConfiguration*> to_be_destroyed; 529 std::vector<VpnConfiguration*> to_be_destroyed;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 void VpnService::Bind( 657 void VpnService::Bind(
658 const std::string& extension_id, 658 const std::string& extension_id,
659 const std::string& configuration_id, 659 const std::string& configuration_id,
660 const std::string& configuration_name, 660 const std::string& configuration_name,
661 const SuccessCallback& success, 661 const SuccessCallback& success,
662 const FailureCallback& failure, 662 const FailureCallback& failure,
663 std::unique_ptr<content::PepperVpnProviderResourceHostProxy> 663 std::unique_ptr<content::PepperVpnProviderResourceHostProxy>
664 pepper_vpn_provider_proxy) { 664 pepper_vpn_provider_proxy) {
665 // The ID is the configuration name for now. This may change in the future. 665 // The ID is the configuration name for now. This may change in the future.
666 const std::string key = GetKey(extension_id, configuration_id); 666 const std::string key = GetKey(extension_id, configuration_id);
667 if (!ContainsKey(key_to_configuration_map_, key)) { 667 if (!base::ContainsKey(key_to_configuration_map_, key)) {
668 failure.Run(std::string(), 668 failure.Run(std::string(),
669 std::string("Unauthorized access. " 669 std::string("Unauthorized access. "
670 "The configuration does not exist.")); 670 "The configuration does not exist."));
671 return; 671 return;
672 } 672 }
673 673
674 VpnConfiguration* configuration = key_to_configuration_map_[key]; 674 VpnConfiguration* configuration = key_to_configuration_map_[key];
675 if (active_configuration_ != configuration) { 675 if (active_configuration_ != configuration) {
676 failure.Run(std::string(), std::string("Unauthorized access. " 676 failure.Run(std::string(), std::string("Unauthorized access. "
677 "The configuration is not active.")); 677 "The configuration is not active."));
(...skipping 18 matching lines...) Expand all
696 configuration->set_pepper_proxy(std::move(pepper_vpn_provider_proxy)); 696 configuration->set_pepper_proxy(std::move(pepper_vpn_provider_proxy));
697 697
698 success.Run(); 698 success.Run();
699 } 699 }
700 700
701 std::unique_ptr<content::VpnServiceProxy> VpnService::GetVpnServiceProxy() { 701 std::unique_ptr<content::VpnServiceProxy> VpnService::GetVpnServiceProxy() {
702 return base::WrapUnique(new VpnServiceProxyImpl(weak_factory_.GetWeakPtr())); 702 return base::WrapUnique(new VpnServiceProxyImpl(weak_factory_.GetWeakPtr()));
703 } 703 }
704 704
705 } // namespace chromeos 705 } // namespace chromeos
OLDNEW
« no previous file with comments | « extensions/browser/api/socket/app_firewall_hole_manager.cc ('k') | extensions/browser/api/web_request/web_request_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698