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

Unified Diff: extensions/renderer/script_context.cc

Issue 2208483002: Fix extension bindings injection for iframes (reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add fix and test for bug 630928, and logging to existing test 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 side-by-side diff with in-line comments
Download patch
Index: extensions/renderer/script_context.cc
diff --git a/extensions/renderer/script_context.cc b/extensions/renderer/script_context.cc
index cf6432f8951ca42f6edbfbc58d6663c485318c85..e12de37d304dd1862ad92e5d31b16ee3330744e5 100644
--- a/extensions/renderer/script_context.cc
+++ b/extensions/renderer/script_context.cc
@@ -109,12 +109,24 @@ ScriptContext::ScriptContext(const v8::Local<v8::Context>& v8_context,
effective_context_type_(effective_context_type),
safe_builtins_(this),
isolate_(v8_context->GetIsolate()),
- url_(web_frame_ ? GetDataSourceURLForFrame(web_frame_) : GURL()),
runner_(new Runner(this)) {
VLOG(1) << "Created context:\n" << GetDebugString();
gin::PerContextData* gin_data = gin::PerContextData::From(v8_context);
CHECK(gin_data);
gin_data->set_runner(runner_.get());
+ if (web_frame_) {
+ const blink::WebURL& weburl = web_frame_->document().url();
+ if (weburl.isEmpty()) {
+ blink::WebDataSource* data_source = web_frame_->provisionalDataSource()
+ ? web_frame_->provisionalDataSource()
+ : web_frame_->dataSource();
asargent_no_longer_on_chrome 2016/08/03 00:22:24 Note that there's a little duplication here with t
Devlin 2016/08/03 16:16:49 This also looks very similar to the new logic adde
asargent_no_longer_on_chrome 2016/08/04 05:47:18 Done.
+ if (data_source && web_frame_->getSecurityOrigin().canAccess(
+ blink::WebSecurityOrigin::create(data_source->request().url())))
+ url_ = GURL(data_source->request().url());
+ }
+ if (url_.is_empty())
Devlin 2016/08/03 16:16:49 This can be an else, right? Because we'll only se
asargent_no_longer_on_chrome 2016/08/04 05:47:18 Good point - I guess it doesn't help to assign to
+ url_ = GURL(weburl);
+ }
}
ScriptContext::~ScriptContext() {

Powered by Google App Engine
This is Rietveld 408576698