| 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/user_script_injector.h" | 5 #include "extensions/renderer/user_script_injector.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
| 11 #include "content/public/renderer/render_thread.h" | 11 #include "content/public/renderer/render_thread.h" |
| 12 #include "content/public/renderer/render_frame.h" |
| 12 #include "content/public/renderer/render_view.h" | 13 #include "content/public/renderer/render_view.h" |
| 13 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
| 14 #include "extensions/common/guest_view/extensions_guest_view_messages.h" | 15 #include "extensions/common/guest_view/extensions_guest_view_messages.h" |
| 15 #include "extensions/common/permissions/permissions_data.h" | 16 #include "extensions/common/permissions/permissions_data.h" |
| 16 #include "extensions/renderer/injection_host.h" | 17 #include "extensions/renderer/injection_host.h" |
| 17 #include "extensions/renderer/script_context.h" | 18 #include "extensions/renderer/script_context.h" |
| 18 #include "extensions/renderer/scripts_run_info.h" | 19 #include "extensions/renderer/scripts_run_info.h" |
| 19 #include "grit/extensions_renderer_resources.h" | 20 #include "grit/extensions_renderer_resources.h" |
| 20 #include "third_party/WebKit/public/web/WebDocument.h" | 21 #include "third_party/WebKit/public/web/WebDocument.h" |
| 21 #include "third_party/WebKit/public/web/WebFrame.h" | 22 #include "third_party/WebKit/public/web/WebFrame.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 146 |
| 146 bool UserScriptInjector::ShouldInjectCss( | 147 bool UserScriptInjector::ShouldInjectCss( |
| 147 UserScript::RunLocation run_location) const { | 148 UserScript::RunLocation run_location) const { |
| 148 return run_location == UserScript::DOCUMENT_START && | 149 return run_location == UserScript::DOCUMENT_START && |
| 149 !script_->css_scripts().empty(); | 150 !script_->css_scripts().empty(); |
| 150 } | 151 } |
| 151 | 152 |
| 152 PermissionsData::AccessType UserScriptInjector::CanExecuteOnFrame( | 153 PermissionsData::AccessType UserScriptInjector::CanExecuteOnFrame( |
| 153 const InjectionHost* injection_host, | 154 const InjectionHost* injection_host, |
| 154 blink::WebFrame* web_frame, | 155 blink::WebFrame* web_frame, |
| 155 int tab_id, | 156 int tab_id) const { |
| 156 const GURL& top_url) const { | |
| 157 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( | 157 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( |
| 158 web_frame, web_frame->document().url(), script_->match_about_blank()); | 158 web_frame, web_frame->document().url(), script_->match_about_blank()); |
| 159 PermissionsData::AccessType can_execute = injection_host->CanExecuteOnFrame( | 159 PermissionsData::AccessType can_execute = injection_host->CanExecuteOnFrame( |
| 160 effective_document_url, top_url, tab_id, is_declarative_); | 160 effective_document_url, |
| 161 content::RenderFrame::FromWebFrame(web_frame), |
| 162 tab_id, |
| 163 is_declarative_); |
| 161 if (script_->consumer_instance_type() != | 164 if (script_->consumer_instance_type() != |
| 162 UserScript::ConsumerInstanceType::WEBVIEW || | 165 UserScript::ConsumerInstanceType::WEBVIEW || |
| 163 can_execute == PermissionsData::ACCESS_DENIED) | 166 can_execute == PermissionsData::ACCESS_DENIED) |
| 164 return can_execute; | 167 return can_execute; |
| 165 | 168 |
| 166 int routing_id = content::RenderView::FromWebView(web_frame->top()->view()) | 169 int routing_id = content::RenderView::FromWebView(web_frame->top()->view()) |
| 167 ->GetRoutingID(); | 170 ->GetRoutingID(); |
| 168 | 171 |
| 169 RoutingInfoKey key(routing_id, script_->id()); | 172 RoutingInfoKey key(routing_id, script_->id()); |
| 170 | 173 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 260 |
| 258 void UserScriptInjector::OnInjectionComplete( | 261 void UserScriptInjector::OnInjectionComplete( |
| 259 scoped_ptr<base::Value> execution_result, | 262 scoped_ptr<base::Value> execution_result, |
| 260 UserScript::RunLocation run_location) { | 263 UserScript::RunLocation run_location) { |
| 261 } | 264 } |
| 262 | 265 |
| 263 void UserScriptInjector::OnWillNotInject(InjectFailureReason reason) { | 266 void UserScriptInjector::OnWillNotInject(InjectFailureReason reason) { |
| 264 } | 267 } |
| 265 | 268 |
| 266 } // namespace extensions | 269 } // namespace extensions |
| OLD | NEW |