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/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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); | 103 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); |
104 gin::PerContextData* context_data = gin::PerContextData::From(context); | 104 gin::PerContextData* context_data = gin::PerContextData::From(context); |
105 if (!context_data) | 105 if (!context_data) |
106 return NULL; | 106 return NULL; |
107 WebUIMojoContextStateData* context_state = | 107 WebUIMojoContextStateData* context_state = |
108 static_cast<WebUIMojoContextStateData*>( | 108 static_cast<WebUIMojoContextStateData*>( |
109 context_data->GetUserData(kWebUIMojoContextStateKey)); | 109 context_data->GetUserData(kWebUIMojoContextStateKey)); |
110 return context_state ? context_state->state.get() : NULL; | 110 return context_state ? context_state->state.get() : NULL; |
111 } | 111 } |
112 | 112 |
113 void WebUIMojo::DidClearWindowObject(blink::WebLocalFrame* frame, | 113 void WebUIMojo::DidClearWindowObject(blink::WebLocalFrame* frame) { |
114 int world_id) { | |
115 if (frame != render_view()->GetWebView()->mainFrame()) | 114 if (frame != render_view()->GetWebView()->mainFrame()) |
116 return; | 115 return; |
117 | 116 |
118 // NOTE: this function may be called early on twice. From the constructor | 117 // NOTE: this function may be called early on twice. From the constructor |
119 // mainWorldScriptContext() may trigger this to be called. If we are created | 118 // mainWorldScriptContext() may trigger this to be called. If we are created |
120 // before the page is loaded (which is very likely), then on first load this | 119 // before the page is loaded (which is very likely), then on first load this |
121 // is called. In the case of the latter we may have already supplied the | 120 // is called. In the case of the latter we may have already supplied the |
122 // handle to the context state so that if we destroy now the handle is | 121 // handle to the context state so that if we destroy now the handle is |
123 // lost. If this is the result of the first load then the contextstate should | 122 // lost. If this is the result of the first load then the contextstate should |
124 // be empty and we don't need to destroy it. | 123 // be empty and we don't need to destroy it. |
125 WebUIMojoContextState* state = GetContextState(); | 124 WebUIMojoContextState* state = GetContextState(); |
126 if (state && !state->module_added()) | 125 if (state && !state->module_added()) |
127 return; | 126 return; |
128 | 127 |
129 v8::HandleScope handle_scope(blink::mainThreadIsolate()); | 128 v8::HandleScope handle_scope(blink::mainThreadIsolate()); |
130 DestroyContextState(frame->mainWorldScriptContext()); | 129 DestroyContextState(frame->mainWorldScriptContext()); |
131 CreateContextState(); | 130 CreateContextState(); |
132 } | 131 } |
133 | 132 |
134 } // namespace content | 133 } // namespace content |
OLD | NEW |