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

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: Yoyo's requested changes 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 struct OAuth2Info { 216 struct OAuth2Info {
216 OAuth2Info(); 217 OAuth2Info();
217 ~OAuth2Info(); 218 ~OAuth2Info();
218 219
219 OAuth2Scopes GetScopesAsSet(); 220 OAuth2Scopes GetScopesAsSet();
220 221
221 std::string client_id; 222 std::string client_id;
222 std::vector<std::string> scopes; 223 std::vector<std::string> scopes;
223 }; 224 };
224 225
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 { 226 struct FileHandlerInfo {
246 explicit FileHandlerInfo(); 227 explicit FileHandlerInfo();
247 ~FileHandlerInfo(); 228 ~FileHandlerInfo();
248 std::string id; 229 std::string id;
249 std::string title; 230 std::string title;
250 231
251 // File extensions associated with this handler. 232 // File extensions associated with this handler.
252 std::set<std::string> extensions; 233 std::set<std::string> extensions;
253 234
254 // MIME types associated with this handler. 235 // 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. 663 // Base64-encoded version of the key used to sign this extension.
683 // In pseudocode, returns 664 // In pseudocode, returns
684 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). 665 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()).
685 const std::string& public_key() const { return public_key_; } 666 const std::string& public_key() const { return public_key_; }
686 const std::string& description() const { return description_; } 667 const std::string& description() const { return description_; }
687 int manifest_version() const { return manifest_version_; } 668 int manifest_version() const { return manifest_version_; }
688 bool converted_from_user_script() const { 669 bool converted_from_user_script() const {
689 return converted_from_user_script_; 670 return converted_from_user_script_;
690 } 671 }
691 const UserScriptList& content_scripts() const { return content_scripts_; } 672 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(); } 673 const ActionInfo* page_action_info() const { return page_action_info_.get(); }
696 const ActionInfo* browser_action_info() const { 674 const ActionInfo* browser_action_info() const {
697 return browser_action_info_.get(); 675 return browser_action_info_.get();
698 } 676 }
699 const ActionInfo* system_indicator_info() const { 677 const ActionInfo* system_indicator_info() const {
700 return system_indicator_info_.get(); 678 return system_indicator_info_.get();
701 } 679 }
702 const FileBrowserHandlerList* file_browser_handlers() const { 680 const FileBrowserHandlerList* file_browser_handlers() const {
703 return file_browser_handlers_.get(); 681 return file_browser_handlers_.get();
704 } 682 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 } 728 }
751 const GURL& options_url() const { return options_url_; } 729 const GURL& options_url() const { return options_url_; }
752 const GURL& devtools_url() const { return devtools_url_; } 730 const GURL& devtools_url() const { return devtools_url_; }
753 const GURL& details_url() const { return details_url_;} 731 const GURL& details_url() const { return details_url_;}
754 const PermissionSet* optional_permission_set() const { 732 const PermissionSet* optional_permission_set() const {
755 return optional_permission_set_.get(); 733 return optional_permission_set_.get();
756 } 734 }
757 const PermissionSet* required_permission_set() const { 735 const PermissionSet* required_permission_set() const {
758 return required_permission_set_.get(); 736 return required_permission_set_.get();
759 } 737 }
760 // Appends |new_warnings| to install_warnings(). 738 // Appends |new_warning[s]| to install_warnings_.
739 void AddInstallWarning(const InstallWarning& new_warning);
761 void AddInstallWarnings(const InstallWarningVector& new_warnings); 740 void AddInstallWarnings(const InstallWarningVector& new_warnings);
762 const InstallWarningVector& install_warnings() const { 741 const InstallWarningVector& install_warnings() const {
763 return install_warnings_; 742 return install_warnings_;
764 } 743 }
765 const GURL& update_url() const { return update_url_; } 744 const GURL& update_url() const { return update_url_; }
766 const ExtensionIconSet& icons() const { return icons_; } 745 const ExtensionIconSet& icons() const { return icons_; }
767 const extensions::Manifest* manifest() const { 746 const extensions::Manifest* manifest() const {
768 return manifest_.get(); 747 return manifest_.get();
769 } 748 }
770 const std::string default_locale() const { return default_locale_; } 749 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); 926 bool LoadFileHandlers(string16* error);
948 bool LoadExtensionFeatures(APIPermissionSet* api_permissions, 927 bool LoadExtensionFeatures(APIPermissionSet* api_permissions,
949 string16* error); 928 string16* error);
950 bool LoadManifestHandlerFeatures(string16* error); 929 bool LoadManifestHandlerFeatures(string16* error);
951 bool LoadDevToolsPage(string16* error); 930 bool LoadDevToolsPage(string16* error);
952 bool LoadInputComponents(const APIPermissionSet& api_permissions, 931 bool LoadInputComponents(const APIPermissionSet& api_permissions,
953 string16* error); 932 string16* error);
954 bool LoadContentScripts(string16* error); 933 bool LoadContentScripts(string16* error);
955 bool LoadPageAction(string16* error); 934 bool LoadPageAction(string16* error);
956 bool LoadBrowserAction(string16* error); 935 bool LoadBrowserAction(string16* error);
957 bool LoadScriptBadge(string16* error);
958 bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error); 936 bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error);
959 bool LoadFileBrowserHandlers(string16* error); 937 bool LoadFileBrowserHandlers(string16* error);
960 // Helper method to load a FileBrowserHandlerList from the manifest. 938 // Helper method to load a FileBrowserHandlerList from the manifest.
961 FileBrowserHandlerList* LoadFileBrowserHandlersHelper( 939 FileBrowserHandlerList* LoadFileBrowserHandlersHelper(
962 const base::ListValue* extension_actions, string16* error); 940 const base::ListValue* extension_actions, string16* error);
963 // Helper method to load an FileBrowserHandler from manifest. 941 // Helper method to load an FileBrowserHandler from manifest.
964 FileBrowserHandler* LoadFileBrowserHandler( 942 FileBrowserHandler* LoadFileBrowserHandler(
965 const base::DictionaryValue* file_browser_handlers, string16* error); 943 const base::DictionaryValue* file_browser_handlers, string16* error);
966 bool LoadChromeURLOverrides(string16* error); 944 bool LoadChromeURLOverrides(string16* error);
967 bool LoadTextToSpeechVoices(string16* error); 945 bool LoadTextToSpeechVoices(string16* error);
(...skipping 25 matching lines...) Expand all
993 971
994 // Helper method that loads either the include_globs or exclude_globs list 972 // Helper method that loads either the include_globs or exclude_globs list
995 // from an entry in the content_script lists of the manifest. 973 // from an entry in the content_script lists of the manifest.
996 bool LoadGlobsHelper(const base::DictionaryValue* content_script, 974 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
997 int content_script_index, 975 int content_script_index,
998 const char* globs_property_name, 976 const char* globs_property_name,
999 string16* error, 977 string16* error,
1000 void(UserScript::*add_method)(const std::string& glob), 978 void(UserScript::*add_method)(const std::string& glob),
1001 UserScript* instance); 979 UserScript* instance);
1002 980
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,
1008 string16* error);
1009
1010 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key. 981 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key.
1011 bool LoadOAuth2Info(string16* error); 982 bool LoadOAuth2Info(string16* error);
1012 983
1013 // Returns true if the extension has more than one "UI surface". For example, 984 // 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. 985 // an extension that has a browser action and a page action.
1015 bool HasMultipleUISurfaces() const; 986 bool HasMultipleUISurfaces() const;
1016 987
1017 // Updates the launch URL and extents for the extension using the given 988 // Updates the launch URL and extents for the extension using the given
1018 // |override_url|. 989 // |override_url|.
1019 void OverrideLaunchUrl(const GURL& override_url); 990 void OverrideLaunchUrl(const GURL& override_url);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 1078
1108 // Paths to the content scripts the extension contains. 1079 // Paths to the content scripts the extension contains.
1109 UserScriptList content_scripts_; 1080 UserScriptList content_scripts_;
1110 1081
1111 // The extension's page action, if any. 1082 // The extension's page action, if any.
1112 scoped_ptr<ActionInfo> page_action_info_; 1083 scoped_ptr<ActionInfo> page_action_info_;
1113 1084
1114 // The extension's browser action, if any. 1085 // The extension's browser action, if any.
1115 scoped_ptr<ActionInfo> browser_action_info_; 1086 scoped_ptr<ActionInfo> browser_action_info_;
1116 1087
1117 // The extension's script badge. Never NULL.
1118 scoped_ptr<ActionInfo> script_badge_info_;
1119
1120 // The extension's system indicator, if any. 1088 // The extension's system indicator, if any.
1121 scoped_ptr<ActionInfo> system_indicator_info_; 1089 scoped_ptr<ActionInfo> system_indicator_info_;
1122 1090
1123 // The extension's file browser actions, if any. 1091 // The extension's file browser actions, if any.
1124 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_; 1092 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_;
1125 1093
1126 // Optional list of NPAPI plugins and associated properties. 1094 // Optional list of NPAPI plugins and associated properties.
1127 std::vector<PluginInfo> plugins_; 1095 std::vector<PluginInfo> plugins_;
1128 1096
1129 // Optional list of NaCl modules and associated properties. 1097 // Optional list of NaCl modules and associated properties.
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 1296
1329 UpdatedExtensionPermissionsInfo( 1297 UpdatedExtensionPermissionsInfo(
1330 const Extension* extension, 1298 const Extension* extension,
1331 const PermissionSet* permissions, 1299 const PermissionSet* permissions,
1332 Reason reason); 1300 Reason reason);
1333 }; 1301 };
1334 1302
1335 } // namespace extensions 1303 } // namespace extensions
1336 1304
1337 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 1305 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698