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 "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/common/extensions/extension_action.h" | 10 #include "chrome/common/extensions/extension_action.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 if (!args[0]->IsInt32()) | 66 if (!args[0]->IsInt32()) |
67 return v8::Undefined(); | 67 return v8::Undefined(); |
68 | 68 |
69 int view_id = args[0]->Int32Value(); | 69 int view_id = args[0]->Int32Value(); |
70 | 70 |
71 if (view_id == MSG_ROUTING_NONE) | 71 if (view_id == MSG_ROUTING_NONE) |
72 return v8::Undefined(); | 72 return v8::Undefined(); |
73 | 73 |
74 // TODO(jeremya): there exists a direct map of routing_id -> RenderView as | 74 // TODO(jeremya): there exists a direct map of routing_id -> RenderView as |
75 // ChildThread::current()->ResolveRoute(), but ResolveRoute returns an | 75 // ChildThread::current()->ResolveRoute(), but ResolveRoute returns an |
76 // IPC::Channel::Listener*, which RenderView doesn't inherit from | 76 // IPC::Listener*, which RenderView doesn't inherit from (RenderViewImpl |
77 // (RenderViewImpl does, indirectly, via RenderWidget, but the link isn't | 77 // does, indirectly, via RenderWidget, but the link isn't exposed outside of |
78 // exposed outside of content/.) | 78 // content/.) |
79 FindViewByID view_finder(view_id); | 79 FindViewByID view_finder(view_id); |
80 content::RenderView::ForEach(&view_finder); | 80 content::RenderView::ForEach(&view_finder); |
81 content::RenderView* view = view_finder.view(); | 81 content::RenderView* view = view_finder.view(); |
82 if (!view) | 82 if (!view) |
83 return v8::Undefined(); | 83 return v8::Undefined(); |
84 | 84 |
85 // TODO(jeremya): it doesn't really make sense to set the opener here, but we | 85 // TODO(jeremya): it doesn't really make sense to set the opener here, but we |
86 // need to make sure the security origin is set up before returning the DOM | 86 // need to make sure the security origin is set up before returning the DOM |
87 // reference. A better way to do this would be to have the browser pass the | 87 // reference. A better way to do this would be to have the browser pass the |
88 // opener through so opener_id is set in RenderViewImpl's constructor. | 88 // opener through so opener_id is set in RenderViewImpl's constructor. |
89 content::RenderView* render_view = GetCurrentRenderView(); | 89 content::RenderView* render_view = GetCurrentRenderView(); |
90 if (!render_view) | 90 if (!render_view) |
91 return v8::Undefined(); | 91 return v8::Undefined(); |
92 WebKit::WebFrame* opener = render_view->GetWebView()->mainFrame(); | 92 WebKit::WebFrame* opener = render_view->GetWebView()->mainFrame(); |
93 WebKit::WebFrame* frame = view->GetWebView()->mainFrame(); | 93 WebKit::WebFrame* frame = view->GetWebView()->mainFrame(); |
94 frame->setOpener(opener); | 94 frame->setOpener(opener); |
95 | 95 |
96 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); | 96 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); |
97 return window; | 97 return window; |
98 } | 98 } |
99 | 99 |
100 } // namespace extensions | 100 } // namespace extensions |
OLD | NEW |