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

Side by Side Diff: chrome/renderer/extensions/chrome_v8_context.cc

Issue 14494013: Allow API functions and events to have entries in _api_features.json (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bug in searching for unprivileged Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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/renderer/extensions/chrome_v8_context.h" 5 #include "chrome/renderer/extensions/chrome_v8_context.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/common/extensions/api/extension_api.h" 12 #include "chrome/common/extensions/api/extension_api.h"
13 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/extensions/extension_set.h" 14 #include "chrome/common/extensions/extension_set.h"
15 #include "chrome/common/extensions/features/base_feature_provider.h"
15 #include "chrome/renderer/extensions/chrome_v8_extension.h" 16 #include "chrome/renderer/extensions/chrome_v8_extension.h"
16 #include "chrome/renderer/extensions/module_system.h" 17 #include "chrome/renderer/extensions/module_system.h"
17 #include "chrome/renderer/extensions/user_script_slave.h" 18 #include "chrome/renderer/extensions/user_script_slave.h"
18 #include "content/public/renderer/render_view.h" 19 #include "content/public/renderer/render_view.h"
19 #include "content/public/renderer/v8_value_converter.h" 20 #include "content/public/renderer/v8_value_converter.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
22 #include "v8/include/v8.h" 23 #include "v8/include/v8.h"
23 24
24 using content::V8ValueConverter; 25 using content::V8ValueConverter;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 web_frame_->callFunctionEvenIfScriptDisabled(function, 146 web_frame_->callFunctionEvenIfScriptDisabled(function,
146 v8::Object::New(), 147 v8::Object::New(),
147 argc, 148 argc,
148 argv); 149 argv);
149 if (result) 150 if (result)
150 *result = result_temp; 151 *result = result_temp;
151 152
152 return true; 153 return true;
153 } 154 }
154 155
156 bool ChromeV8Context::IsAnyFeatureAvailableToContext(
157 const std::string& api_name) {
158 return ExtensionAPI::GetSharedInstance()->IsAnyFeatureAvailableToContext(
159 api_name,
160 context_type_,
161 UserScriptSlave::GetDataSourceURLForFrame(web_frame_));
162 }
163
155 Feature::Availability ChromeV8Context::GetAvailability( 164 Feature::Availability ChromeV8Context::GetAvailability(
156 const std::string& api_name) { 165 const std::string& api_name) {
157 return GetAvailabilityInternal(api_name, extension_);
158 }
159
160 Feature::Availability ChromeV8Context::GetAvailabilityForContext(
161 const std::string& api_name) {
162 return GetAvailabilityInternal(api_name, NULL);
163 }
164
165 Feature::Availability ChromeV8Context::GetAvailabilityInternal(
166 const std::string& api_name,
167 const Extension* extension) {
168 return ExtensionAPI::GetSharedInstance()->IsAvailable( 166 return ExtensionAPI::GetSharedInstance()->IsAvailable(
169 api_name, 167 api_name,
170 extension, 168 extension_,
171 context_type_, 169 context_type_,
172 UserScriptSlave::GetDataSourceURLForFrame(web_frame_)); 170 UserScriptSlave::GetDataSourceURLForFrame(web_frame_));
173 } 171 }
174 172
175 void ChromeV8Context::DispatchOnUnloadEvent() { 173 void ChromeV8Context::DispatchOnUnloadEvent() {
176 v8::HandleScope handle_scope; 174 v8::HandleScope handle_scope;
177 CallChromeHiddenMethod("dispatchOnUnload", 0, NULL, NULL); 175 CallChromeHiddenMethod("dispatchOnUnload", 0, NULL, NULL);
178 } 176 }
179 177
180 std::string ChromeV8Context::GetContextTypeDescription() { 178 std::string ChromeV8Context::GetContextTypeDescription() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // string if a validation error has occured. 214 // string if a validation error has occured.
217 if (DCHECK_IS_ON()) { 215 if (DCHECK_IS_ON()) {
218 if (!retval.IsEmpty() && !retval->IsUndefined()) { 216 if (!retval.IsEmpty() && !retval->IsUndefined()) {
219 std::string error = *v8::String::AsciiValue(retval); 217 std::string error = *v8::String::AsciiValue(retval);
220 DCHECK(false) << error; 218 DCHECK(false) << error;
221 } 219 }
222 } 220 }
223 } 221 }
224 222
225 } // namespace extensions 223 } // namespace extensions
OLDNEW
« 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