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

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

Issue 2257273002: Fix extension bindings injection for iframes (reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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 | « extensions/renderer/script_context.cc ('k') | 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/script_context_set.h" 5 #include "extensions/renderer/script_context_set.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "content/public/common/url_constants.h" 10 #include "content/public/common/url_constants.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 const Extension* ScriptContextSet::GetExtensionFromFrameAndWorld( 134 const Extension* ScriptContextSet::GetExtensionFromFrameAndWorld(
135 const blink::WebLocalFrame* frame, 135 const blink::WebLocalFrame* frame,
136 int world_id, 136 int world_id,
137 bool use_effective_url) { 137 bool use_effective_url) {
138 std::string extension_id; 138 std::string extension_id;
139 if (world_id != 0) { 139 if (world_id != 0) {
140 // Isolated worlds (content script). 140 // Isolated worlds (content script).
141 extension_id = ScriptInjection::GetHostIdForIsolatedWorld(world_id); 141 extension_id = ScriptInjection::GetHostIdForIsolatedWorld(world_id);
142 } else { 142 } else {
143 // Extension pages (chrome-extension:// URLs). 143 // For looking up the extension associated with this frame, we either want
144 GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame); 144 // to use the current url or possibly the data source url (which this frame
145 // may be navigating to shortly), depending on the security origin of the
146 // frame. We don't always want to use the data source url because some
147 // frames (eg iframes and windows created via window.open) briefly contain
148 // an about:blank script context that is scriptable by their parent/opener
149 // before they finish navigating.
150 GURL frame_url = ScriptContext::GetAccessCheckedFrameURL(frame);
145 frame_url = ScriptContext::GetEffectiveDocumentURL(frame, frame_url, 151 frame_url = ScriptContext::GetEffectiveDocumentURL(frame, frame_url,
146 use_effective_url); 152 use_effective_url);
147 extension_id = 153 extension_id =
148 RendererExtensionRegistry::Get()->GetExtensionOrAppIDByURL(frame_url); 154 RendererExtensionRegistry::Get()->GetExtensionOrAppIDByURL(frame_url);
149 } 155 }
150 156
151 // There are conditions where despite a context being associated with an 157 // There are conditions where despite a context being associated with an
152 // extension, no extension actually gets found. Ignore "invalid" because CSP 158 // extension, no extension actually gets found. Ignore "invalid" because CSP
153 // blocks extension page loading by switching the extension ID to "invalid". 159 // blocks extension page loading by switching the extension ID to "invalid".
154 const Extension* extension = 160 const Extension* extension =
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return Feature::WEB_PAGE_CONTEXT; 222 return Feature::WEB_PAGE_CONTEXT;
217 } 223 }
218 224
219 void ScriptContextSet::RecordAndRemove(std::set<ScriptContext*>* removed, 225 void ScriptContextSet::RecordAndRemove(std::set<ScriptContext*>* removed,
220 ScriptContext* context) { 226 ScriptContext* context) {
221 removed->insert(context); 227 removed->insert(context);
222 Remove(context); // Note: context deletion is deferred to the message loop. 228 Remove(context); // Note: context deletion is deferred to the message loop.
223 } 229 }
224 230
225 } // namespace extensions 231 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/script_context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698