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 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2051 #if defined(USE_VIRTUAL_KEYBOARD) | 2051 #if defined(USE_VIRTUAL_KEYBOARD) |
2052 page != chrome::kChromeUIKeyboardHost && | 2052 page != chrome::kChromeUIKeyboardHost && |
2053 #endif | 2053 #endif |
2054 #if defined(OS_CHROMEOS) | 2054 #if defined(OS_CHROMEOS) |
2055 page != chrome::kChromeUIActivationMessageHost && | 2055 page != chrome::kChromeUIActivationMessageHost && |
2056 #endif | 2056 #endif |
2057 page != chrome::kChromeUIBookmarksHost && | 2057 page != chrome::kChromeUIBookmarksHost && |
2058 page != chrome::kChromeUIHistoryHost | 2058 page != chrome::kChromeUIHistoryHost |
2059 #if defined(FILE_MANAGER_EXTENSION) | 2059 #if defined(FILE_MANAGER_EXTENSION) |
2060 && | 2060 && |
2061 !(location() == COMPONENT && | 2061 !(location() == COMPONENT && |
2062 page == chrome::kChromeUIFileManagerHost) | 2062 page == chrome::kChromeUIFileManagerHost) |
2063 #endif | 2063 #endif |
2064 ) || | 2064 ) || |
2065 !overrides->GetStringWithoutPathExpansion(*iter, &val)) { | 2065 !overrides->GetStringWithoutPathExpansion(*iter, &val)) { |
2066 *error = errors::kInvalidChromeURLOverrides; | 2066 *error = errors::kInvalidChromeURLOverrides; |
2067 return false; | 2067 return false; |
2068 } | 2068 } |
2069 // Replace the entry with a fully qualified chrome-extension:// URL. | 2069 // Replace the entry with a fully qualified chrome-extension:// URL. |
2070 chrome_url_overrides_[page] = GetResourceURL(val); | 2070 chrome_url_overrides_[page] = GetResourceURL(val); |
2071 } | 2071 } |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2863 } | 2863 } |
2864 } | 2864 } |
2865 | 2865 |
2866 return true; | 2866 return true; |
2867 } | 2867 } |
2868 | 2868 |
2869 bool Extension::CanSpecifyComponentOnlyPermission() const { | 2869 bool Extension::CanSpecifyComponentOnlyPermission() const { |
2870 // Only COMPONENT extensions can use private APIs. | 2870 // Only COMPONENT extensions can use private APIs. |
2871 // TODO(asargent) - We want a more general purpose mechanism for this, | 2871 // TODO(asargent) - We want a more general purpose mechanism for this, |
2872 // and better error messages. (http://crbug.com/54013) | 2872 // and better error messages. (http://crbug.com/54013) |
2873 if (location_ == Extension::COMPONENT) | 2873 return location_ == Extension::COMPONENT; |
2874 return true; | |
2875 | |
2876 #ifndef NDEBUG | |
2877 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
2878 switches::kExposePrivateExtensionApi)) { | |
2879 return true; | |
2880 } | |
2881 #endif | |
2882 | |
2883 return false; | |
2884 } | 2874 } |
2885 | 2875 |
2886 bool Extension::CanSpecifyExperimentalPermission() const { | 2876 bool Extension::CanSpecifyExperimentalPermission() const { |
2887 if (location_ == Extension::COMPONENT) | 2877 if (location_ == Extension::COMPONENT) |
2888 return true; | 2878 return true; |
2889 | 2879 |
2890 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2880 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2891 switches::kEnableExperimentalExtensionApis)) { | 2881 switches::kEnableExperimentalExtensionApis)) { |
2892 return true; | 2882 return true; |
2893 } | 2883 } |
(...skipping 12 matching lines...) Expand all Loading... |
2906 if (location_ == Extension::COMPONENT) | 2896 if (location_ == Extension::COMPONENT) |
2907 return true; | 2897 return true; |
2908 | 2898 |
2909 if (permission->is_hosted_app()) | 2899 if (permission->is_hosted_app()) |
2910 return true; | 2900 return true; |
2911 | 2901 |
2912 return false; | 2902 return false; |
2913 } | 2903 } |
2914 | 2904 |
2915 bool Extension::CanExecuteScriptEverywhere() const { | 2905 bool Extension::CanExecuteScriptEverywhere() const { |
2916 if (location() == Extension::COMPONENT | 2906 if (location() == Extension::COMPONENT) |
2917 #ifndef NDEBUG | |
2918 || CommandLine::ForCurrentProcess()->HasSwitch( | |
2919 switches::kExposePrivateExtensionApi) | |
2920 #endif | |
2921 ) | |
2922 return true; | 2907 return true; |
2923 | 2908 |
2924 ScriptingWhitelist* whitelist = | 2909 ScriptingWhitelist* whitelist = |
2925 ExtensionConfig::GetInstance()->whitelist(); | 2910 ExtensionConfig::GetInstance()->whitelist(); |
2926 | 2911 |
2927 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); | 2912 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); |
2928 it != whitelist->end(); ++it) { | 2913 it != whitelist->end(); ++it) { |
2929 if (id() == *it) { | 2914 if (id() == *it) { |
2930 return true; | 2915 return true; |
2931 } | 2916 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3052 already_disabled(false), | 3037 already_disabled(false), |
3053 extension(extension) {} | 3038 extension(extension) {} |
3054 | 3039 |
3055 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3040 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
3056 const Extension* extension, | 3041 const Extension* extension, |
3057 const ExtensionPermissionSet* permissions, | 3042 const ExtensionPermissionSet* permissions, |
3058 Reason reason) | 3043 Reason reason) |
3059 : reason(reason), | 3044 : reason(reason), |
3060 extension(extension), | 3045 extension(extension), |
3061 permissions(permissions) {} | 3046 permissions(permissions) {} |
OLD | NEW |