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

Side by Side Diff: extensions/common/permissions/permissions_data.cc

Issue 288053002: Block content scripts from executing until user grants permission (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CQ Time! Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « extensions/common/extension_messages.h ('k') | extensions/common/user_script.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/common/permissions/permissions_data.h" 5 #include "extensions/common/permissions/permissions_data.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 const Extension* extension) { 577 const Extension* extension) {
578 return RequiresActionForScriptExecution(extension, -1, GURL()); 578 return RequiresActionForScriptExecution(extension, -1, GURL());
579 } 579 }
580 580
581 // static 581 // static
582 bool PermissionsData::RequiresActionForScriptExecution( 582 bool PermissionsData::RequiresActionForScriptExecution(
583 const Extension* extension, 583 const Extension* extension,
584 int tab_id, 584 int tab_id,
585 const GURL& url) { 585 const GURL& url) {
586 // For now, the user should be notified when an extension with all hosts 586 // For now, the user should be notified when an extension with all hosts
587 // permission tries to execute a script on a page, with exceptions for policy- 587 // permission tries to execute a script on a page. Exceptions for policy-
588 // enabled and component extensions. If this doesn't meet those criteria, 588 // enabled and component extensions, and extensions which are whitelisted to
589 // return immediately. 589 // execute scripts everywhere.
590 if (!extension->ShouldDisplayInExtensionSettings() || 590 if (!extension->ShouldDisplayInExtensionSettings() ||
591 Manifest::IsPolicyLocation(extension->location()) || 591 Manifest::IsPolicyLocation(extension->location()) ||
592 Manifest::IsComponentLocation(extension->location()) || 592 Manifest::IsComponentLocation(extension->location()) ||
593 CanExecuteScriptEverywhere(extension) ||
593 !ShouldWarnAllHosts(extension)) { 594 !ShouldWarnAllHosts(extension)) {
594 return false; 595 return false;
595 } 596 }
596 597
597 // If the extension has explicit permission to run on the given tab, then 598 // If the extension has explicit permission to run on the given tab, then
598 // we don't need to alert the user. 599 // we don't need to alert the user.
599 if (HasTabSpecificPermissionToExecuteScript(extension, tab_id, url)) 600 if (HasTabSpecificPermissionToExecuteScript(extension, tab_id, url))
600 return false; 601 return false;
601 602
602 return true; 603 return true;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 initial_required_permissions_.reset(); 653 initial_required_permissions_.reset();
653 initial_optional_permissions_.reset(); 654 initial_optional_permissions_.reset();
654 } 655 }
655 656
656 bool PermissionsData::ShouldWarnAllHosts(const Extension* extension) { 657 bool PermissionsData::ShouldWarnAllHosts(const Extension* extension) {
657 base::AutoLock auto_lock(extension->permissions_data()->runtime_lock_); 658 base::AutoLock auto_lock(extension->permissions_data()->runtime_lock_);
658 return PermissionsData::GetActivePermissions(extension)->ShouldWarnAllHosts(); 659 return PermissionsData::GetActivePermissions(extension)->ShouldWarnAllHosts();
659 } 660 }
660 661
661 } // namespace extensions 662 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/extension_messages.h ('k') | extensions/common/user_script.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698