OLD | NEW |
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/renderer/script_context.h" | 5 #include "extensions/renderer/script_context.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // (which it won't). | 261 // (which it won't). |
262 const Extension* extension = extension_.get(); | 262 const Extension* extension = extension_.get(); |
263 if (extension && extension->is_hosted_app() && | 263 if (extension && extension->is_hosted_app() && |
264 (api_name == "runtime.connect" || api_name == "runtime.sendMessage")) { | 264 (api_name == "runtime.connect" || api_name == "runtime.sendMessage")) { |
265 extension = NULL; | 265 extension = NULL; |
266 } | 266 } |
267 return ExtensionAPI::GetSharedInstance()->IsAvailable( | 267 return ExtensionAPI::GetSharedInstance()->IsAvailable( |
268 api_name, extension, context_type_, url(), check_alias); | 268 api_name, extension, context_type_, url(), check_alias); |
269 } | 269 } |
270 | 270 |
271 void ScriptContext::DispatchEvent(const char* event_name, | |
272 v8::Local<v8::Array> args) const { | |
273 DCHECK(thread_checker_.CalledOnValidThread()); | |
274 v8::HandleScope handle_scope(isolate()); | |
275 v8::Context::Scope context_scope(v8_context()); | |
276 | |
277 v8::Local<v8::Value> argv[] = {v8::String::NewFromUtf8(isolate(), event_name), | |
278 args}; | |
279 module_system_->CallModuleMethodSafe(kEventBindings, "dispatchEvent", | |
280 arraysize(argv), argv); | |
281 } | |
282 | |
283 std::string ScriptContext::GetContextTypeDescription() const { | 271 std::string ScriptContext::GetContextTypeDescription() const { |
284 DCHECK(thread_checker_.CalledOnValidThread()); | 272 DCHECK(thread_checker_.CalledOnValidThread()); |
285 return GetContextTypeDescriptionString(context_type_); | 273 return GetContextTypeDescriptionString(context_type_); |
286 } | 274 } |
287 | 275 |
288 std::string ScriptContext::GetEffectiveContextTypeDescription() const { | 276 std::string ScriptContext::GetEffectiveContextTypeDescription() const { |
289 DCHECK(thread_checker_.CalledOnValidThread()); | 277 DCHECK(thread_checker_.CalledOnValidThread()); |
290 return GetContextTypeDescriptionString(effective_context_type_); | 278 return GetContextTypeDescriptionString(effective_context_type_); |
291 } | 279 } |
292 | 280 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 v8::Local<v8::Value> argv[]) { | 526 v8::Local<v8::Value> argv[]) { |
539 return context_->CallFunction(function, argc, argv); | 527 return context_->CallFunction(function, argc, argv); |
540 } | 528 } |
541 | 529 |
542 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { | 530 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { |
543 v8::HandleScope handle_scope(context_->isolate()); | 531 v8::HandleScope handle_scope(context_->isolate()); |
544 return gin::PerContextData::From(context_->v8_context())->context_holder(); | 532 return gin::PerContextData::From(context_->v8_context())->context_holder(); |
545 } | 533 } |
546 | 534 |
547 } // namespace extensions | 535 } // namespace extensions |
OLD | NEW |