OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/runtime_custom_bindings.h" | 5 #include "extensions/renderer/runtime_custom_bindings.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 return; | 150 return; |
151 } | 151 } |
152 | 152 |
153 std::string extension_id = context()->GetExtensionID(); | 153 std::string extension_id = context()->GetExtensionID(); |
154 if (extension_id.empty()) | 154 if (extension_id.empty()) |
155 return; | 155 return; |
156 | 156 |
157 std::vector<content::RenderFrame*> frames = | 157 std::vector<content::RenderFrame*> frames = |
158 ExtensionFrameHelper::GetExtensionFrames(extension_id, browser_window_id, | 158 ExtensionFrameHelper::GetExtensionFrames(extension_id, browser_window_id, |
159 view_type); | 159 view_type); |
| 160 v8::Local<v8::Context> v8_context = args.GetIsolate()->GetCurrentContext(); |
160 v8::Local<v8::Array> v8_views = v8::Array::New(args.GetIsolate()); | 161 v8::Local<v8::Array> v8_views = v8::Array::New(args.GetIsolate()); |
161 int v8_index = 0; | 162 int v8_index = 0; |
162 for (content::RenderFrame* frame : frames) { | 163 for (content::RenderFrame* frame : frames) { |
163 // We filter out iframes here. GetExtensionViews should only return the | 164 // We filter out iframes here. GetExtensionViews should only return the |
164 // main views, not any subframes. (Returning subframes can cause broken | 165 // main views, not any subframes. (Returning subframes can cause broken |
165 // behavior by treating an app window's iframe as its main frame, and maybe | 166 // behavior by treating an app window's iframe as its main frame, and maybe |
166 // other nastiness). | 167 // other nastiness). |
167 if (frame->GetWebFrame()->top() != frame->GetWebFrame()) | 168 if (frame->GetWebFrame()->top() != frame->GetWebFrame()) |
168 continue; | 169 continue; |
169 | 170 |
170 v8::Local<v8::Context> context = | 171 v8::Local<v8::Context> context = |
171 frame->GetWebFrame()->mainWorldScriptContext(); | 172 frame->GetWebFrame()->mainWorldScriptContext(); |
172 if (!context.IsEmpty()) { | 173 if (!context.IsEmpty()) { |
173 v8::Local<v8::Value> window = context->Global(); | 174 v8::Local<v8::Value> window = context->Global(); |
174 DCHECK(!window.IsEmpty()); | 175 DCHECK(!window.IsEmpty()); |
175 v8_views->Set(v8::Integer::New(args.GetIsolate(), v8_index++), window); | 176 v8::Maybe<bool> maybe = |
| 177 v8_views->CreateDataProperty(v8_context, v8_index++, window); |
| 178 DCHECK(maybe.IsJust() && maybe.FromJust()); |
176 } | 179 } |
177 } | 180 } |
178 | 181 |
179 args.GetReturnValue().Set(v8_views); | 182 args.GetReturnValue().Set(v8_views); |
180 } | 183 } |
181 | 184 |
182 } // namespace extensions | 185 } // namespace extensions |
OLD | NEW |