| 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_view.h" | 12 #include "content/public/renderer/render_view.h" |
| 13 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
| 14 #include "extensions/common/guest_view/guest_view_messages.h" | 14 #include "extensions/common/guest_view/extensions_guest_view_messages.h" |
| 15 #include "extensions/common/permissions/permissions_data.h" | 15 #include "extensions/common/permissions/permissions_data.h" |
| 16 #include "extensions/renderer/injection_host.h" | 16 #include "extensions/renderer/injection_host.h" |
| 17 #include "extensions/renderer/script_context.h" | 17 #include "extensions/renderer/script_context.h" |
| 18 #include "extensions/renderer/scripts_run_info.h" | 18 #include "extensions/renderer/scripts_run_info.h" |
| 19 #include "grit/extensions_renderer_resources.h" | 19 #include "grit/extensions_renderer_resources.h" |
| 20 #include "third_party/WebKit/public/web/WebDocument.h" | 20 #include "third_party/WebKit/public/web/WebDocument.h" |
| 21 #include "third_party/WebKit/public/web/WebFrame.h" | 21 #include "third_party/WebKit/public/web/WebFrame.h" |
| 22 #include "third_party/WebKit/public/web/WebScriptSource.h" | 22 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 bool allowed = false; | 178 bool allowed = false; |
| 179 if (iter != map.end()) { | 179 if (iter != map.end()) { |
| 180 allowed = iter->second; | 180 allowed = iter->second; |
| 181 } else { | 181 } else { |
| 182 // Send a SYNC IPC message to the browser to check if this is allowed. This | 182 // Send a SYNC IPC message to the browser to check if this is allowed. This |
| 183 // is not ideal, but is mitigated by the fact that this is only done for | 183 // is not ideal, but is mitigated by the fact that this is only done for |
| 184 // webviews, and then only once per host. | 184 // webviews, and then only once per host. |
| 185 // TODO(hanxi): Find a more efficient way to do this. | 185 // TODO(hanxi): Find a more efficient way to do this. |
| 186 content::RenderThread::Get()->Send( | 186 content::RenderThread::Get()->Send( |
| 187 new GuestViewHostMsg_CanExecuteContentScriptSync( | 187 new ExtensionsGuestViewHostMsg_CanExecuteContentScriptSync( |
| 188 routing_id, script_->id(), &allowed)); | 188 routing_id, script_->id(), &allowed)); |
| 189 map.insert(std::pair<RoutingInfoKey, bool>(key, allowed)); | 189 map.insert(std::pair<RoutingInfoKey, bool>(key, allowed)); |
| 190 } | 190 } |
| 191 | 191 |
| 192 return allowed ? PermissionsData::ACCESS_ALLOWED | 192 return allowed ? PermissionsData::ACCESS_ALLOWED |
| 193 : PermissionsData::ACCESS_DENIED; | 193 : PermissionsData::ACCESS_DENIED; |
| 194 } | 194 } |
| 195 | 195 |
| 196 std::vector<blink::WebScriptSource> UserScriptInjector::GetJsSources( | 196 std::vector<blink::WebScriptSource> UserScriptInjector::GetJsSources( |
| 197 UserScript::RunLocation run_location) const { | 197 UserScript::RunLocation run_location) const { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 261 |
| 262 void UserScriptInjector::OnInjectionComplete( | 262 void UserScriptInjector::OnInjectionComplete( |
| 263 scoped_ptr<base::ListValue> execution_results, | 263 scoped_ptr<base::ListValue> execution_results, |
| 264 UserScript::RunLocation run_location) { | 264 UserScript::RunLocation run_location) { |
| 265 } | 265 } |
| 266 | 266 |
| 267 void UserScriptInjector::OnWillNotInject(InjectFailureReason reason) { | 267 void UserScriptInjector::OnWillNotInject(InjectFailureReason reason) { |
| 268 } | 268 } |
| 269 | 269 |
| 270 } // namespace extensions | 270 } // namespace extensions |
| OLD | NEW |