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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // URL, but to decide whether to inject a content script, we use the URL from | 307 // URL, but to decide whether to inject a content script, we use the URL from |
308 // the data source. This "quirk" helps prevents content scripts from | 308 // the data source. This "quirk" helps prevents content scripts from |
309 // inadvertently adding DOM elements to the compose iframe in Gmail because | 309 // inadvertently adding DOM elements to the compose iframe in Gmail because |
310 // the compose iframe's dataSource URL is about:blank, but the document URL | 310 // the compose iframe's dataSource URL is about:blank, but the document URL |
311 // changes to match the parent document after Gmail document.writes into | 311 // changes to match the parent document after Gmail document.writes into |
312 // it to create the editor. | 312 // it to create the editor. |
313 // http://code.google.com/p/chromium/issues/detail?id=86742 | 313 // http://code.google.com/p/chromium/issues/detail?id=86742 |
314 blink::WebDataSource* data_source = frame->provisionalDataSource() | 314 blink::WebDataSource* data_source = frame->provisionalDataSource() |
315 ? frame->provisionalDataSource() | 315 ? frame->provisionalDataSource() |
316 : frame->dataSource(); | 316 : frame->dataSource(); |
317 return data_source ? GURL(data_source->request().url()) : GURL(); | 317 return data_source ? GURL(data_source->getRequest().url()) : GURL(); |
318 } | 318 } |
319 | 319 |
320 // static | 320 // static |
321 GURL ScriptContext::GetAccessCheckedFrameURL(const blink::WebFrame* frame) { | 321 GURL ScriptContext::GetAccessCheckedFrameURL(const blink::WebFrame* frame) { |
322 const blink::WebURL& weburl = frame->document().url(); | 322 const blink::WebURL& weburl = frame->document().url(); |
323 if (weburl.isEmpty()) { | 323 if (weburl.isEmpty()) { |
324 blink::WebDataSource* data_source = frame->provisionalDataSource() | 324 blink::WebDataSource* data_source = frame->provisionalDataSource() |
325 ? frame->provisionalDataSource() | 325 ? frame->provisionalDataSource() |
326 : frame->dataSource(); | 326 : frame->dataSource(); |
327 if (data_source && | 327 if (data_source && |
328 frame->getSecurityOrigin().canAccess( | 328 frame->getSecurityOrigin().canAccess(blink::WebSecurityOrigin::create( |
329 blink::WebSecurityOrigin::create(data_source->request().url()))) { | 329 data_source->getRequest().url()))) { |
330 return GURL(data_source->request().url()); | 330 return GURL(data_source->getRequest().url()); |
331 } | 331 } |
332 } | 332 } |
333 return GURL(weburl); | 333 return GURL(weburl); |
334 } | 334 } |
335 | 335 |
336 // static | 336 // static |
337 GURL ScriptContext::GetEffectiveDocumentURL(const blink::WebFrame* frame, | 337 GURL ScriptContext::GetEffectiveDocumentURL(const blink::WebFrame* frame, |
338 const GURL& document_url, | 338 const GURL& document_url, |
339 bool match_about_blank) { | 339 bool match_about_blank) { |
340 // Common scenario. If |match_about_blank| is false (as is the case in most | 340 // Common scenario. If |match_about_blank| is false (as is the case in most |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 v8::Local<v8::Value> argv[]) { | 538 v8::Local<v8::Value> argv[]) { |
539 return context_->CallFunction(function, argc, argv); | 539 return context_->CallFunction(function, argc, argv); |
540 } | 540 } |
541 | 541 |
542 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { | 542 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { |
543 v8::HandleScope handle_scope(context_->isolate()); | 543 v8::HandleScope handle_scope(context_->isolate()); |
544 return gin::PerContextData::From(context_->v8_context())->context_holder(); | 544 return gin::PerContextData::From(context_->v8_context())->context_holder(); |
545 } | 545 } |
546 | 546 |
547 } // namespace extensions | 547 } // namespace extensions |
OLD | NEW |