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

Side by Side Diff: content/renderer/web_ui_mojo.cc

Issue 206923002: Adds plumbing to pass WebUI mojo::Handle from browser to renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add TODO and merge to trunk Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/web_ui_mojo.h ('k') | content/renderer/web_ui_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/web_ui_mojo.h" 5 #include "content/renderer/web_ui_mojo.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/web_ui_mojo_context_state.h" 10 #include "content/renderer/web_ui_mojo_context_state.h"
(...skipping 30 matching lines...) Expand all
41 web_ui_mojo_->DestroyContextState(context); 41 web_ui_mojo_->DestroyContextState(context);
42 } 42 }
43 43
44 WebUIMojo::WebUIMojo(RenderView* render_view) 44 WebUIMojo::WebUIMojo(RenderView* render_view)
45 : RenderViewObserver(render_view), 45 : RenderViewObserver(render_view),
46 RenderViewObserverTracker<WebUIMojo>(render_view), 46 RenderViewObserverTracker<WebUIMojo>(render_view),
47 main_frame_observer_(this) { 47 main_frame_observer_(this) {
48 CreateContextState(); 48 CreateContextState();
49 } 49 }
50 50
51 void WebUIMojo::SetBrowserHandle(mojo::ScopedMessagePipeHandle handle) {
52 v8::HandleScope handle_scope(blink::mainThreadIsolate());
53 WebUIMojoContextState* state = GetContextState();
54 if (state)
55 state->SetHandle(handle.Pass());
56 }
57
51 WebUIMojo::~WebUIMojo() { 58 WebUIMojo::~WebUIMojo() {
52 } 59 }
53 60
54 void WebUIMojo::OnSetBrowserHandle(MojoHandle handle) {
55 v8::HandleScope handle_scope(blink::mainThreadIsolate());
56 WebUIMojoContextState* state = GetContextState();
57 if (state)
58 state->SetHandle(mojo::MakeScopedHandle(mojo::Handle(handle)));
59 }
60
61 void WebUIMojo::CreateContextState() { 61 void WebUIMojo::CreateContextState() {
62 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 62 v8::HandleScope handle_scope(blink::mainThreadIsolate());
63 blink::WebFrame* frame = render_view()->GetWebView()->mainFrame(); 63 blink::WebFrame* frame = render_view()->GetWebView()->mainFrame();
64 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); 64 v8::Handle<v8::Context> context = frame->mainWorldScriptContext();
65 gin::PerContextData* context_data = gin::PerContextData::From(context); 65 gin::PerContextData* context_data = gin::PerContextData::From(context);
66 WebUIMojoContextStateData* data = new WebUIMojoContextStateData; 66 WebUIMojoContextStateData* data = new WebUIMojoContextStateData;
67 data->state.reset(new WebUIMojoContextState( 67 data->state.reset(new WebUIMojoContextState(
68 render_view()->GetWebView()->mainFrame(), context)); 68 render_view()->GetWebView()->mainFrame(), context));
69 context_data->SetUserData(kWebUIMojoContextStateKey, data); 69 context_data->SetUserData(kWebUIMojoContextStateKey, data);
70 } 70 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 WebUIMojoContextState* state = GetContextState(); 103 WebUIMojoContextState* state = GetContextState();
104 if (state && !state->module_added()) 104 if (state && !state->module_added())
105 return; 105 return;
106 106
107 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 107 v8::HandleScope handle_scope(blink::mainThreadIsolate());
108 DestroyContextState(frame->mainWorldScriptContext()); 108 DestroyContextState(frame->mainWorldScriptContext());
109 CreateContextState(); 109 CreateContextState();
110 } 110 }
111 111
112 } // namespace content 112 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/web_ui_mojo.h ('k') | content/renderer/web_ui_mojo_context_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698