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

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

Issue 444503002: Start using RenderFrameProxyHost objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create view IFF frame is main frame Created 6 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 | « content/renderer/render_view_impl.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.h" 5 #include "extensions/renderer/script_context.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // |document_url| (supposedly the URL of the frame). 181 // |document_url| (supposedly the URL of the frame).
182 if (!match_about_blank || !document_url.SchemeIs(url::kAboutScheme)) 182 if (!match_about_blank || !document_url.SchemeIs(url::kAboutScheme))
183 return document_url; 183 return document_url;
184 184
185 // Non-sandboxed about:blank and about:srcdoc pages inherit their security 185 // Non-sandboxed about:blank and about:srcdoc pages inherit their security
186 // origin from their parent frame/window. So, traverse the frame/window 186 // origin from their parent frame/window. So, traverse the frame/window
187 // hierarchy to find the closest non-about:-page and return its URL. 187 // hierarchy to find the closest non-about:-page and return its URL.
188 const blink::WebFrame* parent = frame; 188 const blink::WebFrame* parent = frame;
189 do { 189 do {
190 parent = parent->parent() ? parent->parent() : parent->opener(); 190 parent = parent->parent() ? parent->parent() : parent->opener();
191 } while (parent != NULL && 191 } while (parent != NULL && !parent->document().isNull() &&
192 GURL(parent->document().url()).SchemeIs(url::kAboutScheme)); 192 GURL(parent->document().url()).SchemeIs(url::kAboutScheme));
193 193
194 if (parent) { 194 if (parent && !parent->document().isNull()) {
195 // Only return the parent URL if the frame can access it. 195 // Only return the parent URL if the frame can access it.
196 const blink::WebDocument& parent_document = parent->document(); 196 const blink::WebDocument& parent_document = parent->document();
197 if (frame->document().securityOrigin().canAccess( 197 if (frame->document().securityOrigin().canAccess(
198 parent_document.securityOrigin())) 198 parent_document.securityOrigin()))
199 return parent_document.url(); 199 return parent_document.url();
200 } 200 }
201 return document_url; 201 return document_url;
202 } 202 }
203 203
204 ScriptContext* ScriptContext::GetContext() { return this; } 204 ScriptContext* ScriptContext::GetContext() { return this; }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 v8::Handle<v8::Value> argv[]) { 238 v8::Handle<v8::Value> argv[]) {
239 return CallFunction(function, argc, argv); 239 return CallFunction(function, argc, argv);
240 } 240 }
241 241
242 gin::ContextHolder* ScriptContext::GetContextHolder() { 242 gin::ContextHolder* ScriptContext::GetContextHolder() {
243 v8::HandleScope handle_scope(isolate()); 243 v8::HandleScope handle_scope(isolate());
244 return gin::PerContextData::From(v8_context())->context_holder(); 244 return gin::PerContextData::From(v8_context())->context_holder();
245 } 245 }
246 246
247 } // namespace extensions 247 } // namespace extensions
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698