| 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 "chrome/browser/extensions/active_script_controller.h" | 5 #include "chrome/browser/extensions/active_script_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 12 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
| 13 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 13 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 14 #include "chrome/browser/extensions/extension_action.h" | 14 #include "chrome/browser/extensions/extension_action.h" |
| 15 #include "chrome/browser/extensions/extension_action_manager.h" | 15 #include "chrome/browser/extensions/extension_action_manager.h" |
| 16 #include "chrome/browser/extensions/extension_util.h" | |
| 17 #include "chrome/browser/extensions/permissions_updater.h" | 16 #include "chrome/browser/extensions/permissions_updater.h" |
| 18 #include "chrome/browser/extensions/tab_helper.h" | 17 #include "chrome/browser/extensions/tab_helper.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/sessions/session_tab_helper.h" | 19 #include "chrome/browser/sessions/session_tab_helper.h" |
| 21 #include "chrome/common/extensions/api/extension_action/action_info.h" | 20 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 22 #include "components/crx_file/id_util.h" | 21 #include "components/crx_file/id_util.h" |
| 23 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
| 24 #include "content/public/browser/navigation_details.h" | 23 #include "content/public/browser/navigation_details.h" |
| 25 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
| 26 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 ->enabled_extensions().GetByID(extension_id); | 222 ->enabled_extensions().GetByID(extension_id); |
| 224 // We shouldn't allow extensions which are no longer enabled to run any | 223 // We shouldn't allow extensions which are no longer enabled to run any |
| 225 // scripts. Ignore the request. | 224 // scripts. Ignore the request. |
| 226 if (!extension) | 225 if (!extension) |
| 227 return; | 226 return; |
| 228 | 227 |
| 229 // If the request id is -1, that signals that the content script has already | 228 // If the request id is -1, that signals that the content script has already |
| 230 // ran (because this feature is not enabled). Add the extension to the list of | 229 // ran (because this feature is not enabled). Add the extension to the list of |
| 231 // permitted extensions (for metrics), and return immediately. | 230 // permitted extensions (for metrics), and return immediately. |
| 232 if (request_id == -1) { | 231 if (request_id == -1) { |
| 233 if (util::ScriptsMayRequireActionForExtension( | 232 if (PermissionsData::ScriptsMayRequireActionForExtension( |
| 234 extension, | 233 extension, |
| 235 extension->permissions_data()->active_permissions().get())) { | 234 extension->permissions_data()->active_permissions().get())) { |
| 236 permitted_extensions_.insert(extension->id()); | 235 permitted_extensions_.insert(extension->id()); |
| 237 } | 236 } |
| 238 return; | 237 return; |
| 239 } | 238 } |
| 240 | 239 |
| 241 switch (RequiresUserConsentForScriptInjection(extension, script_type)) { | 240 switch (RequiresUserConsentForScriptInjection(extension, script_type)) { |
| 242 case PermissionsData::ACCESS_ALLOWED: | 241 case PermissionsData::ACCESS_ALLOWED: |
| 243 PermitScriptInjection(request_id); | 242 PermitScriptInjection(request_id); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 UnloadedExtensionInfo::Reason reason) { | 326 UnloadedExtensionInfo::Reason reason) { |
| 328 PendingRequestMap::iterator iter = pending_requests_.find(extension->id()); | 327 PendingRequestMap::iterator iter = pending_requests_.find(extension->id()); |
| 329 if (iter != pending_requests_.end()) { | 328 if (iter != pending_requests_.end()) { |
| 330 pending_requests_.erase(iter); | 329 pending_requests_.erase(iter); |
| 331 ExtensionActionAPI::Get(browser_context_)-> | 330 ExtensionActionAPI::Get(browser_context_)-> |
| 332 NotifyPageActionsChanged(web_contents()); | 331 NotifyPageActionsChanged(web_contents()); |
| 333 } | 332 } |
| 334 } | 333 } |
| 335 | 334 |
| 336 } // namespace extensions | 335 } // namespace extensions |
| OLD | NEW |