Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 8659002: Adding the --load-component-extension flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a unit test. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1982 matching lines...) Expand 10 before | Expand all | Expand 10 after
1993 #if defined(USE_VIRTUAL_KEYBOARD) 1993 #if defined(USE_VIRTUAL_KEYBOARD)
1994 page != chrome::kChromeUIKeyboardHost && 1994 page != chrome::kChromeUIKeyboardHost &&
1995 #endif 1995 #endif
1996 #if defined(OS_CHROMEOS) 1996 #if defined(OS_CHROMEOS)
1997 page != chrome::kChromeUIActivationMessageHost && 1997 page != chrome::kChromeUIActivationMessageHost &&
1998 #endif 1998 #endif
1999 page != chrome::kChromeUIBookmarksHost && 1999 page != chrome::kChromeUIBookmarksHost &&
2000 page != chrome::kChromeUIHistoryHost 2000 page != chrome::kChromeUIHistoryHost
2001 #if defined(FILE_MANAGER_EXTENSION) 2001 #if defined(FILE_MANAGER_EXTENSION)
2002 && 2002 &&
2003 !(location() == COMPONENT && 2003 !(location() == COMPONENT &&
2004 page == chrome::kChromeUIFileManagerHost) 2004 page == chrome::kChromeUIFileManagerHost)
2005 #endif 2005 #endif
2006 ) || 2006 ) ||
2007 !overrides->GetStringWithoutPathExpansion(*iter, &val)) { 2007 !overrides->GetStringWithoutPathExpansion(*iter, &val)) {
2008 *error = errors::kInvalidChromeURLOverrides; 2008 *error = errors::kInvalidChromeURLOverrides;
2009 return false; 2009 return false;
2010 } 2010 }
2011 // Replace the entry with a fully qualified chrome-extension:// URL. 2011 // Replace the entry with a fully qualified chrome-extension:// URL.
2012 chrome_url_overrides_[page] = GetResourceURL(val); 2012 chrome_url_overrides_[page] = GetResourceURL(val);
2013 } 2013 }
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
2822 return false; 2822 return false;
2823 } 2823 }
2824 2824
2825 return true; 2825 return true;
2826 } 2826 }
2827 2827
2828 bool Extension::CanSpecifyComponentOnlyPermission() const { 2828 bool Extension::CanSpecifyComponentOnlyPermission() const {
2829 // Only COMPONENT extensions can use private APIs. 2829 // Only COMPONENT extensions can use private APIs.
2830 // TODO(asargent) - We want a more general purpose mechanism for this, 2830 // TODO(asargent) - We want a more general purpose mechanism for this,
2831 // and better error messages. (http://crbug.com/54013) 2831 // and better error messages. (http://crbug.com/54013)
2832 if (location_ == Extension::COMPONENT) 2832 return location_ == Extension::COMPONENT;
2833 return true;
2834
2835 #ifndef NDEBUG
2836 if (CommandLine::ForCurrentProcess()->HasSwitch(
2837 switches::kExposePrivateExtensionApi)) {
2838 return true;
2839 }
2840 #endif
2841
2842 return false;
2843 } 2833 }
2844 2834
2845 bool Extension::CanSpecifyExperimentalPermission() const { 2835 bool Extension::CanSpecifyExperimentalPermission() const {
2846 if (location_ == Extension::COMPONENT) 2836 if (location_ == Extension::COMPONENT)
2847 return true; 2837 return true;
2848 2838
2849 if (CommandLine::ForCurrentProcess()->HasSwitch( 2839 if (CommandLine::ForCurrentProcess()->HasSwitch(
2850 switches::kEnableExperimentalExtensionApis)) { 2840 switches::kEnableExperimentalExtensionApis)) {
2851 return true; 2841 return true;
2852 } 2842 }
2853 2843
2854 // We rely on the webstore to check access to experimental. This way we can 2844 // We rely on the webstore to check access to experimental. This way we can
2855 // whitelist extensions to have access to experimental in just the store, and 2845 // whitelist extensions to have access to experimental in just the store, and
2856 // not have to push a new version of the client. 2846 // not have to push a new version of the client.
2857 if (from_webstore()) 2847 if (from_webstore())
2858 return true; 2848 return true;
2859 2849
2860 return false; 2850 return false;
2861 } 2851 }
2862 2852
2863 bool Extension::CanExecuteScriptEverywhere() const { 2853 bool Extension::CanExecuteScriptEverywhere() const {
2864 if (location() == Extension::COMPONENT 2854 if (location() == Extension::COMPONENT)
2865 #ifndef NDEBUG
2866 || CommandLine::ForCurrentProcess()->HasSwitch(
2867 switches::kExposePrivateExtensionApi)
2868 #endif
2869 )
2870 return true; 2855 return true;
2871 2856
2872 ScriptingWhitelist* whitelist = 2857 ScriptingWhitelist* whitelist =
2873 ExtensionConfig::GetInstance()->whitelist(); 2858 ExtensionConfig::GetInstance()->whitelist();
2874 2859
2875 for (ScriptingWhitelist::const_iterator it = whitelist->begin(); 2860 for (ScriptingWhitelist::const_iterator it = whitelist->begin();
2876 it != whitelist->end(); ++it) { 2861 it != whitelist->end(); ++it) {
2877 if (id() == *it) { 2862 if (id() == *it) {
2878 return true; 2863 return true;
2879 } 2864 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3000 already_disabled(false), 2985 already_disabled(false),
3001 extension(extension) {} 2986 extension(extension) {}
3002 2987
3003 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 2988 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3004 const Extension* extension, 2989 const Extension* extension,
3005 const ExtensionPermissionSet* permissions, 2990 const ExtensionPermissionSet* permissions,
3006 Reason reason) 2991 Reason reason)
3007 : reason(reason), 2992 : reason(reason),
3008 extension(extension), 2993 extension(extension),
3009 permissions(permissions) {} 2994 permissions(permissions) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698