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

Unified Diff: content/renderer/mojo_context_state.cc

Issue 2049363003: Adds support for headless chrome embedder mojo services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/mojo_context_state.h ('k') | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/mojo_context_state.cc
diff --git a/content/renderer/mojo_context_state.cc b/content/renderer/mojo_context_state.cc
index 17939f7b8e0ae84b3b429a26e26b78b3290da73f..2da9becde0a44f559a8f89a52f1e13f1c9d254b7 100644
--- a/content/renderer/mojo_context_state.cc
+++ b/content/renderer/mojo_context_state.cc
@@ -18,6 +18,7 @@
#include "content/public/common/content_client.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/resource_fetcher.h"
+#include "content/renderer/mojo_bindings_controller.h"
#include "content/renderer/mojo_main_runner.h"
#include "gin/converter.h"
#include "gin/modules/module_registry.h"
@@ -90,17 +91,28 @@ scoped_refptr<base::RefCountedMemory> GetBuiltinModuleData(
return source_iter->second;
}
+std::string GetModulePrefixForBindingsType(MojoBindingsType bindings_type,
+ blink::WebFrame* frame) {
+ switch (bindings_type) {
+ case MojoBindingsType::FOR_WEB_UI:
+ return frame->getSecurityOrigin().toString().utf8() + "/";
+ case MojoBindingsType::FOR_LAYOUT_TESTS:
+ return "layout-test-mojom://";
+ case MojoBindingsType::FOR_HEADLESS:
+ return "headless-mojom://";
+ }
+ NOTREACHED();
+ return "";
+}
+
} // namespace
MojoContextState::MojoContextState(blink::WebFrame* frame,
v8::Local<v8::Context> context,
- bool for_layout_tests)
+ MojoBindingsType bindings_type)
: frame_(frame),
module_added_(false),
- module_prefix_(for_layout_tests
- ? "layout-test-mojom://"
- : frame_->getSecurityOrigin().toString().utf8() +
- "/") {
+ module_prefix_(GetModulePrefixForBindingsType(bindings_type, frame)) {
gin::PerContextData* context_data = gin::PerContextData::From(context);
gin::ContextHolder* context_holder = context_data->context_holder();
runner_.reset(new MojoMainRunner(frame_, context_holder));
@@ -109,7 +121,7 @@ MojoContextState::MojoContextState(blink::WebFrame* frame,
content::RenderFrame::FromWebFrame(frame)
->EnsureMojoBuiltinsAreAvailable(context_holder->isolate(), context);
v8::Local<v8::Object> install_target;
- if (for_layout_tests) {
+ if (bindings_type == MojoBindingsType::FOR_LAYOUT_TESTS) {
// In layout tests we install the module system under 'mojo.define'
// for now to avoid globally exposing something as generic as 'define'.
//
« no previous file with comments | « content/renderer/mojo_context_state.h ('k') | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698