Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: extensions/renderer/runtime_custom_bindings.cc

Issue 1935953002: Create array of extension views without side effects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698