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

Side by Side 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 unified diff | Download patch
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 <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 Feature::Context effective_context_type) 102 Feature::Context effective_context_type)
103 : is_valid_(true), 103 : is_valid_(true),
104 v8_context_(v8_context->GetIsolate(), v8_context), 104 v8_context_(v8_context->GetIsolate(), v8_context),
105 web_frame_(web_frame), 105 web_frame_(web_frame),
106 extension_(extension), 106 extension_(extension),
107 context_type_(context_type), 107 context_type_(context_type),
108 effective_extension_(effective_extension), 108 effective_extension_(effective_extension),
109 effective_context_type_(effective_context_type), 109 effective_context_type_(effective_context_type),
110 safe_builtins_(this), 110 safe_builtins_(this),
111 isolate_(v8_context->GetIsolate()), 111 isolate_(v8_context->GetIsolate()),
112 url_(web_frame_ ? GetDataSourceURLForFrame(web_frame_) : GURL()),
113 runner_(new Runner(this)) { 112 runner_(new Runner(this)) {
114 VLOG(1) << "Created context:\n" << GetDebugString(); 113 VLOG(1) << "Created context:\n" << GetDebugString();
115 gin::PerContextData* gin_data = gin::PerContextData::From(v8_context); 114 gin::PerContextData* gin_data = gin::PerContextData::From(v8_context);
116 CHECK(gin_data); 115 CHECK(gin_data);
117 gin_data->set_runner(runner_.get()); 116 gin_data->set_runner(runner_.get());
117 if (web_frame_) {
118 const blink::WebURL& weburl = web_frame_->document().url();
119 if (weburl.isEmpty()) {
120 blink::WebDataSource* data_source = web_frame_->provisionalDataSource()
121 ? web_frame_->provisionalDataSource()
122 : 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.
123 if (data_source && web_frame_->getSecurityOrigin().canAccess(
124 blink::WebSecurityOrigin::create(data_source->request().url())))
125 url_ = GURL(data_source->request().url());
126 }
127 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
128 url_ = GURL(weburl);
129 }
118 } 130 }
119 131
120 ScriptContext::~ScriptContext() { 132 ScriptContext::~ScriptContext() {
121 VLOG(1) << "Destroyed context for extension\n" 133 VLOG(1) << "Destroyed context for extension\n"
122 << " extension id: " << GetExtensionID() << "\n" 134 << " extension id: " << GetExtensionID() << "\n"
123 << " effective extension id: " 135 << " effective extension id: "
124 << (effective_extension_.get() ? effective_extension_->id() : ""); 136 << (effective_extension_.get() ? effective_extension_->id() : "");
125 CHECK(!is_valid_) << "ScriptContexts must be invalidated before destruction"; 137 CHECK(!is_valid_) << "ScriptContexts must be invalidated before destruction";
126 } 138 }
127 139
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 v8::Local<v8::Value> argv[]) { 498 v8::Local<v8::Value> argv[]) {
487 return context_->CallFunction(function, argc, argv); 499 return context_->CallFunction(function, argc, argv);
488 } 500 }
489 501
490 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { 502 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() {
491 v8::HandleScope handle_scope(context_->isolate()); 503 v8::HandleScope handle_scope(context_->isolate());
492 return gin::PerContextData::From(context_->v8_context())->context_holder(); 504 return gin::PerContextData::From(context_->v8_context())->context_holder();
493 } 505 }
494 506
495 } // namespace extensions 507 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698