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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 ExtensionFrameHelper::GetExtensionFrames(extension_id, browser_window_id, | 87 ExtensionFrameHelper::GetExtensionFrames(extension_id, browser_window_id, |
88 tab_id, view_type); | 88 tab_id, view_type); |
89 v8::Local<v8::Context> v8_context = args.GetIsolate()->GetCurrentContext(); | 89 v8::Local<v8::Context> v8_context = args.GetIsolate()->GetCurrentContext(); |
90 v8::Local<v8::Array> v8_views = v8::Array::New(args.GetIsolate()); | 90 v8::Local<v8::Array> v8_views = v8::Array::New(args.GetIsolate()); |
91 int v8_index = 0; | 91 int v8_index = 0; |
92 for (content::RenderFrame* frame : frames) { | 92 for (content::RenderFrame* frame : frames) { |
93 // We filter out iframes here. GetExtensionViews should only return the | 93 // We filter out iframes here. GetExtensionViews should only return the |
94 // main views, not any subframes. (Returning subframes can cause broken | 94 // main views, not any subframes. (Returning subframes can cause broken |
95 // behavior by treating an app window's iframe as its main frame, and maybe | 95 // behavior by treating an app window's iframe as its main frame, and maybe |
96 // other nastiness). | 96 // other nastiness). |
97 blink::WebFrame* web_frame = frame->GetWebFrame(); | 97 blink::WebLocalFrame* web_frame = frame->GetWebFrame(); |
98 if (web_frame->Top() != web_frame) | 98 if (web_frame->Top() != web_frame) |
99 continue; | 99 continue; |
100 | 100 |
101 if (!blink::WebFrame::ScriptCanAccess(web_frame)) | 101 if (!blink::WebFrame::ScriptCanAccess(web_frame)) |
102 continue; | 102 continue; |
103 | 103 |
104 v8::Local<v8::Context> context = web_frame->MainWorldScriptContext(); | 104 v8::Local<v8::Context> context = web_frame->MainWorldScriptContext(); |
105 if (!context.IsEmpty()) { | 105 if (!context.IsEmpty()) { |
106 v8::Local<v8::Value> window = context->Global(); | 106 v8::Local<v8::Value> window = context->Global(); |
107 CHECK(!window.IsEmpty()); | 107 CHECK(!window.IsEmpty()); |
108 v8::Maybe<bool> maybe = | 108 v8::Maybe<bool> maybe = |
109 v8_views->CreateDataProperty(v8_context, v8_index++, window); | 109 v8_views->CreateDataProperty(v8_context, v8_index++, window); |
110 CHECK(maybe.IsJust() && maybe.FromJust()); | 110 CHECK(maybe.IsJust() && maybe.FromJust()); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 args.GetReturnValue().Set(v8_views); | 114 args.GetReturnValue().Set(v8_views); |
115 } | 115 } |
116 | 116 |
117 } // namespace extensions | 117 } // namespace extensions |
OLD | NEW |