OLD | NEW |
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 Loading... |
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. Exceptions for policy- | 587 // permission tries to execute a script on a page, with exceptions for policy- |
588 // enabled and component extensions, and extensions which are whitelisted to | 588 // enabled and component extensions. If this doesn't meet those criteria, |
589 // execute scripts everywhere. | 589 // return immediately. |
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) || | |
594 !ShouldWarnAllHosts(extension)) { | 593 !ShouldWarnAllHosts(extension)) { |
595 return false; | 594 return false; |
596 } | 595 } |
597 | 596 |
598 // If the extension has explicit permission to run on the given tab, then | 597 // If the extension has explicit permission to run on the given tab, then |
599 // we don't need to alert the user. | 598 // we don't need to alert the user. |
600 if (HasTabSpecificPermissionToExecuteScript(extension, tab_id, url)) | 599 if (HasTabSpecificPermissionToExecuteScript(extension, tab_id, url)) |
601 return false; | 600 return false; |
602 | 601 |
603 return true; | 602 return true; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 initial_required_permissions_.reset(); | 652 initial_required_permissions_.reset(); |
654 initial_optional_permissions_.reset(); | 653 initial_optional_permissions_.reset(); |
655 } | 654 } |
656 | 655 |
657 bool PermissionsData::ShouldWarnAllHosts(const Extension* extension) { | 656 bool PermissionsData::ShouldWarnAllHosts(const Extension* extension) { |
658 base::AutoLock auto_lock(extension->permissions_data()->runtime_lock_); | 657 base::AutoLock auto_lock(extension->permissions_data()->runtime_lock_); |
659 return PermissionsData::GetActivePermissions(extension)->ShouldWarnAllHosts(); | 658 return PermissionsData::GetActivePermissions(extension)->ShouldWarnAllHosts(); |
660 } | 659 } |
661 | 660 |
662 } // namespace extensions | 661 } // namespace extensions |
OLD | NEW |