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

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: 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 unified diff | Download patch | Annotate | Revision Log
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 *error = errors::kAllURLOrActiveTabNeeded; 577 *error = errors::kAllURLOrActiveTabNeeded;
578 return false; 578 return false;
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 initial_optional_permissions_->api_permissions, 648 initial_optional_permissions_->api_permissions,
648 initial_optional_permissions_->manifest_permissions, 649 initial_optional_permissions_->manifest_permissions,
649 initial_optional_permissions_->host_permissions, 650 initial_optional_permissions_->host_permissions,
650 URLPatternSet()); 651 URLPatternSet());
651 652
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 } // namespace extensions 657 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698