| 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/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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |