Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(973)

Unified Diff: chrome/browser/extensions/active_script_controller.cc

Issue 293003008: Make ActiveScriptController use Active Tab-style permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest master for CQ Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/active_script_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/active_script_controller.cc
diff --git a/chrome/browser/extensions/active_script_controller.cc b/chrome/browser/extensions/active_script_controller.cc
index 4f9c7e36bd60099faeae853ed1b9585bf027033a..2c3c6b7813450221b85f06be4bdfb87b7f11d6cb 100644
--- a/chrome/browser/extensions/active_script_controller.cc
+++ b/chrome/browser/extensions/active_script_controller.cc
@@ -9,9 +9,11 @@
#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
#include "base/stl_util.h"
+#include "chrome/browser/extensions/active_tab_permission_granter.h"
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/extensions/location_bar_controller.h"
#include "chrome/browser/extensions/tab_helper.h"
+#include "chrome/browser/sessions/session_id.h"
#include "chrome/common/extensions/api/extension_action/action_info.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
@@ -70,8 +72,12 @@ ActiveScriptController* ActiveScriptController::GetForWebContents(
bool ActiveScriptController::RequiresUserConsentForScriptInjection(
const Extension* extension) {
CHECK(extension);
- if (!PermissionsData::RequiresActionForScriptExecution(extension))
+ if (!PermissionsData::RequiresActionForScriptExecution(
+ extension,
+ SessionID::IdForTab(web_contents()),
+ web_contents()->GetVisibleURL())) {
return false;
+ }
// If the feature is not enabled, we automatically allow all extensions to
// run scripts.
@@ -165,6 +171,11 @@ LocationBarController::Action ActiveScriptController::OnClicked(
iter->second.swap(requests);
pending_requests_.erase(extension->id());
+ // Clicking to run the extension counts as granting it permission to run on
+ // the given tab.
+ TabHelper::FromWebContents(web_contents())->
+ active_tab_permission_granter()->GrantIfRequested(extension);
+
// Run all pending injections for the given extension.
for (PendingRequestList::iterator request = requests.begin();
request != requests.end();
« no previous file with comments | « no previous file | chrome/browser/extensions/active_script_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698