OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extension_process_bindings.h" | 5 #include "chrome/renderer/extensions/extension_process_bindings.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 if (!ViewTypeMatches(render_view->view_type(), view_type_)) | 140 if (!ViewTypeMatches(render_view->view_type(), view_type_)) |
141 return true; | 141 return true; |
142 | 142 |
143 GURL url = render_view->webview()->mainFrame()->url(); | 143 GURL url = render_view->webview()->mainFrame()->url(); |
144 if (!url.SchemeIs(chrome::kExtensionScheme)) | 144 if (!url.SchemeIs(chrome::kExtensionScheme)) |
145 return true; | 145 return true; |
146 const std::string& extension_id = url.host(); | 146 const std::string& extension_id = url.host(); |
147 if (extension_id != extension_id_) | 147 if (extension_id != extension_id_) |
148 return true; | 148 return true; |
149 | 149 |
150 if (browser_window_id_ != -1 && | 150 // If we are searching for a pop-up, it may be the case that the pop-up |
151 render_view->browser_window_id() != browser_window_id_) | 151 // is not attached to a browser window instance. (It is hosted in a |
152 return true; | 152 // ExternalTabContainer.) If so, then bypass validation of |
| 153 // same-browser-window origin. |
| 154 // TODO(twiz): The browser window id of the views visited should always |
| 155 // match that of the arguments to the accumulator. |
| 156 // See bug: http://crbug.com/29646 |
| 157 if (!(view_type_ == ViewType::EXTENSION_POPUP && |
| 158 render_view->browser_window_id() == -1)) { |
| 159 if (browser_window_id_ != -1 && |
| 160 render_view->browser_window_id() != browser_window_id_) { |
| 161 return true; |
| 162 } |
| 163 } |
153 | 164 |
154 v8::Local<v8::Context> context = | 165 v8::Local<v8::Context> context = |
155 render_view->webview()->mainFrame()->mainWorldScriptContext(); | 166 render_view->webview()->mainFrame()->mainWorldScriptContext(); |
156 if (!context.IsEmpty()) { | 167 if (!context.IsEmpty()) { |
157 v8::Local<v8::Value> window = context->Global(); | 168 v8::Local<v8::Value> window = context->Global(); |
158 DCHECK(!window.IsEmpty()); | 169 DCHECK(!window.IsEmpty()); |
159 | 170 |
160 if (!OnMatchedView(window)) | 171 if (!OnMatchedView(window)) |
161 return false; | 172 return false; |
162 } | 173 } |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 return; | 725 return; |
715 | 726 |
716 v8::HandleScope handle_scope; | 727 v8::HandleScope handle_scope; |
717 WebFrame* frame = view->mainFrame(); | 728 WebFrame* frame = view->mainFrame(); |
718 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); | 729 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
719 v8::Handle<v8::Value> argv[1]; | 730 v8::Handle<v8::Value> argv[1]; |
720 argv[0] = v8::String::New(type_str); | 731 argv[0] = v8::String::New(type_str); |
721 bindings_utils::CallFunctionInContext(context, "setViewType", | 732 bindings_utils::CallFunctionInContext(context, "setViewType", |
722 arraysize(argv), argv); | 733 arraysize(argv), argv); |
723 } | 734 } |
OLD | NEW |