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

Unified Diff: chrome/renderer/extensions/chrome_v8_context.cc

Issue 12522004: Lazily load extension API schemas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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
« no previous file with comments | « chrome/renderer/extensions/chrome_v8_context.h ('k') | chrome/renderer/extensions/dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/chrome_v8_context.cc
diff --git a/chrome/renderer/extensions/chrome_v8_context.cc b/chrome/renderer/extensions/chrome_v8_context.cc
index b7a4d64a57b61cb917b7d7aabd60306ea650af03..fa1bcd6955e1a4eeaaf027a038cd1ddcdb6fa752 100644
--- a/chrome/renderer/extensions/chrome_v8_context.cc
+++ b/chrome/renderer/extensions/chrome_v8_context.cc
@@ -24,11 +24,6 @@ namespace extensions {
namespace {
const char kChromeHidden[] = "chromeHidden";
-const char kUnavailableMessage[] = "You do not have permission to access this "
- "API. Ensure that the required permission "
- "or manifest property is included in your "
- "manifest.json.";
-
const char kValidateCallbacks[] = "validateCallbacks";
const char kValidateAPI[] = "validateAPI";
@@ -41,8 +36,7 @@ ChromeV8Context::ChromeV8Context(v8::Handle<v8::Context> v8_context,
: v8_context_(v8_context),
web_frame_(web_frame),
extension_(extension),
- context_type_(context_type),
- available_extension_apis_initialized_(false) {
+ context_type_(context_type) {
VLOG(1) << "Created context:\n"
<< " extension id: " << GetExtensionID() << "\n"
<< " frame: " << web_frame_ << "\n"
@@ -154,29 +148,13 @@ bool ChromeV8Context::CallChromeHiddenMethod(
return true;
}
-const std::set<std::string>& ChromeV8Context::GetAvailableExtensionAPIs() {
- if (!available_extension_apis_initialized_) {
- available_extension_apis_ =
- ExtensionAPI::GetSharedInstance()->GetAPIsForContext(
- context_type_,
- extension_,
- UserScriptSlave::GetDataSourceURLForFrame(web_frame_));
- available_extension_apis_initialized_ = true;
- }
- return available_extension_apis_;
-}
-
Feature::Availability ChromeV8Context::GetAvailability(
const std::string& api_name) {
- const std::set<std::string>& available_apis = GetAvailableExtensionAPIs();
-
- // TODO(cduvall/kalman): Switch to ExtensionAPI::IsAvailable() once Features
- // are complete.
- if (available_apis.find(api_name) != available_apis.end())
- return Feature::CreateAvailability(Feature::IS_AVAILABLE, "");
-
- return Feature::CreateAvailability(Feature::INVALID_CONTEXT,
- kUnavailableMessage);
+ return ExtensionAPI::GetSharedInstance()->IsAvailable(
+ api_name,
+ extension_,
+ context_type_,
+ UserScriptSlave::GetDataSourceURLForFrame(web_frame_));
}
void ChromeV8Context::DispatchOnLoadEvent(bool is_incognito_process,
« no previous file with comments | « chrome/renderer/extensions/chrome_v8_context.h ('k') | chrome/renderer/extensions/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698