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

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

Issue 11446034: SupportsUserData and manifest handlers for Extension; use them for the Omnibox API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_H_
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <iosfwd> 9 #include <iosfwd>
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/file_path.h" 16 #include "base/file_path.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/hash_tables.h" 18 #include "base/hash_tables.h"
19 #include "base/memory/linked_ptr.h" 19 #include "base/memory/linked_ptr.h"
20 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
21 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
22 #include "base/supports_user_data.h"
22 #include "base/synchronization/lock.h" 23 #include "base/synchronization/lock.h"
23 #include "chrome/common/extensions/command.h" 24 #include "chrome/common/extensions/command.h"
24 #include "chrome/common/extensions/extension_constants.h" 25 #include "chrome/common/extensions/extension_constants.h"
25 #include "chrome/common/extensions/extension_icon_set.h" 26 #include "chrome/common/extensions/extension_icon_set.h"
26 #include "chrome/common/extensions/permissions/api_permission.h" 27 #include "chrome/common/extensions/permissions/api_permission.h"
27 #include "chrome/common/extensions/permissions/api_permission_set.h" 28 #include "chrome/common/extensions/permissions/api_permission_set.h"
28 #include "chrome/common/extensions/permissions/permission_message.h" 29 #include "chrome/common/extensions/permissions/permission_message.h"
29 #include "chrome/common/extensions/user_script.h" 30 #include "chrome/common/extensions/user_script.h"
30 #include "extensions/common/url_pattern.h" 31 #include "extensions/common/url_pattern.h"
31 #include "extensions/common/url_pattern_set.h" 32 #include "extensions/common/url_pattern_set.h"
(...skipping 23 matching lines...) Expand all
55 FORWARD_DECLARE_TEST(TabStripModelTest, Apps); 56 FORWARD_DECLARE_TEST(TabStripModelTest, Apps);
56 57
57 namespace extensions { 58 namespace extensions {
58 59
59 class Manifest; 60 class Manifest;
60 class PermissionSet; 61 class PermissionSet;
61 62
62 typedef std::set<std::string> OAuth2Scopes; 63 typedef std::set<std::string> OAuth2Scopes;
63 64
64 // Represents a Chrome extension. 65 // Represents a Chrome extension.
65 class Extension : public base::RefCountedThreadSafe<Extension> { 66 class Extension : public base::RefCountedThreadSafe<Extension>,
67 public base::SupportsUserData {
66 public: 68 public:
67 struct InstallWarning; 69 struct InstallWarning;
68 70
69 typedef std::map<const std::string, GURL> URLOverrideMap; 71 typedef std::map<const std::string, GURL> URLOverrideMap;
70 typedef std::vector<std::string> ScriptingWhitelist; 72 typedef std::vector<std::string> ScriptingWhitelist;
71 typedef std::vector<linked_ptr<FileBrowserHandler> > FileBrowserHandlerList; 73 typedef std::vector<linked_ptr<FileBrowserHandler> > FileBrowserHandlerList;
72 typedef std::vector<InstallWarning> InstallWarningVector; 74 typedef std::vector<InstallWarning> InstallWarningVector;
73 75
74 // What an extension was loaded from. 76 // What an extension was loaded from.
75 // NOTE: These values are stored as integers in the preferences and used 77 // NOTE: These values are stored as integers in the preferences and used
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 const ActionInfo* script_badge_info() const { 682 const ActionInfo* script_badge_info() const {
681 return script_badge_info_.get(); 683 return script_badge_info_.get();
682 } 684 }
683 const ActionInfo* page_action_info() const { return page_action_info_.get(); } 685 const ActionInfo* page_action_info() const { return page_action_info_.get(); }
684 const ActionInfo* browser_action_info() const { 686 const ActionInfo* browser_action_info() const {
685 return browser_action_info_.get(); 687 return browser_action_info_.get();
686 } 688 }
687 const ActionInfo* system_indicator_info() const { 689 const ActionInfo* system_indicator_info() const {
688 return system_indicator_info_.get(); 690 return system_indicator_info_.get();
689 } 691 }
690 bool is_verbose_install_message() const {
691 return !omnibox_keyword().empty() ||
692 browser_action_info() ||
693 (page_action_info() &&
694 (page_action_command() ||
695 !page_action_info()->default_icon.empty()));
696 }
697 const FileBrowserHandlerList* file_browser_handlers() const { 692 const FileBrowserHandlerList* file_browser_handlers() const {
698 return file_browser_handlers_.get(); 693 return file_browser_handlers_.get();
699 } 694 }
700 const std::vector<PluginInfo>& plugins() const { return plugins_; } 695 const std::vector<PluginInfo>& plugins() const { return plugins_; }
701 const std::vector<NaClModuleInfo>& nacl_modules() const { 696 const std::vector<NaClModuleInfo>& nacl_modules() const {
702 return nacl_modules_; 697 return nacl_modules_;
703 } 698 }
704 const std::vector<InputComponentInfo>& input_components() const { 699 const std::vector<InputComponentInfo>& input_components() const {
705 return input_components_; 700 return input_components_;
706 } 701 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 } 754 }
760 const GURL& update_url() const { return update_url_; } 755 const GURL& update_url() const { return update_url_; }
761 const ExtensionIconSet& icons() const { return icons_; } 756 const ExtensionIconSet& icons() const { return icons_; }
762 const extensions::Manifest* manifest() const { 757 const extensions::Manifest* manifest() const {
763 return manifest_.get(); 758 return manifest_.get();
764 } 759 }
765 const std::string default_locale() const { return default_locale_; } 760 const std::string default_locale() const { return default_locale_; }
766 const URLOverrideMap& GetChromeURLOverrides() const { 761 const URLOverrideMap& GetChromeURLOverrides() const {
767 return chrome_url_overrides_; 762 return chrome_url_overrides_;
768 } 763 }
769 const std::string omnibox_keyword() const { return omnibox_keyword_; }
770 bool incognito_split_mode() const { return incognito_split_mode_; } 764 bool incognito_split_mode() const { return incognito_split_mode_; }
771 bool offline_enabled() const { return offline_enabled_; } 765 bool offline_enabled() const { return offline_enabled_; }
772 const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; } 766 const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; }
773 const OAuth2Info& oauth2_info() const { return oauth2_info_; } 767 const OAuth2Info& oauth2_info() const { return oauth2_info_; }
774 const std::vector<webkit_glue::WebIntentServiceData>& 768 const std::vector<webkit_glue::WebIntentServiceData>&
775 intents_services() const { 769 intents_services() const {
776 return intents_services_; 770 return intents_services_;
777 } 771 }
778 772
779 bool wants_file_access() const { return wants_file_access_; } 773 bool wants_file_access() const { return wants_file_access_; }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 string16* error); 859 string16* error);
866 860
867 // Normalize the path for use by the extension. On Windows, this will make 861 // Normalize the path for use by the extension. On Windows, this will make
868 // sure the drive letter is uppercase. 862 // sure the drive letter is uppercase.
869 static FilePath MaybeNormalizePath(const FilePath& path); 863 static FilePath MaybeNormalizePath(const FilePath& path);
870 864
871 // Returns true if this extension id is from a trusted provider. 865 // Returns true if this extension id is from a trusted provider.
872 static bool IsTrustedId(const std::string& id); 866 static bool IsTrustedId(const std::string& id);
873 867
874 Extension(const FilePath& path, scoped_ptr<extensions::Manifest> manifest); 868 Extension(const FilePath& path, scoped_ptr<extensions::Manifest> manifest);
875 ~Extension(); 869 virtual ~Extension();
876 870
877 // Initialize the extension from a parsed manifest. 871 // Initialize the extension from a parsed manifest.
878 // TODO(aa): Rename to just Init()? There's no Value here anymore. 872 // TODO(aa): Rename to just Init()? There's no Value here anymore.
879 // TODO(aa): It is really weird the way this class essentially contains a copy 873 // TODO(aa): It is really weird the way this class essentially contains a copy
880 // of the underlying DictionaryValue in its members. We should decide to 874 // of the underlying DictionaryValue in its members. We should decide to
881 // either wrap the DictionaryValue and go with that only, or we should parse 875 // either wrap the DictionaryValue and go with that only, or we should parse
882 // into strong types and discard the value. But doing both is bad. 876 // into strong types and discard the value. But doing both is bad.
883 bool InitFromValue(int flags, string16* error); 877 bool InitFromValue(int flags, string16* error);
884 878
885 // The following are helpers for InitFromValue to load various features of the 879 // The following are helpers for InitFromValue to load various features of the
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 bool LoadWebIntentAction(const std::string& action_name, 929 bool LoadWebIntentAction(const std::string& action_name,
936 const base::DictionaryValue& intent_service, 930 const base::DictionaryValue& intent_service,
937 string16* error); 931 string16* error);
938 bool LoadWebIntentServices(string16* error); 932 bool LoadWebIntentServices(string16* error);
939 bool LoadFileHandler(const std::string& handler_id, 933 bool LoadFileHandler(const std::string& handler_id,
940 const base::DictionaryValue& handler_info, 934 const base::DictionaryValue& handler_info,
941 string16* error); 935 string16* error);
942 bool LoadFileHandlers(string16* error); 936 bool LoadFileHandlers(string16* error);
943 bool LoadExtensionFeatures(APIPermissionSet* api_permissions, 937 bool LoadExtensionFeatures(APIPermissionSet* api_permissions,
944 string16* error); 938 string16* error);
939 bool LoadManifestHandlerFeatures(string16* error);
945 bool LoadDevToolsPage(string16* error); 940 bool LoadDevToolsPage(string16* error);
946 bool LoadInputComponents(const APIPermissionSet& api_permissions, 941 bool LoadInputComponents(const APIPermissionSet& api_permissions,
947 string16* error); 942 string16* error);
948 bool LoadContentScripts(string16* error); 943 bool LoadContentScripts(string16* error);
949 bool LoadPageAction(string16* error); 944 bool LoadPageAction(string16* error);
950 bool LoadBrowserAction(string16* error); 945 bool LoadBrowserAction(string16* error);
951 bool LoadScriptBadge(string16* error); 946 bool LoadScriptBadge(string16* error);
952 bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error); 947 bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error);
953 bool LoadFileBrowserHandlers(string16* error); 948 bool LoadFileBrowserHandlers(string16* error);
954 // Helper method to load a FileBrowserHandlerList from the manifest. 949 // Helper method to load a FileBrowserHandlerList from the manifest.
955 FileBrowserHandlerList* LoadFileBrowserHandlersHelper( 950 FileBrowserHandlerList* LoadFileBrowserHandlersHelper(
956 const base::ListValue* extension_actions, string16* error); 951 const base::ListValue* extension_actions, string16* error);
957 // Helper method to load an FileBrowserHandler from manifest. 952 // Helper method to load an FileBrowserHandler from manifest.
958 FileBrowserHandler* LoadFileBrowserHandler( 953 FileBrowserHandler* LoadFileBrowserHandler(
959 const base::DictionaryValue* file_browser_handlers, string16* error); 954 const base::DictionaryValue* file_browser_handlers, string16* error);
960 bool LoadChromeURLOverrides(string16* error); 955 bool LoadChromeURLOverrides(string16* error);
961 bool LoadOmnibox(string16* error);
962 bool LoadTextToSpeechVoices(string16* error); 956 bool LoadTextToSpeechVoices(string16* error);
963 bool LoadIncognitoMode(string16* error); 957 bool LoadIncognitoMode(string16* error);
964 bool LoadContentSecurityPolicy(string16* error); 958 bool LoadContentSecurityPolicy(string16* error);
965 959
966 bool LoadThemeFeatures(string16* error); 960 bool LoadThemeFeatures(string16* error);
967 bool LoadThemeImages(const base::DictionaryValue* theme_value, 961 bool LoadThemeImages(const base::DictionaryValue* theme_value,
968 string16* error); 962 string16* error);
969 bool LoadThemeColors(const base::DictionaryValue* theme_value, 963 bool LoadThemeColors(const base::DictionaryValue* theme_value,
970 string16* error); 964 string16* error);
971 bool LoadThemeTints(const base::DictionaryValue* theme_value, 965 bool LoadThemeTints(const base::DictionaryValue* theme_value,
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 // containers like panels and windows. 1216 // containers like panels and windows.
1223 int launch_width_; 1217 int launch_width_;
1224 int launch_height_; 1218 int launch_height_;
1225 1219
1226 // Should this app be shown in the app launcher. 1220 // Should this app be shown in the app launcher.
1227 bool display_in_launcher_; 1221 bool display_in_launcher_;
1228 1222
1229 // Should this app be shown in the browser New Tab Page. 1223 // Should this app be shown in the browser New Tab Page.
1230 bool display_in_new_tab_page_; 1224 bool display_in_new_tab_page_;
1231 1225
1232 // The Omnibox keyword for this extension, or empty if there is none.
1233 std::string omnibox_keyword_;
1234
1235 // List of text-to-speech voices that this extension provides, if any. 1226 // List of text-to-speech voices that this extension provides, if any.
1236 std::vector<TtsVoice> tts_voices_; 1227 std::vector<TtsVoice> tts_voices_;
1237 1228
1238 // The OAuth2 client id and scopes, if specified by the extension. 1229 // The OAuth2 client id and scopes, if specified by the extension.
1239 OAuth2Info oauth2_info_; 1230 OAuth2Info oauth2_info_;
1240 1231
1241 // List of intent services that this extension provides, if any. 1232 // List of intent services that this extension provides, if any.
1242 std::vector<webkit_glue::WebIntentServiceData> intents_services_; 1233 std::vector<webkit_glue::WebIntentServiceData> intents_services_;
1243 1234
1244 // List of file handlers associated with this extension, if any. 1235 // List of file handlers associated with this extension, if any.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 1311
1321 UpdatedExtensionPermissionsInfo( 1312 UpdatedExtensionPermissionsInfo(
1322 const Extension* extension, 1313 const Extension* extension,
1323 const PermissionSet* permissions, 1314 const PermissionSet* permissions,
1324 Reason reason); 1315 Reason reason);
1325 }; 1316 };
1326 1317
1327 } // namespace extensions 1318 } // namespace extensions
1328 1319
1329 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 1320 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698