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 "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/common/service_registry.h" | |
8 #include "content/public/renderer/render_frame.h" | 9 #include "content/public/renderer/render_frame.h" |
9 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
10 #include "content/renderer/web_ui_mojo_context_state.h" | 11 #include "content/renderer/web_ui_mojo_context_state.h" |
11 #include "gin/per_context_data.h" | 12 #include "gin/per_context_data.h" |
12 #include "third_party/WebKit/public/web/WebKit.h" | 13 #include "third_party/WebKit/public/web/WebKit.h" |
13 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 14 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
14 #include "third_party/WebKit/public/web/WebView.h" | 15 #include "third_party/WebKit/public/web/WebView.h" |
15 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 | 78 |
78 void WebUIMojo::DestroyContextState(v8::Handle<v8::Context> context) { | 79 void WebUIMojo::DestroyContextState(v8::Handle<v8::Context> context) { |
79 gin::PerContextData* context_data = gin::PerContextData::From(context); | 80 gin::PerContextData* context_data = gin::PerContextData::From(context); |
80 if (!context_data) | 81 if (!context_data) |
81 return; | 82 return; |
82 context_data->RemoveUserData(kWebUIMojoContextStateKey); | 83 context_data->RemoveUserData(kWebUIMojoContextStateKey); |
83 } | 84 } |
84 | 85 |
85 void WebUIMojo::OnDidFinishDocumentLoad() { | 86 void WebUIMojo::OnDidFinishDocumentLoad() { |
86 did_finish_document_load_ = true; | 87 did_finish_document_load_ = true; |
87 if (pending_handle_.is_valid()) | 88 mojo::MessagePipe pipe; |
88 SetHandleOnContextState(pending_handle_.Pass()); | 89 SetHandleOnContextState(pipe.handle0.Pass()); |
90 RenderFrame::FromWebFrame(render_view()->GetWebView()->mainFrame()) | |
91 ->GetServiceRegistry() | |
darin (slow to review)
2014/06/21 04:33:35
nit: "Wrap after binary operators, not before." fr
Sam McNally
2014/06/24 04:00:29
Done.
| |
92 ->GetRemoteInterface("webui_controller", pipe.handle1.Pass()); | |
89 } | 93 } |
90 | 94 |
91 void WebUIMojo::SetHandleOnContextState(mojo::ScopedMessagePipeHandle handle) { | 95 void WebUIMojo::SetHandleOnContextState(mojo::ScopedMessagePipeHandle handle) { |
92 DCHECK(did_finish_document_load_); | 96 DCHECK(did_finish_document_load_); |
93 v8::HandleScope handle_scope(blink::mainThreadIsolate()); | 97 v8::HandleScope handle_scope(blink::mainThreadIsolate()); |
94 WebUIMojoContextState* state = GetContextState(); | 98 WebUIMojoContextState* state = GetContextState(); |
95 if (state) | 99 if (state) |
96 state->SetHandle(handle.Pass()); | 100 state->SetHandle(handle.Pass()); |
97 } | 101 } |
98 | 102 |
(...skipping 25 matching lines...) Expand all Loading... | |
124 WebUIMojoContextState* state = GetContextState(); | 128 WebUIMojoContextState* state = GetContextState(); |
125 if (state && !state->module_added()) | 129 if (state && !state->module_added()) |
126 return; | 130 return; |
127 | 131 |
128 v8::HandleScope handle_scope(blink::mainThreadIsolate()); | 132 v8::HandleScope handle_scope(blink::mainThreadIsolate()); |
129 DestroyContextState(frame->mainWorldScriptContext()); | 133 DestroyContextState(frame->mainWorldScriptContext()); |
130 CreateContextState(); | 134 CreateContextState(); |
131 } | 135 } |
132 | 136 |
133 } // namespace content | 137 } // namespace content |
OLD | NEW |