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, 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 Loading... |
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 |
OLD | NEW |