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

Side by Side Diff: extensions/renderer/script_context.cc

Issue 399363002: Add support for writing unit tests for Mojo-backed apps/extensions APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « extensions/renderer/resources/test_custom_bindings.js ('k') | extensions/test/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 v8::HandleScope handle_scope(isolate()); 114 v8::HandleScope handle_scope(isolate());
115 v8::Context::Scope context_scope(v8_context()); 115 v8::Context::Scope context_scope(v8_context());
116 116
117 v8::Handle<v8::Value> argv[] = { 117 v8::Handle<v8::Value> argv[] = {
118 v8::String::NewFromUtf8(isolate(), event_name), args}; 118 v8::String::NewFromUtf8(isolate(), event_name), args};
119 module_system_->CallModuleMethod( 119 module_system_->CallModuleMethod(
120 kEventBindings, "dispatchEvent", arraysize(argv), argv); 120 kEventBindings, "dispatchEvent", arraysize(argv), argv);
121 } 121 }
122 122
123 void ScriptContext::DispatchOnUnloadEvent() { 123 void ScriptContext::DispatchOnUnloadEvent() {
124 v8::HandleScope handle_scope(isolate());
125 v8::Context::Scope context_scope(v8_context());
124 module_system_->CallModuleMethod("unload_event", "dispatch"); 126 module_system_->CallModuleMethod("unload_event", "dispatch");
125 } 127 }
126 128
127 std::string ScriptContext::GetContextTypeDescription() { 129 std::string ScriptContext::GetContextTypeDescription() {
128 switch (context_type_) { 130 switch (context_type_) {
129 case Feature::UNSPECIFIED_CONTEXT: 131 case Feature::UNSPECIFIED_CONTEXT:
130 return "UNSPECIFIED"; 132 return "UNSPECIFIED";
131 case Feature::BLESSED_EXTENSION_CONTEXT: 133 case Feature::BLESSED_EXTENSION_CONTEXT:
132 return "BLESSED_EXTENSION"; 134 return "BLESSED_EXTENSION";
133 case Feature::UNBLESSED_EXTENSION_CONTEXT: 135 case Feature::UNBLESSED_EXTENSION_CONTEXT:
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 v8::Handle<v8::Value> argv[]) { 239 v8::Handle<v8::Value> argv[]) {
238 return CallFunction(function, argc, argv); 240 return CallFunction(function, argc, argv);
239 } 241 }
240 242
241 gin::ContextHolder* ScriptContext::GetContextHolder() { 243 gin::ContextHolder* ScriptContext::GetContextHolder() {
242 v8::HandleScope handle_scope(isolate()); 244 v8::HandleScope handle_scope(isolate());
243 return gin::PerContextData::From(v8_context())->context_holder(); 245 return gin::PerContextData::From(v8_context())->context_holder();
244 } 246 }
245 247
246 } // namespace extensions 248 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/resources/test_custom_bindings.js ('k') | extensions/test/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698