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