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 !(CanSpecifyComponentOnlyPermission() && |
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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 if (location_ == Extension::COMPONENT) |
2874 return true; | 2874 return true; |
2875 | 2875 |
2876 #ifndef NDEBUG | 2876 if (location_ == Extension::LOAD && |
2877 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2877 CommandLine::ForCurrentProcess()->HasSwitch( |
2878 switches::kExposePrivateExtensionApi)) { | 2878 switches::kExposePrivateExtensionApi)) { |
2879 return true; | 2879 return true; |
2880 } | 2880 } |
2881 #endif | |
2882 | 2881 |
2883 return false; | 2882 return false; |
2884 } | 2883 } |
2885 | 2884 |
2886 bool Extension::CanSpecifyExperimentalPermission() const { | 2885 bool Extension::CanSpecifyExperimentalPermission() const { |
2887 if (location_ == Extension::COMPONENT) | 2886 if (location_ == Extension::COMPONENT) |
2888 return true; | 2887 return true; |
2889 | 2888 |
2890 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2889 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2891 switches::kEnableExperimentalExtensionApis)) { | 2890 switches::kEnableExperimentalExtensionApis)) { |
(...skipping 14 matching lines...) Expand all Loading... | |
2906 if (location_ == Extension::COMPONENT) | 2905 if (location_ == Extension::COMPONENT) |
2907 return true; | 2906 return true; |
2908 | 2907 |
2909 if (permission->is_hosted_app()) | 2908 if (permission->is_hosted_app()) |
2910 return true; | 2909 return true; |
2911 | 2910 |
2912 return false; | 2911 return false; |
2913 } | 2912 } |
2914 | 2913 |
2915 bool Extension::CanExecuteScriptEverywhere() const { | 2914 bool Extension::CanExecuteScriptEverywhere() const { |
2916 if (location() == Extension::COMPONENT | 2915 if (location() == Extension::COMPONENT || |
2917 #ifndef NDEBUG | 2916 (location() == Extension::LOAD && |
2918 || CommandLine::ForCurrentProcess()->HasSwitch( | 2917 CommandLine::ForCurrentProcess()->HasSwitch( |
2919 switches::kExposePrivateExtensionApi) | 2918 switches::kExposePrivateExtensionApi) |
2920 #endif | |
2921 ) | 2919 ) |
Aaron Boodman
2011/11/28 18:29:59
Nit: these parens should be up on line 2918.
SeRya
2011/11/28 23:49:53
Done.
| |
2920 ) | |
2922 return true; | 2921 return true; |
2923 | 2922 |
2924 ScriptingWhitelist* whitelist = | 2923 ScriptingWhitelist* whitelist = |
2925 ExtensionConfig::GetInstance()->whitelist(); | 2924 ExtensionConfig::GetInstance()->whitelist(); |
2926 | 2925 |
2927 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); | 2926 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); |
2928 it != whitelist->end(); ++it) { | 2927 it != whitelist->end(); ++it) { |
2929 if (id() == *it) { | 2928 if (id() == *it) { |
2930 return true; | 2929 return true; |
2931 } | 2930 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3052 already_disabled(false), | 3051 already_disabled(false), |
3053 extension(extension) {} | 3052 extension(extension) {} |
3054 | 3053 |
3055 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3054 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
3056 const Extension* extension, | 3055 const Extension* extension, |
3057 const ExtensionPermissionSet* permissions, | 3056 const ExtensionPermissionSet* permissions, |
3058 Reason reason) | 3057 Reason reason) |
3059 : reason(reason), | 3058 : reason(reason), |
3060 extension(extension), | 3059 extension(extension), |
3061 permissions(permissions) {} | 3060 permissions(permissions) {} |
OLD | NEW |