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

Side by Side Diff: content/renderer/mojo_bindings_controller.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, 4 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 | « content/renderer/mojo_bindings_controller.h ('k') | content/renderer/mojo_context_state.h » ('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 "content/renderer/mojo_bindings_controller.h" 5 #include "content/renderer/mojo_bindings_controller.h"
6 6
7 #include "content/common/view_messages.h" 7 #include "content/common/view_messages.h"
8 #include "content/public/renderer/render_frame.h" 8 #include "content/public/renderer/render_frame.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "content/renderer/mojo_context_state.h" 10 #include "content/renderer/mojo_context_state.h"
11 #include "gin/per_context_data.h" 11 #include "gin/per_context_data.h"
12 #include "third_party/WebKit/public/web/WebKit.h" 12 #include "third_party/WebKit/public/web/WebKit.h"
13 #include "third_party/WebKit/public/web/WebLocalFrame.h" 13 #include "third_party/WebKit/public/web/WebLocalFrame.h"
14 #include "third_party/WebKit/public/web/WebView.h" 14 #include "third_party/WebKit/public/web/WebView.h"
15 #include "v8/include/v8.h" 15 #include "v8/include/v8.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 namespace { 19 namespace {
20 20
21 const char kMojoContextStateKey[] = "MojoContextState"; 21 const char kMojoContextStateKey[] = "MojoContextState";
22 22
23 struct MojoContextStateData : public base::SupportsUserData::Data { 23 struct MojoContextStateData : public base::SupportsUserData::Data {
24 std::unique_ptr<MojoContextState> state; 24 std::unique_ptr<MojoContextState> state;
25 }; 25 };
26 26
27 } // namespace 27 } // namespace
28 28
29 MojoBindingsController::MojoBindingsController(RenderFrame* render_frame, 29 MojoBindingsController::MojoBindingsController(RenderFrame* render_frame,
30 bool for_layout_tests) 30 MojoBindingsType bindings_type)
31 : RenderFrameObserver(render_frame), 31 : RenderFrameObserver(render_frame),
32 RenderFrameObserverTracker<MojoBindingsController>(render_frame), 32 RenderFrameObserverTracker<MojoBindingsController>(render_frame),
33 for_layout_tests_(for_layout_tests) {} 33 bindings_type_(bindings_type) {}
34 34
35 MojoBindingsController::~MojoBindingsController() { 35 MojoBindingsController::~MojoBindingsController() {
36 } 36 }
37 37
38 void MojoBindingsController::CreateContextState() { 38 void MojoBindingsController::CreateContextState() {
39 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 39 v8::HandleScope handle_scope(blink::mainThreadIsolate());
40 blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); 40 blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
41 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); 41 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
42 gin::PerContextData* context_data = gin::PerContextData::From(context); 42 gin::PerContextData* context_data = gin::PerContextData::From(context);
43 MojoContextStateData* data = new MojoContextStateData; 43 MojoContextStateData* data = new MojoContextStateData;
44 data->state.reset(new MojoContextState(frame, context, for_layout_tests_)); 44 data->state.reset(new MojoContextState(frame, context, bindings_type_));
45 context_data->SetUserData(kMojoContextStateKey, data); 45 context_data->SetUserData(kMojoContextStateKey, data);
46 } 46 }
47 47
48 void MojoBindingsController::DestroyContextState( 48 void MojoBindingsController::DestroyContextState(
49 v8::Local<v8::Context> context) { 49 v8::Local<v8::Context> context) {
50 gin::PerContextData* context_data = gin::PerContextData::From(context); 50 gin::PerContextData* context_data = gin::PerContextData::From(context);
51 if (!context_data) 51 if (!context_data)
52 return; 52 return;
53 context_data->RemoveUserData(kMojoContextStateKey); 53 context_data->RemoveUserData(kMojoContextStateKey);
54 } 54 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 97 v8::HandleScope handle_scope(blink::mainThreadIsolate());
98 DestroyContextState(render_frame()->GetWebFrame()->mainWorldScriptContext()); 98 DestroyContextState(render_frame()->GetWebFrame()->mainWorldScriptContext());
99 } 99 }
100 100
101 void MojoBindingsController::OnDestruct() { 101 void MojoBindingsController::OnDestruct() {
102 delete this; 102 delete this;
103 } 103 }
104 104
105 } // namespace content 105 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/mojo_bindings_controller.h ('k') | content/renderer/mojo_context_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698