OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1992 #if defined(USE_VIRTUAL_KEYBOARD) | 1992 #if defined(USE_VIRTUAL_KEYBOARD) |
1993 page != chrome::kChromeUIKeyboardHost && | 1993 page != chrome::kChromeUIKeyboardHost && |
1994 #endif | 1994 #endif |
1995 #if defined(OS_CHROMEOS) | 1995 #if defined(OS_CHROMEOS) |
1996 page != chrome::kChromeUIActivationMessageHost && | 1996 page != chrome::kChromeUIActivationMessageHost && |
1997 #endif | 1997 #endif |
1998 page != chrome::kChromeUIBookmarksHost && | 1998 page != chrome::kChromeUIBookmarksHost && |
1999 page != chrome::kChromeUIHistoryHost | 1999 page != chrome::kChromeUIHistoryHost |
2000 #if defined(FILE_MANAGER_EXTENSION) | 2000 #if defined(FILE_MANAGER_EXTENSION) |
2001 && | 2001 && |
2002 !(location() == COMPONENT && | 2002 !(location() == COMPONENT && |
2003 page == chrome::kChromeUIFileManagerHost) | 2003 page == chrome::kChromeUIFileManagerHost) |
2004 #endif | 2004 #endif |
2005 ) || | 2005 ) || |
2006 !overrides->GetStringWithoutPathExpansion(*iter, &val)) { | 2006 !overrides->GetStringWithoutPathExpansion(*iter, &val)) { |
2007 *error = errors::kInvalidChromeURLOverrides; | 2007 *error = errors::kInvalidChromeURLOverrides; |
2008 return false; | 2008 return false; |
2009 } | 2009 } |
2010 // Replace the entry with a fully qualified chrome-extension:// URL. | 2010 // Replace the entry with a fully qualified chrome-extension:// URL. |
2011 chrome_url_overrides_[page] = GetResourceURL(val); | 2011 chrome_url_overrides_[page] = GetResourceURL(val); |
2012 } | 2012 } |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2821 return false; | 2821 return false; |
2822 } | 2822 } |
2823 | 2823 |
2824 return true; | 2824 return true; |
2825 } | 2825 } |
2826 | 2826 |
2827 bool Extension::CanSpecifyComponentOnlyPermission() const { | 2827 bool Extension::CanSpecifyComponentOnlyPermission() const { |
2828 // Only COMPONENT extensions can use private APIs. | 2828 // Only COMPONENT extensions can use private APIs. |
2829 // TODO(asargent) - We want a more general purpose mechanism for this, | 2829 // TODO(asargent) - We want a more general purpose mechanism for this, |
2830 // and better error messages. (http://crbug.com/54013) | 2830 // and better error messages. (http://crbug.com/54013) |
2831 if (location_ == Extension::COMPONENT) | 2831 return location_ == Extension::COMPONENT; |
2832 return true; | |
2833 | |
2834 #ifndef NDEBUG | |
2835 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
2836 switches::kExposePrivateExtensionApi)) { | |
2837 return true; | |
2838 } | |
2839 #endif | |
2840 | |
2841 return false; | |
2842 } | 2832 } |
2843 | 2833 |
2844 bool Extension::CanSpecifyExperimentalPermission() const { | 2834 bool Extension::CanSpecifyExperimentalPermission() const { |
2845 if (location_ == Extension::COMPONENT) | 2835 if (location_ == Extension::COMPONENT) |
2846 return true; | 2836 return true; |
2847 | 2837 |
2848 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2838 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2849 switches::kEnableExperimentalExtensionApis)) { | 2839 switches::kEnableExperimentalExtensionApis)) { |
2850 return true; | 2840 return true; |
2851 } | 2841 } |
2852 | 2842 |
2853 // We rely on the webstore to check access to experimental. This way we can | 2843 // We rely on the webstore to check access to experimental. This way we can |
2854 // whitelist extensions to have access to experimental in just the store, and | 2844 // whitelist extensions to have access to experimental in just the store, and |
2855 // not have to push a new version of the client. | 2845 // not have to push a new version of the client. |
2856 if (from_webstore()) | 2846 if (from_webstore()) |
2857 return true; | 2847 return true; |
2858 | 2848 |
2859 return false; | 2849 return false; |
2860 } | 2850 } |
2861 | 2851 |
2862 bool Extension::CanExecuteScriptEverywhere() const { | 2852 bool Extension::CanExecuteScriptEverywhere() const { |
2863 if (location() == Extension::COMPONENT | 2853 if (location() == Extension::COMPONENT) |
2864 #ifndef NDEBUG | |
2865 || CommandLine::ForCurrentProcess()->HasSwitch( | |
2866 switches::kExposePrivateExtensionApi) | |
2867 #endif | |
2868 ) | |
2869 return true; | 2854 return true; |
2870 | 2855 |
2871 ScriptingWhitelist* whitelist = | 2856 ScriptingWhitelist* whitelist = |
2872 ExtensionConfig::GetInstance()->whitelist(); | 2857 ExtensionConfig::GetInstance()->whitelist(); |
2873 | 2858 |
2874 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); | 2859 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); |
2875 it != whitelist->end(); ++it) { | 2860 it != whitelist->end(); ++it) { |
2876 if (id() == *it) { | 2861 if (id() == *it) { |
2877 return true; | 2862 return true; |
2878 } | 2863 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2999 already_disabled(false), | 2984 already_disabled(false), |
3000 extension(extension) {} | 2985 extension(extension) {} |
3001 | 2986 |
3002 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 2987 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
3003 const Extension* extension, | 2988 const Extension* extension, |
3004 const ExtensionPermissionSet* permissions, | 2989 const ExtensionPermissionSet* permissions, |
3005 Reason reason) | 2990 Reason reason) |
3006 : reason(reason), | 2991 : reason(reason), |
3007 extension(extension), | 2992 extension(extension), |
3008 permissions(permissions) {} | 2993 permissions(permissions) {} |
OLD | NEW |