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