Chromium Code Reviews| 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_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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 return INJECTION_FINISHED; // We're done. | 133 return INJECTION_FINISHED; // We're done. |
| 134 } | 134 } |
| 135 | 135 |
| 136 blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame(); | 136 blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame(); |
| 137 switch (injector_->CanExecuteOnFrame( | 137 switch (injector_->CanExecuteOnFrame( |
| 138 injection_host_.get(), web_frame, tab_id_)) { | 138 injection_host_.get(), web_frame, tab_id_)) { |
| 139 case PermissionsData::ACCESS_DENIED: | 139 case PermissionsData::ACCESS_DENIED: |
| 140 NotifyWillNotInject(ScriptInjector::NOT_ALLOWED); | 140 NotifyWillNotInject(ScriptInjector::NOT_ALLOWED); |
| 141 return INJECTION_FINISHED; // We're done. | 141 return INJECTION_FINISHED; // We're done. |
| 142 case PermissionsData::ACCESS_WITHHELD: | 142 case PermissionsData::ACCESS_WITHHELD: |
| 143 // Note: we don't consider ACCESS_WITHHELD for child frames because there | |
| 144 // is nowhere to surface a request for a child frame. | |
| 145 // TODO(devlin): We should ask for permission somehow. crbug.com/491402. | |
| 146 if (web_frame->parent()) { | |
| 147 NotifyWillNotInject(ScriptInjector::NOT_ALLOWED); | |
| 148 return INJECTION_FINISHED; | |
| 149 } | |
| 150 | |
| 151 SendInjectionMessage(true /* request permission */); | 143 SendInjectionMessage(true /* request permission */); |
|
not at google - send to devlin
2015/09/11 22:46:39
This change means that you're always going to be s
Devlin
2015/09/11 22:55:02
Nope, because the logic to choose allowed or not a
not at google - send to devlin
2015/09/11 23:09:49
I see. I read these methods in reverse.
| |
| 152 return INJECTION_WAITING; // Wait around for permission. | 144 return INJECTION_WAITING; // Wait around for permission. |
| 153 case PermissionsData::ACCESS_ALLOWED: | 145 case PermissionsData::ACCESS_ALLOWED: |
| 154 InjectionResult result = Inject(scripts_run_info); | 146 InjectionResult result = Inject(scripts_run_info); |
| 155 // If the injection is blocked, we need to set the manager so we can | 147 // If the injection is blocked, we need to set the manager so we can |
| 156 // notify it upon completion. | 148 // notify it upon completion. |
| 157 if (result == INJECTION_BLOCKED) | 149 if (result == INJECTION_BLOCKED) |
| 158 async_completion_callback_ = async_completion_callback; | 150 async_completion_callback_ = async_completion_callback; |
| 159 return result; | 151 return result; |
| 160 } | 152 } |
| 161 | 153 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 | 291 |
| 300 void ScriptInjection::InjectCss() { | 292 void ScriptInjection::InjectCss() { |
| 301 std::vector<std::string> css_sources = | 293 std::vector<std::string> css_sources = |
| 302 injector_->GetCssSources(run_location_); | 294 injector_->GetCssSources(run_location_); |
| 303 blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame(); | 295 blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame(); |
| 304 for (const std::string& css : css_sources) | 296 for (const std::string& css : css_sources) |
| 305 web_frame->document().insertStyleSheet(blink::WebString::fromUTF8(css)); | 297 web_frame->document().insertStyleSheet(blink::WebString::fromUTF8(css)); |
| 306 } | 298 } |
| 307 | 299 |
| 308 } // namespace extensions | 300 } // namespace extensions |
| OLD | NEW |