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

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: Fix aa's and kalman's comments. 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 const GURL& options_url() const { return options_url_; } 638 const GURL& options_url() const { return options_url_; }
640 const GURL& devtools_url() const { return devtools_url_; } 639 const GURL& devtools_url() const { return devtools_url_; }
641 const ExtensionPermissionSet* optional_permission_set() const { 640 const ExtensionPermissionSet* optional_permission_set() const {
642 return optional_permission_set_.get(); 641 return optional_permission_set_.get();
643 } 642 }
644 const ExtensionPermissionSet* required_permission_set() const { 643 const ExtensionPermissionSet* required_permission_set() const {
645 return required_permission_set_.get(); 644 return required_permission_set_.get();
646 } 645 }
647 // Appends |new_warnings| to install_warnings(). 646 // Appends |new_warnings| to install_warnings().
648 void AddInstallWarnings(const InstallWarningVector& new_warnings); 647 void AddInstallWarnings(const InstallWarningVector& new_warnings);
648 // Adds an install warning for developers' benefit, which won't
649 // bother normal users.
650 void AddDeveloperInstallWarning(InstallWarning::Format format,
651 const std::string& message);
649 const InstallWarningVector& install_warnings() const { 652 const InstallWarningVector& install_warnings() const {
650 return install_warnings_; 653 return install_warnings_;
651 } 654 }
652 const GURL& update_url() const { return update_url_; } 655 const GURL& update_url() const { return update_url_; }
653 const ExtensionIconSet& icons() const { return icons_; } 656 const ExtensionIconSet& icons() const { return icons_; }
654 const extensions::Manifest* manifest() const { 657 const extensions::Manifest* manifest() const {
655 return manifest_; 658 return manifest_;
656 } 659 }
657 const std::string default_locale() const { return default_locale_; } 660 const std::string default_locale() const { return default_locale_; }
658 const URLOverrideMap& GetChromeURLOverrides() const { 661 const URLOverrideMap& GetChromeURLOverrides() const {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 string16* error); 818 string16* error);
816 bool LoadWebIntentServices(string16* error); 819 bool LoadWebIntentServices(string16* error);
817 bool LoadExtensionFeatures(const ExtensionAPIPermissionSet& api_permissions, 820 bool LoadExtensionFeatures(const ExtensionAPIPermissionSet& api_permissions,
818 string16* error); 821 string16* error);
819 bool LoadDevToolsPage(string16* error); 822 bool LoadDevToolsPage(string16* error);
820 bool LoadInputComponents(const ExtensionAPIPermissionSet& api_permissions, 823 bool LoadInputComponents(const ExtensionAPIPermissionSet& api_permissions,
821 string16* error); 824 string16* error);
822 bool LoadContentScripts(string16* error); 825 bool LoadContentScripts(string16* error);
823 bool LoadPageAction(string16* error); 826 bool LoadPageAction(string16* error);
824 bool LoadBrowserAction(string16* error); 827 bool LoadBrowserAction(string16* error);
828 bool LoadScriptBadge(string16* error);
825 bool LoadFileBrowserHandlers(string16* error); 829 bool LoadFileBrowserHandlers(string16* error);
826 // Helper method to load a FileBrowserHandlerList from the manifest. 830 // Helper method to load a FileBrowserHandlerList from the manifest.
827 FileBrowserHandlerList* LoadFileBrowserHandlersHelper( 831 FileBrowserHandlerList* LoadFileBrowserHandlersHelper(
828 const base::ListValue* extension_actions, string16* error); 832 const base::ListValue* extension_actions, string16* error);
829 // Helper method to load an FileBrowserHandler from manifest. 833 // Helper method to load an FileBrowserHandler from manifest.
830 FileBrowserHandler* LoadFileBrowserHandler( 834 FileBrowserHandler* LoadFileBrowserHandler(
831 const base::DictionaryValue* file_browser_handlers, string16* error); 835 const base::DictionaryValue* file_browser_handlers, string16* error);
832 bool LoadChromeURLOverrides(string16* error); 836 bool LoadChromeURLOverrides(string16* error);
833 bool LoadOmnibox(string16* error); 837 bool LoadOmnibox(string16* error);
834 bool LoadTextToSpeechVoices(string16* error); 838 bool LoadTextToSpeechVoices(string16* error);
(...skipping 28 matching lines...) Expand all
863 bool LoadGlobsHelper(const base::DictionaryValue* content_script, 867 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
864 int content_script_index, 868 int content_script_index,
865 const char* globs_property_name, 869 const char* globs_property_name,
866 string16* error, 870 string16* error,
867 void(UserScript::*add_method)(const std::string& glob), 871 void(UserScript::*add_method)(const std::string& glob),
868 UserScript *instance); 872 UserScript *instance);
869 873
870 // Helper method to load an ExtensionAction from the page_action or 874 // Helper method to load an ExtensionAction from the page_action or
871 // browser_action entries in the manifest. 875 // browser_action entries in the manifest.
872 scoped_ptr<ExtensionAction> LoadExtensionActionHelper( 876 scoped_ptr<ExtensionAction> LoadExtensionActionHelper(
873 const base::DictionaryValue* extension_action, string16* error); 877 const base::DictionaryValue* extension_action,
878 ExtensionAction::Type action_type,
879 string16* error);
874 880
875 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key. 881 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key.
876 bool LoadOAuth2Info(string16* error); 882 bool LoadOAuth2Info(string16* error);
877 883
878 // Returns true if the extension has more than one "UI surface". For example, 884 // 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. 885 // an extension that has a browser action and a page action.
880 bool HasMultipleUISurfaces() const; 886 bool HasMultipleUISurfaces() const;
881 887
882 // Updates the launch URL and extents for the extension using the given 888 // Updates the launch URL and extents for the extension using the given
883 // |override_url|. 889 // |override_url|.
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 1129
1124 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper); 1130 FRIEND_TEST_ALL_PREFIXES(ExtensionTest, LoadPageActionHelper);
1125 FRIEND_TEST_ALL_PREFIXES(::TabStripModelTest, Apps); 1131 FRIEND_TEST_ALL_PREFIXES(::TabStripModelTest, Apps);
1126 1132
1127 DISALLOW_COPY_AND_ASSIGN(Extension); 1133 DISALLOW_COPY_AND_ASSIGN(Extension);
1128 }; 1134 };
1129 1135
1130 typedef std::vector< scoped_refptr<const Extension> > ExtensionList; 1136 typedef std::vector< scoped_refptr<const Extension> > ExtensionList;
1131 typedef std::set<std::string> ExtensionIdSet; 1137 typedef std::set<std::string> ExtensionIdSet;
1132 1138
1139 // Let gtest print InstallWarnings.
1140 void PrintTo(const Extension::InstallWarning&, ::std::ostream* os);
1141
1133 // Handy struct to pass core extension info around. 1142 // Handy struct to pass core extension info around.
1134 struct ExtensionInfo { 1143 struct ExtensionInfo {
1135 ExtensionInfo(const base::DictionaryValue* manifest, 1144 ExtensionInfo(const base::DictionaryValue* manifest,
1136 const std::string& id, 1145 const std::string& id,
1137 const FilePath& path, 1146 const FilePath& path,
1138 Extension::Location location); 1147 Extension::Location location);
1139 ~ExtensionInfo(); 1148 ~ExtensionInfo();
1140 1149
1141 scoped_ptr<base::DictionaryValue> extension_manifest; 1150 scoped_ptr<base::DictionaryValue> extension_manifest;
1142 std::string extension_id; 1151 std::string extension_id;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 1189
1181 UpdatedExtensionPermissionsInfo( 1190 UpdatedExtensionPermissionsInfo(
1182 const Extension* extension, 1191 const Extension* extension,
1183 const ExtensionPermissionSet* permissions, 1192 const ExtensionPermissionSet* permissions,
1184 Reason reason); 1193 Reason reason);
1185 }; 1194 };
1186 1195
1187 } // namespace extensions 1196 } // namespace extensions
1188 1197
1189 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 1198 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698