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