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