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

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

Issue 1948773002: Create array of extension views without side effects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
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 "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
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
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