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

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

Issue 10565017: Parse the script_badge manifest section. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Back out support for setting switches in unittests. Created 8 years, 6 months 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 #pragma once 7 #pragma once
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iosfwd>
10 #include <map> 11 #include <map>
11 #include <set> 12 #include <set>
12 #include <string> 13 #include <string>
13 #include <utility> 14 #include <utility>
14 #include <vector> 15 #include <vector>
15 16
16 #include "base/file_path.h" 17 #include "base/file_path.h"
17 #include "base/gtest_prod_util.h" 18 #include "base/gtest_prod_util.h"
18 #include "base/hash_tables.h" 19 #include "base/hash_tables.h"
19 #include "base/memory/linked_ptr.h" 20 #include "base/memory/linked_ptr.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 struct InstallWarning { 189 struct InstallWarning {
189 enum Format { 190 enum Format {
190 // IMPORTANT: Do not build HTML strings from user or developer-supplied 191 // IMPORTANT: Do not build HTML strings from user or developer-supplied
191 // input. 192 // input.
192 FORMAT_TEXT, 193 FORMAT_TEXT,
193 FORMAT_HTML, 194 FORMAT_HTML,
194 }; 195 };
195 InstallWarning(Format format, const std::string& message) 196 InstallWarning(Format format, const std::string& message)
196 : format(format), message(message) { 197 : format(format), message(message) {
197 } 198 }
199 bool operator==(const InstallWarning& other) const;
198 Format format; 200 Format format;
199 std::string message; 201 std::string message;
200 }; 202 };
201 203
202 enum InitFromValueFlags { 204 enum InitFromValueFlags {
203 NO_FLAGS = 0, 205 NO_FLAGS = 0,
204 206
205 // Usually, the id of an extension is generated by the "key" property of 207 // Usually, the id of an extension is generated by the "key" property of
206 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be 208 // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be
207 // generated based on the path. 209 // generated based on the path.
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 // Returns true if the extension should be displayed in the launcher. 545 // Returns true if the extension should be displayed in the launcher.
544 bool ShouldDisplayInLauncher() const; 546 bool ShouldDisplayInLauncher() const;
545 547
546 // Returns true if the extension should be displayed in the extension 548 // Returns true if the extension should be displayed in the extension
547 // settings page (i.e. chrome://extensions). 549 // settings page (i.e. chrome://extensions).
548 bool ShouldDisplayInExtensionSettings() const; 550 bool ShouldDisplayInExtensionSettings() const;
549 551
550 // Returns true if the extension has a content script declared at |url|. 552 // Returns true if the extension has a content script declared at |url|.
551 bool HasContentScriptAtURL(const GURL& url) const; 553 bool HasContentScriptAtURL(const GURL& url) const;
552 554
553 // Returns an ExtensionAction representing the script badge that should be
554 // shown for this extension in the location bar.
555 ExtensionAction* GetScriptBadge() const;
556
557 // Gets the tab-specific host permissions of |tab_id|, or NULL if there 555 // Gets the tab-specific host permissions of |tab_id|, or NULL if there
558 // aren't any. 556 // aren't any.
559 // 557 //
560 // This is a weak pointer. Callers should create a copy before mutating any 558 // This is a weak pointer. Callers should create a copy before mutating any
561 // tab specific permissions. 559 // tab specific permissions.
562 const URLPatternSet* GetTabSpecificHostPermissions(int tab_id) const; 560 const URLPatternSet* GetTabSpecificHostPermissions(int tab_id) const;
563 561
564 // Sets the tab-specific host permissions of |tab_id| to |permissions|. 562 // Sets the tab-specific host permissions of |tab_id| to |permissions|.
565 void SetTabSpecificHostPermissions(int tab_id, 563 void SetTabSpecificHostPermissions(int tab_id,
566 const URLPatternSet& permissions) const; 564 const URLPatternSet& permissions) const;
(...skipping 14 matching lines...) Expand all
581 // Base64-encoded version of the key used to sign this extension. 579 // Base64-encoded version of the key used to sign this extension.
582 // In pseudocode, returns 580 // In pseudocode, returns
583 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). 581 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()).
584 const std::string& public_key() const { return public_key_; } 582 const std::string& public_key() const { return public_key_; }
585 const std::string& description() const { return description_; } 583 const std::string& description() const { return description_; }
586 int manifest_version() const { return manifest_version_; } 584 int manifest_version() const { return manifest_version_; }
587 bool converted_from_user_script() const { 585 bool converted_from_user_script() const {
588 return converted_from_user_script_; 586 return converted_from_user_script_;
589 } 587 }
590 const UserScriptList& content_scripts() const { return content_scripts_; } 588 const UserScriptList& content_scripts() const { return content_scripts_; }
589 ExtensionAction* script_badge() const { return script_badge_.get(); }
591 ExtensionAction* page_action() const { return page_action_.get(); } 590 ExtensionAction* page_action() const { return page_action_.get(); }
592 ExtensionAction* browser_action() const { return browser_action_.get(); } 591 ExtensionAction* browser_action() const { return browser_action_.get(); }
593 ExtensionAction::Type declared_action_type() const { 592 ExtensionAction::Type declared_action_type() const {
594 return declared_action_type_; 593 return declared_action_type_;
595 } 594 }
596 const FileBrowserHandlerList* file_browser_handlers() const { 595 const FileBrowserHandlerList* file_browser_handlers() const {
597 return file_browser_handlers_.get(); 596 return file_browser_handlers_.get();
598 } 597 }
599 const std::vector<PluginInfo>& plugins() const { return plugins_; } 598 const std::vector<PluginInfo>& plugins() const { return plugins_; }
600 const std::vector<NaClModuleInfo>& nacl_modules() const { 599 const std::vector<NaClModuleInfo>& nacl_modules() const {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 string16* error); 814 string16* error);
816 bool LoadWebIntentServices(string16* error); 815 bool LoadWebIntentServices(string16* error);
817 bool LoadExtensionFeatures(const ExtensionAPIPermissionSet& api_permissions, 816 bool LoadExtensionFeatures(const ExtensionAPIPermissionSet& api_permissions,
818 string16* error); 817 string16* error);
819 bool LoadDevToolsPage(string16* error); 818 bool LoadDevToolsPage(string16* error);
820 bool LoadInputComponents(const ExtensionAPIPermissionSet& api_permissions, 819 bool LoadInputComponents(const ExtensionAPIPermissionSet& api_permissions,
821 string16* error); 820 string16* error);
822 bool LoadContentScripts(string16* error); 821 bool LoadContentScripts(string16* error);
823 bool LoadPageAction(string16* error); 822 bool LoadPageAction(string16* error);
824 bool LoadBrowserAction(string16* error); 823 bool LoadBrowserAction(string16* error);
824 bool LoadScriptBadge(string16* error);
825 bool LoadFileBrowserHandlers(string16* error); 825 bool LoadFileBrowserHandlers(string16* error);
826 // Helper method to load a FileBrowserHandlerList from the manifest. 826 // Helper method to load a FileBrowserHandlerList from the manifest.
827 FileBrowserHandlerList* LoadFileBrowserHandlersHelper( 827 FileBrowserHandlerList* LoadFileBrowserHandlersHelper(
828 const base::ListValue* extension_actions, string16* error); 828 const base::ListValue* extension_actions, string16* error);
829 // Helper method to load an FileBrowserHandler from manifest. 829 // Helper method to load an FileBrowserHandler from manifest.
830 FileBrowserHandler* LoadFileBrowserHandler( 830 FileBrowserHandler* LoadFileBrowserHandler(
831 const base::DictionaryValue* file_browser_handlers, string16* error); 831 const base::DictionaryValue* file_browser_handlers, string16* error);
832 bool LoadChromeURLOverrides(string16* error); 832 bool LoadChromeURLOverrides(string16* error);
833 bool LoadOmnibox(string16* error); 833 bool LoadOmnibox(string16* error);
834 bool LoadTextToSpeechVoices(string16* error); 834 bool LoadTextToSpeechVoices(string16* error);
(...skipping 28 matching lines...) Expand all
863 bool LoadGlobsHelper(const base::DictionaryValue* content_script, 863 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
864 int content_script_index, 864 int content_script_index,
865 const char* globs_property_name, 865 const char* globs_property_name,
866 string16* error, 866 string16* error,
867 void(UserScript::*add_method)(const std::string& glob), 867 void(UserScript::*add_method)(const std::string& glob),
868 UserScript *instance); 868 UserScript *instance);
869 869
870 // Helper method to load an ExtensionAction from the page_action or 870 // Helper method to load an ExtensionAction from the page_action or
871 // browser_action entries in the manifest. 871 // browser_action entries in the manifest.
872 scoped_ptr<ExtensionAction> LoadExtensionActionHelper( 872 scoped_ptr<ExtensionAction> LoadExtensionActionHelper(
873 const base::DictionaryValue* extension_action, string16* error); 873 const base::DictionaryValue* extension_action,
874 ExtensionAction::Type action_type,
875 string16* error);
874 876
875 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key. 877 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key.
876 bool LoadOAuth2Info(string16* error); 878 bool LoadOAuth2Info(string16* error);
877 879
878 // Returns true if the extension has more than one "UI surface". For example, 880 // Returns true if the extension has more than one "UI surface". For example,
879 // an extension that has a browser action and a page action. 881 // an extension that has a browser action and a page action.
880 bool HasMultipleUISurfaces() const; 882 bool HasMultipleUISurfaces() const;
881 883
882 // Updates the launch URL and extents for the extension using the given 884 // Updates the launch URL and extents for the extension using the given
883 // |override_url|. 885 // |override_url|.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 975
974 // The extension's browser action, if any. 976 // The extension's browser action, if any.
975 scoped_ptr<ExtensionAction> browser_action_; 977 scoped_ptr<ExtensionAction> browser_action_;
976 978
977 // Indicates the type of action (browser or page) that the extension declared 979 // Indicates the type of action (browser or page) that the extension declared
978 // in its manifest. This doesn't imply any value for page_action or 980 // in its manifest. This doesn't imply any value for page_action or
979 // browser_action, since page actions may be turned into browser actions and 981 // browser_action, since page actions may be turned into browser actions and
980 // browser actions may be generated without any action declared. 982 // browser actions may be generated without any action declared.
981 ExtensionAction::Type declared_action_type_; 983 ExtensionAction::Type declared_action_type_;
982 984
983 // The extension's script badge. Lazily populated (and subsequently updated) 985 // The extension's script badge. Never NULL.
984 // as required by GetScriptBadge. 986 scoped_ptr<ExtensionAction> script_badge_;
985 mutable scoped_ptr<ExtensionAction> script_badge_;
986 987
987 // The extension's file browser actions, if any. 988 // The extension's file browser actions, if any.
988 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_; 989 scoped_ptr<FileBrowserHandlerList> file_browser_handlers_;
989 990
990 // Optional list of NPAPI plugins and associated properties. 991 // Optional list of NPAPI plugins and associated properties.
991 std::vector<PluginInfo> plugins_; 992 std::vector<PluginInfo> plugins_;
992 993
993 // Optional list of NaCl modules and associated properties. 994 // Optional list of NaCl modules and associated properties.
994 std::vector<NaClModuleInfo> nacl_modules_; 995 std::vector<NaClModuleInfo> nacl_modules_;
995 996
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 1124
1124 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper); 1125 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper);
1125 FRIEND_TEST_ALL_PREFIXES(::TabStripModelTest, Apps); 1126 FRIEND_TEST_ALL_PREFIXES(::TabStripModelTest, Apps);
1126 1127
1127 DISALLOW_COPY_AND_ASSIGN(Extension); 1128 DISALLOW_COPY_AND_ASSIGN(Extension);
1128 }; 1129 };
1129 1130
1130 typedef std::vector< scoped_refptr<const Extension> > ExtensionList; 1131 typedef std::vector< scoped_refptr<const Extension> > ExtensionList;
1131 typedef std::set<std::string> ExtensionIdSet; 1132 typedef std::set<std::string> ExtensionIdSet;
1132 1133
1134 // Let gtest print InstallWarnings.
1135 void PrintTo(const Extension::InstallWarning&, ::std::ostream* os);
1136
1133 // Handy struct to pass core extension info around. 1137 // Handy struct to pass core extension info around.
1134 struct ExtensionInfo { 1138 struct ExtensionInfo {
1135 ExtensionInfo(const base::DictionaryValue* manifest, 1139 ExtensionInfo(const base::DictionaryValue* manifest,
1136 const std::string& id, 1140 const std::string& id,
1137 const FilePath& path, 1141 const FilePath& path,
1138 Extension::Location location); 1142 Extension::Location location);
1139 ~ExtensionInfo(); 1143 ~ExtensionInfo();
1140 1144
1141 scoped_ptr<base::DictionaryValue> extension_manifest; 1145 scoped_ptr<base::DictionaryValue> extension_manifest;
1142 std::string extension_id; 1146 std::string extension_id;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 1184
1181 UpdatedExtensionPermissionsInfo( 1185 UpdatedExtensionPermissionsInfo(
1182 const Extension* extension, 1186 const Extension* extension,
1183 const ExtensionPermissionSet* permissions, 1187 const ExtensionPermissionSet* permissions,
1184 Reason reason); 1188 Reason reason);
1185 }; 1189 };
1186 1190
1187 } // namespace extensions 1191 } // namespace extensions
1188 1192
1189 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 1193 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/_manifest_features.json ('k') | chrome/common/extensions/extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698