OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/extensions/app_window_custom_bindings.h" | 5 #include "chrome/renderer/extensions/app_window_custom_bindings.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "chrome/common/extensions/extension_messages.h" | 9 #include "chrome/common/extensions/extension_messages.h" |
10 #include "chrome/renderer/extensions/chrome_v8_context.h" | 10 #include "chrome/renderer/extensions/chrome_v8_context.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 return; | 42 return; |
43 v8::Context::Scope context_scope(v8_context->v8_context()); | 43 v8::Context::Scope context_scope(v8_context->v8_context()); |
44 v8_context->module_system()->CallModuleMethod( | 44 v8_context->module_system()->CallModuleMethod( |
45 "injectAppTitlebar", "didCreateDocumentElement"); | 45 "injectAppTitlebar", "didCreateDocumentElement"); |
46 } | 46 } |
47 | 47 |
48 private: | 48 private: |
49 Dispatcher* dispatcher_; | 49 Dispatcher* dispatcher_; |
50 }; | 50 }; |
51 | 51 |
52 AppWindowCustomBindings::AppWindowCustomBindings(Dispatcher* dispatcher) | 52 AppWindowCustomBindings::AppWindowCustomBindings( |
53 : ChromeV8Extension(dispatcher) { | 53 Dispatcher* dispatcher, |
| 54 v8::Handle<v8::Context> context) : ChromeV8Extension(dispatcher, context) { |
54 RouteFunction("GetView", | 55 RouteFunction("GetView", |
55 base::Bind(&AppWindowCustomBindings::GetView, | 56 base::Bind(&AppWindowCustomBindings::GetView, |
56 base::Unretained(this))); | 57 base::Unretained(this))); |
57 RouteFunction("OnContextReady", | 58 RouteFunction("OnContextReady", |
58 base::Bind(&AppWindowCustomBindings::OnContextReady, | 59 base::Bind(&AppWindowCustomBindings::OnContextReady, |
59 base::Unretained(this))); | 60 base::Unretained(this))); |
60 } | 61 } |
61 | 62 |
62 namespace { | 63 namespace { |
63 class LoadWatcher : public content::RenderViewObserver { | 64 class LoadWatcher : public content::RenderViewObserver { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 if (!view) | 152 if (!view) |
152 return v8::Undefined(); | 153 return v8::Undefined(); |
153 | 154 |
154 if (inject_titlebar) | 155 if (inject_titlebar) |
155 new DidCreateDocumentElementObserver(view, dispatcher()); | 156 new DidCreateDocumentElementObserver(view, dispatcher()); |
156 | 157 |
157 // TODO(jeremya): it doesn't really make sense to set the opener here, but we | 158 // TODO(jeremya): it doesn't really make sense to set the opener here, but we |
158 // need to make sure the security origin is set up before returning the DOM | 159 // need to make sure the security origin is set up before returning the DOM |
159 // reference. A better way to do this would be to have the browser pass the | 160 // reference. A better way to do this would be to have the browser pass the |
160 // opener through so opener_id is set in RenderViewImpl's constructor. | 161 // opener through so opener_id is set in RenderViewImpl's constructor. |
161 content::RenderView* render_view = GetCurrentRenderView(); | 162 content::RenderView* render_view = GetRenderView(); |
162 if (!render_view) | 163 if (!render_view) |
163 return v8::Undefined(); | 164 return v8::Undefined(); |
164 WebKit::WebFrame* opener = render_view->GetWebView()->mainFrame(); | 165 WebKit::WebFrame* opener = render_view->GetWebView()->mainFrame(); |
165 WebKit::WebFrame* frame = view->GetWebView()->mainFrame(); | 166 WebKit::WebFrame* frame = view->GetWebView()->mainFrame(); |
166 frame->setOpener(opener); | 167 frame->setOpener(opener); |
167 content::RenderThread::Get()->Send( | 168 content::RenderThread::Get()->Send( |
168 new ExtensionHostMsg_ResumeRequests(view->GetRoutingID())); | 169 new ExtensionHostMsg_ResumeRequests(view->GetRoutingID())); |
169 | 170 |
170 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); | 171 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); |
171 return window; | 172 return window; |
172 } | 173 } |
173 | 174 |
174 } // namespace extensions | 175 } // namespace extensions |
OLD | NEW |