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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 v8::HandleScope handle_scope(isolate()); | 113 v8::HandleScope handle_scope(isolate()); |
114 v8::Context::Scope context_scope(v8_context()); | 114 v8::Context::Scope context_scope(v8_context()); |
115 | 115 |
116 v8::Handle<v8::Value> argv[] = { | 116 v8::Handle<v8::Value> argv[] = { |
117 v8::String::NewFromUtf8(isolate(), event_name), args}; | 117 v8::String::NewFromUtf8(isolate(), event_name), args}; |
118 module_system_->CallModuleMethod( | 118 module_system_->CallModuleMethod( |
119 kEventBindings, "dispatchEvent", arraysize(argv), argv); | 119 kEventBindings, "dispatchEvent", arraysize(argv), argv); |
120 } | 120 } |
121 | 121 |
122 void ScriptContext::DispatchOnUnloadEvent() { | 122 void ScriptContext::DispatchOnUnloadEvent() { |
| 123 v8::HandleScope handle_scope(isolate()); |
| 124 v8::Context::Scope context_scope(v8_context()); |
123 module_system_->CallModuleMethod("unload_event", "dispatch"); | 125 module_system_->CallModuleMethod("unload_event", "dispatch"); |
124 } | 126 } |
125 | 127 |
126 std::string ScriptContext::GetContextTypeDescription() { | 128 std::string ScriptContext::GetContextTypeDescription() { |
127 switch (context_type_) { | 129 switch (context_type_) { |
128 case Feature::UNSPECIFIED_CONTEXT: | 130 case Feature::UNSPECIFIED_CONTEXT: |
129 return "UNSPECIFIED"; | 131 return "UNSPECIFIED"; |
130 case Feature::BLESSED_EXTENSION_CONTEXT: | 132 case Feature::BLESSED_EXTENSION_CONTEXT: |
131 return "BLESSED_EXTENSION"; | 133 return "BLESSED_EXTENSION"; |
132 case Feature::UNBLESSED_EXTENSION_CONTEXT: | 134 case Feature::UNBLESSED_EXTENSION_CONTEXT: |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 v8::Handle<v8::Value> argv[]) { | 236 v8::Handle<v8::Value> argv[]) { |
235 return CallFunction(function, argc, argv); | 237 return CallFunction(function, argc, argv); |
236 } | 238 } |
237 | 239 |
238 gin::ContextHolder* ScriptContext::GetContextHolder() { | 240 gin::ContextHolder* ScriptContext::GetContextHolder() { |
239 v8::HandleScope handle_scope(isolate()); | 241 v8::HandleScope handle_scope(isolate()); |
240 return gin::PerContextData::From(v8_context())->context_holder(); | 242 return gin::PerContextData::From(v8_context())->context_holder(); |
241 } | 243 } |
242 | 244 |
243 } // namespace extensions | 245 } // namespace extensions |
OLD | NEW |