SupportsUserData and manifest handlers for Extension; use them for the Omnibox API.

Note that manifest handlers aren't available in the renderer (there seems to be no place to register them). At least for Omnibox, the renderer doesn't need to parse the manifest field, but this won't be true everywhere.
Pull a bunch of Omnibox API stuff out of ExtensionService.

BUG=159265


Review URL: https://chromiumcodereview.appspot.com/11446034

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172638 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index fc93fbc2..0d47680 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -65,11 +65,14 @@
 class Extension : public base::RefCountedThreadSafe<Extension> {
  public:
   struct InstallWarning;
+  struct ManifestData;
 
   typedef std::map<const std::string, GURL> URLOverrideMap;
   typedef std::vector<std::string> ScriptingWhitelist;
   typedef std::vector<linked_ptr<FileBrowserHandler> > FileBrowserHandlerList;
   typedef std::vector<InstallWarning> InstallWarningVector;
+  typedef std::map<const std::string, linked_ptr<ManifestData> >
+      ManifestDataMap;
 
   // What an extension was loaded from.
   // NOTE: These values are stored as integers in the preferences and used
@@ -267,6 +270,13 @@
     std::string message;
   };
 
+  // A base class for parsed manifest data that APIs want to store on
+  // the extension. Related to base::SupportsUserData, but with an immutable
+  // thread-safe interface to match Extension.
+  struct ManifestData {
+    virtual ~ManifestData() {}
+  };
+
   enum InitFromValueFlags {
     NO_FLAGS = 0,
 
@@ -659,6 +669,15 @@
   // Clears the tab-specific permissions of |tab_id|.
   void ClearTabSpecificPermissions(int tab_id) const;
 
+  // Get the manifest data associated with the key, or NULL if there is none.
+  // Can only be called after InitValue is finished.
+  ManifestData* GetManifestData(const std::string& key) const;
+
+  // Sets |data| to be associated with the key. Takes ownership of |data|.
+  // Can only be called before InitValue is finished. Not thread-safe;
+  // all SetManifestData calls should be on only one thread.
+  void SetManifestData(const std::string& key, ManifestData* data);
+
   // Accessors:
 
   const Requirements& requirements() const { return requirements_; }
@@ -690,13 +709,6 @@
   const ActionInfo* system_indicator_info() const {
     return system_indicator_info_.get();
   }
-  bool is_verbose_install_message() const {
-    return !omnibox_keyword().empty() ||
-           browser_action_info() ||
-           (page_action_info() &&
-            (page_action_command() ||
-             !page_action_info()->default_icon.empty()));
-  }
   const FileBrowserHandlerList* file_browser_handlers() const {
     return file_browser_handlers_.get();
   }
@@ -769,7 +781,6 @@
   const URLOverrideMap& GetChromeURLOverrides() const {
     return chrome_url_overrides_;
   }
-  const std::string omnibox_keyword() const { return omnibox_keyword_; }
   bool incognito_split_mode() const { return incognito_split_mode_; }
   bool offline_enabled() const { return offline_enabled_; }
   const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; }
@@ -876,7 +887,7 @@
   static bool IsTrustedId(const std::string& id);
 
   Extension(const FilePath& path, scoped_ptr<extensions::Manifest> manifest);
-  ~Extension();
+  virtual ~Extension();
 
   // Initialize the extension from a parsed manifest.
   // TODO(aa): Rename to just Init()? There's no Value here anymore.
@@ -946,6 +957,7 @@
   bool LoadFileHandlers(string16* error);
   bool LoadExtensionFeatures(APIPermissionSet* api_permissions,
                              string16* error);
+  bool LoadManifestHandlerFeatures(string16* error);
   bool LoadDevToolsPage(string16* error);
   bool LoadInputComponents(const APIPermissionSet& api_permissions,
                            string16* error);
@@ -962,7 +974,6 @@
   FileBrowserHandler* LoadFileBrowserHandler(
       const base::DictionaryValue* file_browser_handlers, string16* error);
   bool LoadChromeURLOverrides(string16* error);
-  bool LoadOmnibox(string16* error);
   bool LoadTextToSpeechVoices(string16* error);
   bool LoadIncognitoMode(string16* error);
   bool LoadContentSecurityPolicy(string16* error);
@@ -1201,6 +1212,12 @@
   // The manifest from which this extension was created.
   scoped_ptr<Manifest> manifest_;
 
+  // Stored parsed manifest data.
+  ManifestDataMap manifest_data_;
+
+  // Set to true at the end of InitValue when initialization is finished.
+  bool finished_parsing_manifest_;
+
   // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs
   // which override the handling of those URLs. (see ExtensionOverrideUI).
   URLOverrideMap chrome_url_overrides_;
@@ -1233,9 +1250,6 @@
   // Should this app be shown in the browser New Tab Page.
   bool display_in_new_tab_page_;
 
-  // The Omnibox keyword for this extension, or empty if there is none.
-  std::string omnibox_keyword_;
-
   // List of text-to-speech voices that this extension provides, if any.
   std::vector<TtsVoice> tts_voices_;