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

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

Issue 11588004: Move ScriptBadge, ActionInfo out of Extension; preparation for BrowserAction (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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
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/synchronization/lock.h" 22 #include "base/synchronization/lock.h"
23 #include "chrome/common/extensions/api/extension_action/action_info.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"
32 #include "googleurl/src/gurl.h" 33 #include "googleurl/src/gurl.h"
(...skipping 15 matching lines...) Expand all
48 class ImageSkia; 49 class ImageSkia;
49 } 50 }
50 51
51 namespace webkit_glue { 52 namespace webkit_glue {
52 struct WebIntentServiceData; 53 struct WebIntentServiceData;
53 } 54 }
54 55
55 FORWARD_DECLARE_TEST(TabStripModelTest, Apps); 56 FORWARD_DECLARE_TEST(TabStripModelTest, Apps);
56 57
57 namespace extensions { 58 namespace extensions {
58
Yoyo Zhou 2012/12/18 02:01:41 doesn't seem necessary to remove this
Devlin 2012/12/18 20:42:07 Didn't realize I did that; whoops.
59 class Manifest; 59 class Manifest;
60 class PermissionSet; 60 class PermissionSet;
61 61
62 typedef std::set<std::string> OAuth2Scopes; 62 typedef std::set<std::string> OAuth2Scopes;
63 63
64 // Represents a Chrome extension. 64 // Represents a Chrome extension.
65 class Extension : public base::RefCountedThreadSafe<Extension> { 65 class Extension : public base::RefCountedThreadSafe<Extension> {
66 public: 66 public:
67 struct InstallWarning; 67 struct InstallWarning;
68 struct ManifestData; 68 struct ManifestData;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 struct OAuth2Info { 215 struct OAuth2Info {
216 OAuth2Info(); 216 OAuth2Info();
217 ~OAuth2Info(); 217 ~OAuth2Info();
218 218
219 OAuth2Scopes GetScopesAsSet(); 219 OAuth2Scopes GetScopesAsSet();
220 220
221 std::string client_id; 221 std::string client_id;
222 std::vector<std::string> scopes; 222 std::vector<std::string> scopes;
223 }; 223 };
224 224
225 struct ActionInfo {
226 explicit ActionInfo();
227 ~ActionInfo();
228
229 // The types of extension actions.
230 enum Type {
231 TYPE_BROWSER,
232 TYPE_PAGE,
233 TYPE_SCRIPT_BADGE,
234 TYPE_SYSTEM_INDICATOR,
235 };
236
237 // Empty implies the key wasn't present.
238 ExtensionIconSet default_icon;
239 std::string default_title;
240 GURL default_popup_url;
241 // action id -- only used with legacy page actions API.
242 std::string id;
243 };
244
245 struct FileHandlerInfo { 225 struct FileHandlerInfo {
246 explicit FileHandlerInfo(); 226 explicit FileHandlerInfo();
247 ~FileHandlerInfo(); 227 ~FileHandlerInfo();
248 std::string id; 228 std::string id;
249 std::string title; 229 std::string title;
250 230
251 // File extensions associated with this handler. 231 // File extensions associated with this handler.
252 std::set<std::string> extensions; 232 std::set<std::string> extensions;
253 233
254 // MIME types associated with this handler. 234 // MIME types associated with this handler.
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 // Base64-encoded version of the key used to sign this extension. 662 // Base64-encoded version of the key used to sign this extension.
683 // In pseudocode, returns 663 // In pseudocode, returns
684 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). 664 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()).
685 const std::string& public_key() const { return public_key_; } 665 const std::string& public_key() const { return public_key_; }
686 const std::string& description() const { return description_; } 666 const std::string& description() const { return description_; }
687 int manifest_version() const { return manifest_version_; } 667 int manifest_version() const { return manifest_version_; }
688 bool converted_from_user_script() const { 668 bool converted_from_user_script() const {
689 return converted_from_user_script_; 669 return converted_from_user_script_;
690 } 670 }
691 const UserScriptList& content_scripts() const { return content_scripts_; } 671 const UserScriptList& content_scripts() const { return content_scripts_; }
692 const ActionInfo* script_badge_info() const {
693 return script_badge_info_.get();
694 }
695 const ActionInfo* page_action_info() const { return page_action_info_.get(); } 672 const ActionInfo* page_action_info() const { return page_action_info_.get(); }
696 const ActionInfo* browser_action_info() const { 673 const ActionInfo* browser_action_info() const {
697 return browser_action_info_.get(); 674 return browser_action_info_.get();
698 } 675 }
699 const ActionInfo* system_indicator_info() const { 676 const ActionInfo* system_indicator_info() const {
700 return system_indicator_info_.get(); 677 return system_indicator_info_.get();
701 } 678 }
702 const FileBrowserHandlerList* file_browser_handlers() const { 679 const FileBrowserHandlerList* file_browser_handlers() const {
703 return file_browser_handlers_.get(); 680 return file_browser_handlers_.get();
704 } 681 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 } 727 }
751 const GURL& options_url() const { return options_url_; } 728 const GURL& options_url() const { return options_url_; }
752 const GURL& devtools_url() const { return devtools_url_; } 729 const GURL& devtools_url() const { return devtools_url_; }
753 const GURL& details_url() const { return details_url_;} 730 const GURL& details_url() const { return details_url_;}
754 const PermissionSet* optional_permission_set() const { 731 const PermissionSet* optional_permission_set() const {
755 return optional_permission_set_.get(); 732 return optional_permission_set_.get();
756 } 733 }
757 const PermissionSet* required_permission_set() const { 734 const PermissionSet* required_permission_set() const {
758 return required_permission_set_.get(); 735 return required_permission_set_.get();
759 } 736 }
760 // Appends |new_warnings| to install_warnings(). 737 // Appends |new_warning[s]| to install_warnings_.
738 void AddInstallWarning(const InstallWarning& new_warning);
761 void AddInstallWarnings(const InstallWarningVector& new_warnings); 739 void AddInstallWarnings(const InstallWarningVector& new_warnings);
762 const InstallWarningVector& install_warnings() const { 740 const InstallWarningVector& install_warnings() const {
763 return install_warnings_; 741 return install_warnings_;
764 } 742 }
765 const GURL& update_url() const { return update_url_; } 743 const GURL& update_url() const { return update_url_; }
766 const ExtensionIconSet& icons() const { return icons_; } 744 const ExtensionIconSet& icons() const { return icons_; }
767 const extensions::Manifest* manifest() const { 745 const extensions::Manifest* manifest() const {
768 return manifest_.get(); 746 return manifest_.get();
769 } 747 }
770 const std::string default_locale() const { return default_locale_; } 748 const std::string default_locale() const { return default_locale_; }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 bool LoadFileHandlers(string16* error); 925 bool LoadFileHandlers(string16* error);
948 bool LoadExtensionFeatures(APIPermissionSet* api_permissions, 926 bool LoadExtensionFeatures(APIPermissionSet* api_permissions,
949 string16* error); 927 string16* error);
950 bool LoadManifestHandlerFeatures(string16* error); 928 bool LoadManifestHandlerFeatures(string16* error);
951 bool LoadDevToolsPage(string16* error); 929 bool LoadDevToolsPage(string16* error);
952 bool LoadInputComponents(const APIPermissionSet& api_permissions, 930 bool LoadInputComponents(const APIPermissionSet& api_permissions,
953 string16* error); 931 string16* error);
954 bool LoadContentScripts(string16* error); 932 bool LoadContentScripts(string16* error);
955 bool LoadPageAction(string16* error); 933 bool LoadPageAction(string16* error);
956 bool LoadBrowserAction(string16* error); 934 bool LoadBrowserAction(string16* error);
957 bool LoadScriptBadge(string16* error);
958 bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error); 935 bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error);
959 bool LoadFileBrowserHandlers(string16* error); 936 bool LoadFileBrowserHandlers(string16* error);
960 // Helper method to load a FileBrowserHandlerList from the manifest. 937 // Helper method to load a FileBrowserHandlerList from the manifest.
961 FileBrowserHandlerList* LoadFileBrowserHandlersHelper( 938 FileBrowserHandlerList* LoadFileBrowserHandlersHelper(
962 const base::ListValue* extension_actions, string16* error); 939 const base::ListValue* extension_actions, string16* error);
963 // Helper method to load an FileBrowserHandler from manifest. 940 // Helper method to load an FileBrowserHandler from manifest.
964 FileBrowserHandler* LoadFileBrowserHandler( 941 FileBrowserHandler* LoadFileBrowserHandler(
965 const base::DictionaryValue* file_browser_handlers, string16* error); 942 const base::DictionaryValue* file_browser_handlers, string16* error);
966 bool LoadChromeURLOverrides(string16* error); 943 bool LoadChromeURLOverrides(string16* error);
967 bool LoadTextToSpeechVoices(string16* error); 944 bool LoadTextToSpeechVoices(string16* error);
(...skipping 25 matching lines...) Expand all
993 970
994 // Helper method that loads either the include_globs or exclude_globs list 971 // Helper method that loads either the include_globs or exclude_globs list
995 // from an entry in the content_script lists of the manifest. 972 // from an entry in the content_script lists of the manifest.
996 bool LoadGlobsHelper(const base::DictionaryValue* content_script, 973 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
997 int content_script_index, 974 int content_script_index,
998 const char* globs_property_name, 975 const char* globs_property_name,
999 string16* error, 976 string16* error,
1000 void(UserScript::*add_method)(const std::string& glob), 977 void(UserScript::*add_method)(const std::string& glob),
1001 UserScript* instance); 978 UserScript* instance);
1002 979
1003 // Helper method to load an ExtensionAction from the page_action or
1004 // browser_action entries in the manifest.
1005 scoped_ptr<ActionInfo> LoadExtensionActionInfoHelper(
1006 const base::DictionaryValue* manifest_section,
1007 ActionInfo::Type action_type,
Yoyo Zhou 2012/12/18 02:01:41 Cool, this was never used!
1008 string16* error);
1009
1010 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key. 980 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key.
1011 bool LoadOAuth2Info(string16* error); 981 bool LoadOAuth2Info(string16* error);
1012 982
1013 // Returns true if the extension has more than one "UI surface". For example, 983 // Returns true if the extension has more than one "UI surface". For example,
1014 // an extension that has a browser action and a page action. 984 // an extension that has a browser action and a page action.
1015 bool HasMultipleUISurfaces() const; 985 bool HasMultipleUISurfaces() const;
1016 986
1017 // Updates the launch URL and extents for the extension using the given 987 // Updates the launch URL and extents for the extension using the given
1018 // |override_url|. 988 // |override_url|.
1019 void OverrideLaunchUrl(const GURL& override_url); 989 void OverrideLaunchUrl(const GURL& override_url);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 1077
1108 // Paths to the content scripts the extension contains. 1078 // Paths to the content scripts the extension contains.
1109 UserScriptList content_scripts_; 1079 UserScriptList content_scripts_;
1110 1080
1111 // The extension's page action, if any. 1081 // The extension's page action, if any.
1112 scoped_ptr<ActionInfo> page_action_info_; 1082 scoped_ptr<ActionInfo> page_action_info_;
1113 1083
1114 // The extension's browser action, if any. 1084 // The extension's browser action, if any.
1115 scoped_ptr<ActionInfo> browser_action_info_; 1085 scoped_ptr<ActionInfo> browser_action_info_;
1116 1086
1117 // The extension's script badge. Never NULL.
1118 scoped_ptr<ActionInfo> script_badge_info_;
1119
1120 // The extension's system indicator, if any. 1087 // The extension's system indicator, if any.
1121 scoped_ptr<ActionInfo> system_indicator_info_; 1088 scoped_ptr<ActionInfo> system_indicator_info_;
1122 1089
1123 // The extension's file browser actions, if any. 1090 // The extension's file browser actions, if any.
1124 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_; 1091 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_;
1125 1092
1126 // Optional list of NPAPI plugins and associated properties. 1093 // Optional list of NPAPI plugins and associated properties.
1127 std::vector<PluginInfo> plugins_; 1094 std::vector<PluginInfo> plugins_;
1128 1095
1129 // Optional list of NaCl modules and associated properties. 1096 // Optional list of NaCl modules and associated properties.
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 1295
1329 UpdatedExtensionPermissionsInfo( 1296 UpdatedExtensionPermissionsInfo(
1330 const Extension* extension, 1297 const Extension* extension,
1331 const PermissionSet* permissions, 1298 const PermissionSet* permissions,
1332 Reason reason); 1299 Reason reason);
1333 }; 1300 };
1334 1301
1335 } // namespace extensions 1302 } // namespace extensions
1336 1303
1337 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 1304 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698