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/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 Loading... | |
| 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 Feature::Availability ChromeV8Context::GetAvailabilityForContext( | |
| 157 const std::string& api_name) { | |
| 158 return ExtensionAPI::GetSharedInstance()->IsPartAvailableToContext( | |
|
not at google - send to devlin
2013/04/27 01:02:43
seems like this might be a dangerous oversimplific
cduvall
2013/05/01 02:51:47
Maybe it would be better to rename GetPossibleAvai
not at google - send to devlin
2013/05/01 20:47:04
Ah yeah good point. Something even more explicit p
cduvall
2013/05/01 23:47:10
Done.
| |
| 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::DispatchOnLoadEvent(bool is_incognito_process, | 173 void ChromeV8Context::DispatchOnLoadEvent(bool is_incognito_process, |
| 176 int manifest_version) { | 174 int manifest_version) { |
| 177 v8::HandleScope handle_scope; | 175 v8::HandleScope handle_scope; |
| 178 v8::Handle<v8::Value> argv[] = { | 176 v8::Handle<v8::Value> argv[] = { |
| 179 v8::String::New(GetExtensionID().c_str()), | 177 v8::String::New(GetExtensionID().c_str()), |
| 180 v8::String::New(GetContextTypeDescription().c_str()), | 178 v8::String::New(GetContextTypeDescription().c_str()), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 // string if a validation error has occured. | 226 // string if a validation error has occured. |
| 229 if (DCHECK_IS_ON()) { | 227 if (DCHECK_IS_ON()) { |
| 230 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 228 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
| 231 std::string error = *v8::String::AsciiValue(retval); | 229 std::string error = *v8::String::AsciiValue(retval); |
| 232 DCHECK(false) << error; | 230 DCHECK(false) << error; |
| 233 } | 231 } |
| 234 } | 232 } |
| 235 } | 233 } |
| 236 | 234 |
| 237 } // namespace extensions | 235 } // namespace extensions |
| OLD | NEW |