| 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" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 LocationBarController* location_bar_controller = | 66 LocationBarController* location_bar_controller = |
| 67 tab_helper->location_bar_controller(); | 67 tab_helper->location_bar_controller(); |
| 68 // This should never be NULL. | 68 // This should never be NULL. |
| 69 DCHECK(location_bar_controller); | 69 DCHECK(location_bar_controller); |
| 70 return location_bar_controller->active_script_controller(); | 70 return location_bar_controller->active_script_controller(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool ActiveScriptController::RequiresUserConsentForScriptInjection( | 73 bool ActiveScriptController::RequiresUserConsentForScriptInjection( |
| 74 const Extension* extension) { | 74 const Extension* extension) { |
| 75 CHECK(extension); | 75 CHECK(extension); |
| 76 if (!PermissionsData::ForExtension(extension) | 76 if (!extension->permissions_data()->RequiresActionForScriptExecution( |
| 77 ->RequiresActionForScriptExecution( | 77 extension, |
| 78 extension, | 78 SessionID::IdForTab(web_contents()), |
| 79 SessionID::IdForTab(web_contents()), | 79 web_contents()->GetVisibleURL()) || |
| 80 web_contents()->GetVisibleURL()) || | |
| 81 util::AllowedScriptingOnAllUrls(extension->id(), | 80 util::AllowedScriptingOnAllUrls(extension->id(), |
| 82 web_contents()->GetBrowserContext())) { | 81 web_contents()->GetBrowserContext())) { |
| 83 return false; | 82 return false; |
| 84 } | 83 } |
| 85 | 84 |
| 86 // If the feature is not enabled, we automatically allow all extensions to | 85 // If the feature is not enabled, we automatically allow all extensions to |
| 87 // run scripts. | 86 // run scripts. |
| 88 if (!enabled_) | 87 if (!enabled_) |
| 89 permitted_extensions_.insert(extension->id()); | 88 permitted_extensions_.insert(extension->id()); |
| 90 | 89 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 UMA_HISTOGRAM_COUNTS_100( | 290 UMA_HISTOGRAM_COUNTS_100( |
| 292 "Extensions.ActiveScriptController.PermittedExtensions", | 291 "Extensions.ActiveScriptController.PermittedExtensions", |
| 293 permitted_extensions_.size()); | 292 permitted_extensions_.size()); |
| 294 UMA_HISTOGRAM_COUNTS_100( | 293 UMA_HISTOGRAM_COUNTS_100( |
| 295 "Extensions.ActiveScriptController.DeniedExtensions", | 294 "Extensions.ActiveScriptController.DeniedExtensions", |
| 296 pending_requests_.size()); | 295 pending_requests_.size()); |
| 297 } | 296 } |
| 298 } | 297 } |
| 299 | 298 |
| 300 } // namespace extensions | 299 } // namespace extensions |
| OLD | NEW |