Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/extensions/api/extension_api.h" | 5 #include "chrome/common/extensions/api/extension_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 void ExtensionAPI::RegisterSchema(const std::string& name, | 402 void ExtensionAPI::RegisterSchema(const std::string& name, |
| 403 const base::StringPiece& source) { | 403 const base::StringPiece& source) { |
| 404 unloaded_schemas_[name] = source; | 404 unloaded_schemas_[name] = source; |
| 405 } | 405 } |
| 406 | 406 |
| 407 void ExtensionAPI::RegisterDependencyProvider(const std::string& name, | 407 void ExtensionAPI::RegisterDependencyProvider(const std::string& name, |
| 408 FeatureProvider* provider) { | 408 FeatureProvider* provider) { |
| 409 dependency_providers_[name] = provider; | 409 dependency_providers_[name] = provider; |
| 410 } | 410 } |
| 411 | 411 |
| 412 Feature::Availability ExtensionAPI::IsPartAvailableToContext( | |
|
not at google - send to devlin
2013/04/27 01:02:43
this method should probably return a bool, since i
cduvall
2013/05/01 02:51:47
Done.
| |
| 413 const std::string& api_name, | |
| 414 Feature::Context context, | |
| 415 const GURL& url) { | |
| 416 FeatureProviderMap::iterator provider = dependency_providers_.find("api"); | |
| 417 CHECK(provider != dependency_providers_.end()); | |
| 418 std::set<std::string> features = provider->second->GetAllFeatureNames(); | |
| 419 | |
| 420 // Check to see if there are any parts of this API that are allowed in this | |
| 421 // context. | |
| 422 for (std::set<std::string>::iterator i = features.begin(); | |
| 423 i != features.end(); ++i) { | |
| 424 std::string feature_name = *i; | |
|
not at google - send to devlin
2013/04/27 01:02:43
std::string&
cduvall
2013/05/01 02:51:47
Done.
| |
| 425 if (feature_name != api_name && feature_name.find(api_name) == 0) { | |
|
not at google - send to devlin
2013/04/27 01:02:43
i'm worried that at some point we'll have API name
cduvall
2013/05/01 02:51:47
Done.
| |
| 426 Feature::Availability availability = | |
| 427 IsAvailable(feature_name, NULL, context, url); | |
| 428 if (availability.is_available()) | |
| 429 return availability; | |
| 430 } | |
| 431 } | |
| 432 return IsAvailable(api_name, NULL, context, url); | |
| 433 } | |
| 434 | |
| 412 Feature::Availability ExtensionAPI::IsAvailable(const std::string& full_name, | 435 Feature::Availability ExtensionAPI::IsAvailable(const std::string& full_name, |
| 413 const Extension* extension, | 436 const Extension* extension, |
| 414 Feature::Context context, | 437 Feature::Context context, |
| 415 const GURL& url) { | 438 const GURL& url) { |
| 416 std::string feature_type; | 439 std::string feature_type; |
| 417 std::string feature_name; | 440 std::string feature_name; |
| 418 SplitDependencyName(full_name, &feature_type, &feature_name); | 441 SplitDependencyName(full_name, &feature_type, &feature_name); |
| 419 | 442 |
| 420 std::string child_name; | 443 std::string child_name; |
| 421 std::string api_name = GetAPINameFromFullName(feature_name, &child_name); | 444 std::string api_name = GetAPINameFromFullName(feature_name, &child_name); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 641 return extension->required_permission_set()->HasAnyAccessToAPI(name) || | 664 return extension->required_permission_set()->HasAnyAccessToAPI(name) || |
| 642 extension->optional_permission_set()->HasAnyAccessToAPI(name); | 665 extension->optional_permission_set()->HasAnyAccessToAPI(name); |
| 643 } | 666 } |
| 644 | 667 |
| 645 bool ExtensionAPI::IsPrivilegedAPI(const std::string& name) { | 668 bool ExtensionAPI::IsPrivilegedAPI(const std::string& name) { |
| 646 return completely_unprivileged_apis_.count(name) || | 669 return completely_unprivileged_apis_.count(name) || |
| 647 partially_unprivileged_apis_.count(name); | 670 partially_unprivileged_apis_.count(name); |
| 648 } | 671 } |
| 649 | 672 |
| 650 } // namespace extensions | 673 } // namespace extensions |
| OLD | NEW |