| 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::RequiresActionForScriptExecution( | 76 if (!PermissionsData::ForExtension(extension) |
| 77 extension, | 77 ->RequiresActionForScriptExecution( |
| 78 SessionID::IdForTab(web_contents()), | 78 extension, |
| 79 web_contents()->GetVisibleURL()) || | 79 SessionID::IdForTab(web_contents()), |
| 80 web_contents()->GetVisibleURL()) || |
| 80 util::AllowedScriptingOnAllUrls(extension->id(), | 81 util::AllowedScriptingOnAllUrls(extension->id(), |
| 81 web_contents()->GetBrowserContext())) { | 82 web_contents()->GetBrowserContext())) { |
| 82 return false; | 83 return false; |
| 83 } | 84 } |
| 84 | 85 |
| 85 // If the feature is not enabled, we automatically allow all extensions to | 86 // If the feature is not enabled, we automatically allow all extensions to |
| 86 // run scripts. | 87 // run scripts. |
| 87 if (!enabled_) | 88 if (!enabled_) |
| 88 permitted_extensions_.insert(extension->id()); | 89 permitted_extensions_.insert(extension->id()); |
| 89 | 90 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 UMA_HISTOGRAM_COUNTS_100( | 258 UMA_HISTOGRAM_COUNTS_100( |
| 258 "Extensions.ActiveScriptController.PermittedExtensions", | 259 "Extensions.ActiveScriptController.PermittedExtensions", |
| 259 permitted_extensions_.size()); | 260 permitted_extensions_.size()); |
| 260 UMA_HISTOGRAM_COUNTS_100( | 261 UMA_HISTOGRAM_COUNTS_100( |
| 261 "Extensions.ActiveScriptController.DeniedExtensions", | 262 "Extensions.ActiveScriptController.DeniedExtensions", |
| 262 pending_requests_.size()); | 263 pending_requests_.size()); |
| 263 } | 264 } |
| 264 } | 265 } |
| 265 | 266 |
| 266 } // namespace extensions | 267 } // namespace extensions |
| OLD | NEW |