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

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

Issue 1150683007: [Extensions] Use document url (not top url) for tab-specific permissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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_injection.h" 5 #include "extensions/renderer/script_injection.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // We're waiting for permission right now, try again later. 129 // We're waiting for permission right now, try again later.
130 return INJECTION_WAITING; 130 return INJECTION_WAITING;
131 } 131 }
132 132
133 if (!injection_host_) { 133 if (!injection_host_) {
134 NotifyWillNotInject(ScriptInjector::EXTENSION_REMOVED); 134 NotifyWillNotInject(ScriptInjector::EXTENSION_REMOVED);
135 return INJECTION_FINISHED; // We're done. 135 return INJECTION_FINISHED; // We're done.
136 } 136 }
137 137
138 switch (injector_->CanExecuteOnFrame( 138 switch (injector_->CanExecuteOnFrame(
139 injection_host_.get(), web_frame_, tab_id_, 139 injection_host_.get(), web_frame_, tab_id_)) {
140 web_frame_->top()->document().url())) {
141 case PermissionsData::ACCESS_DENIED: 140 case PermissionsData::ACCESS_DENIED:
142 NotifyWillNotInject(ScriptInjector::NOT_ALLOWED); 141 NotifyWillNotInject(ScriptInjector::NOT_ALLOWED);
143 return INJECTION_FINISHED; // We're done. 142 return INJECTION_FINISHED; // We're done.
144 case PermissionsData::ACCESS_WITHHELD: 143 case PermissionsData::ACCESS_WITHHELD:
145 // Note: we don't consider ACCESS_WITHHELD for child frames because there 144 // Note: we don't consider ACCESS_WITHHELD for child frames because there
146 // is nowhere to surface a request for a child frame. 145 // is nowhere to surface a request for a child frame.
147 // TODO(devlin): We should ask for permission somehow. crbug.com/491402. 146 // TODO(devlin): We should ask for permission somehow. crbug.com/491402.
148 if (web_frame_->parent()) { 147 if (web_frame_->parent()) {
149 NotifyWillNotInject(ScriptInjector::NOT_ALLOWED); 148 NotifyWillNotInject(ScriptInjector::NOT_ALLOWED);
150 return INJECTION_FINISHED; 149 return INJECTION_FINISHED;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 298 }
300 299
301 void ScriptInjection::InjectCss(blink::WebLocalFrame* frame) { 300 void ScriptInjection::InjectCss(blink::WebLocalFrame* frame) {
302 std::vector<std::string> css_sources = 301 std::vector<std::string> css_sources =
303 injector_->GetCssSources(run_location_); 302 injector_->GetCssSources(run_location_);
304 for (const std::string& css : css_sources) 303 for (const std::string& css : css_sources)
305 frame->document().insertStyleSheet(blink::WebString::fromUTF8(css)); 304 frame->document().insertStyleSheet(blink::WebString::fromUTF8(css));
306 } 305 }
307 306
308 } // namespace extensions 307 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/programmatic_script_injector.cc ('k') | extensions/renderer/script_injector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698