| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 static const char* kExtensionRegistryPath; | 100 static const char* kExtensionRegistryPath; |
| 101 #endif | 101 #endif |
| 102 | 102 |
| 103 // The number of bytes in a legal id. | 103 // The number of bytes in a legal id. |
| 104 static const size_t kIdSize; | 104 static const size_t kIdSize; |
| 105 | 105 |
| 106 // The mimetype used for extensions. | 106 // The mimetype used for extensions. |
| 107 static const char kMimeType[]; | 107 static const char kMimeType[]; |
| 108 | 108 |
| 109 Extension() | 109 Extension() |
| 110 : location_(INVALID), is_theme_(false), background_page_ready_(false) {} | 110 : location_(INVALID), browser_action_(NULL), is_theme_(false), |
| 111 background_page_ready_(false) {} |
| 111 explicit Extension(const FilePath& path); | 112 explicit Extension(const FilePath& path); |
| 112 virtual ~Extension(); | 113 virtual ~Extension(); |
| 113 | 114 |
| 114 // Resets the id counter. This is only useful for unit tests. | 115 // Resets the id counter. This is only useful for unit tests. |
| 115 static void ResetGeneratedIdCounter() { | 116 static void ResetGeneratedIdCounter() { |
| 116 id_counter_ = 0; | 117 id_counter_ = 0; |
| 117 } | 118 } |
| 118 | 119 |
| 119 // Checks to see if the extension has a valid ID. | 120 // Checks to see if the extension has a valid ID. |
| 120 static bool IdIsValid(const std::string& id); | 121 static bool IdIsValid(const std::string& id); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 const Location location() const { return location_; } | 187 const Location location() const { return location_; } |
| 187 void set_location(Location location) { location_ = location; } | 188 void set_location(Location location) { location_ = location; } |
| 188 const std::string& id() const { return id_; } | 189 const std::string& id() const { return id_; } |
| 189 const Version* version() const { return version_.get(); } | 190 const Version* version() const { return version_.get(); } |
| 190 // String representation of the version number. | 191 // String representation of the version number. |
| 191 const std::string VersionString() const; | 192 const std::string VersionString() const; |
| 192 const std::string& name() const { return name_; } | 193 const std::string& name() const { return name_; } |
| 193 const std::string& public_key() const { return public_key_; } | 194 const std::string& public_key() const { return public_key_; } |
| 194 const std::string& description() const { return description_; } | 195 const std::string& description() const { return description_; } |
| 195 const UserScriptList& content_scripts() const { return content_scripts_; } | 196 const UserScriptList& content_scripts() const { return content_scripts_; } |
| 196 const PageActionMap& page_actions() const { return page_actions_; } | 197 const ContextualActionMap& page_actions() const { return page_actions_; } |
| 198 ContextualAction* browser_action() const { return browser_action_; } |
| 197 const std::vector<PrivacyBlacklistInfo>& privacy_blacklists() const { | 199 const std::vector<PrivacyBlacklistInfo>& privacy_blacklists() const { |
| 198 return privacy_blacklists_; | 200 return privacy_blacklists_; |
| 199 } | 201 } |
| 200 const std::vector<PluginInfo>& plugins() const { return plugins_; } | 202 const std::vector<PluginInfo>& plugins() const { return plugins_; } |
| 201 const GURL& background_url() const { return background_url_; } | 203 const GURL& background_url() const { return background_url_; } |
| 202 const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; } | 204 const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; } |
| 203 const std::vector<std::string>& api_permissions() const { | 205 const std::vector<std::string>& api_permissions() const { |
| 204 return api_permissions_; | 206 return api_permissions_; |
| 205 } | 207 } |
| 206 const HostPermissions& host_permissions() const { | 208 const HostPermissions& host_permissions() const { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 217 const std::set<std::string> GetEffectiveHostPermissions() const; | 219 const std::set<std::string> GetEffectiveHostPermissions() const; |
| 218 | 220 |
| 219 // Whether the extension has access to all hosts. This is true if there is | 221 // Whether the extension has access to all hosts. This is true if there is |
| 220 // a content script that matches all hosts, or if there is a host permission | 222 // a content script that matches all hosts, or if there is a host permission |
| 221 // for all hosts. | 223 // for all hosts. |
| 222 bool HasAccessToAllHosts() const; | 224 bool HasAccessToAllHosts() const; |
| 223 | 225 |
| 224 const GURL& update_url() const { return update_url_; } | 226 const GURL& update_url() const { return update_url_; } |
| 225 const std::map<int, std::string>& icons() { return icons_; } | 227 const std::map<int, std::string>& icons() { return icons_; } |
| 226 | 228 |
| 227 // Retrieves a page action by |id|. | 229 // Retrieves a page action or browser action by |id|. |
| 228 const PageAction* GetPageAction(std::string id) const; | 230 const ContextualAction* GetContextualAction( |
| 231 std::string id, ContextualAction::ContextualActionType action_type) const; |
| 229 | 232 |
| 230 // Returns the origin of this extension. This function takes a |registry_path| | 233 // Returns the origin of this extension. This function takes a |registry_path| |
| 231 // so that the registry location can be overwritten during testing. | 234 // so that the registry location can be overwritten during testing. |
| 232 Location ExternalExtensionInstallType(std::string registry_path); | 235 Location ExternalExtensionInstallType(std::string registry_path); |
| 233 | 236 |
| 234 // Theme-related. | 237 // Theme-related. |
| 235 DictionaryValue* GetThemeImages() const { return theme_images_.get(); } | 238 DictionaryValue* GetThemeImages() const { return theme_images_.get(); } |
| 236 DictionaryValue* GetThemeColors() const { return theme_colors_.get(); } | 239 DictionaryValue* GetThemeColors() const { return theme_colors_.get(); } |
| 237 DictionaryValue* GetThemeTints() const { return theme_tints_.get(); } | 240 DictionaryValue* GetThemeTints() const { return theme_tints_.get(); } |
| 238 DictionaryValue* GetThemeDisplayProperties() const { | 241 DictionaryValue* GetThemeDisplayProperties() const { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // value is 0. | 286 // value is 0. |
| 284 static int NextGeneratedId() { return id_counter_++; } | 287 static int NextGeneratedId() { return id_counter_++; } |
| 285 | 288 |
| 286 // Helper method that loads a UserScript object from a | 289 // Helper method that loads a UserScript object from a |
| 287 // dictionary in the content_script list of the manifest. | 290 // dictionary in the content_script list of the manifest. |
| 288 bool LoadUserScriptHelper(const DictionaryValue* content_script, | 291 bool LoadUserScriptHelper(const DictionaryValue* content_script, |
| 289 int definition_index, | 292 int definition_index, |
| 290 std::string* error, | 293 std::string* error, |
| 291 UserScript* result); | 294 UserScript* result); |
| 292 | 295 |
| 293 // Helper method that loads a PageAction object from a | 296 // Helper method that loads a ContextualAction object from a |
| 294 // dictionary in the page_action list of the manifest. | 297 // dictionary in the page_action or browser_action section of the manifest. |
| 295 PageAction* LoadPageActionHelper(const DictionaryValue* page_action, | 298 ContextualAction* LoadContextualActionHelper( |
| 296 int definition_index, | 299 const DictionaryValue* contextual_action, |
| 297 std::string* error); | 300 int definition_index, |
| 301 std::string* error, |
| 302 ContextualAction::ContextualActionType action_type); |
| 298 | 303 |
| 299 // Figures out if a source contains keys not associated with themes - we | 304 // Figures out if a source contains keys not associated with themes - we |
| 300 // don't want to allow scripts and such to be bundled with themes. | 305 // don't want to allow scripts and such to be bundled with themes. |
| 301 bool ContainsNonThemeKeys(const DictionaryValue& source); | 306 bool ContainsNonThemeKeys(const DictionaryValue& source); |
| 302 | 307 |
| 303 // The absolute path to the directory the extension is stored in. | 308 // The absolute path to the directory the extension is stored in. |
| 304 FilePath path_; | 309 FilePath path_; |
| 305 | 310 |
| 306 // The base extension url for the extension. | 311 // The base extension url for the extension. |
| 307 GURL extension_url_; | 312 GURL extension_url_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 323 // The extension's human-readable name. | 328 // The extension's human-readable name. |
| 324 std::string name_; | 329 std::string name_; |
| 325 | 330 |
| 326 // An optional longer description of the extension. | 331 // An optional longer description of the extension. |
| 327 std::string description_; | 332 std::string description_; |
| 328 | 333 |
| 329 // Paths to the content scripts the extension contains. | 334 // Paths to the content scripts the extension contains. |
| 330 UserScriptList content_scripts_; | 335 UserScriptList content_scripts_; |
| 331 | 336 |
| 332 // A list of page actions. | 337 // A list of page actions. |
| 333 PageActionMap page_actions_; | 338 ContextualActionMap page_actions_; |
| 339 |
| 340 // The extension's browser action, if any. |
| 341 ContextualAction* browser_action_; |
| 334 | 342 |
| 335 // Optional list of privacy blacklistrom. | 343 // Optional list of privacy blacklistrom. |
| 336 std::vector<PrivacyBlacklistInfo> privacy_blacklists_; | 344 std::vector<PrivacyBlacklistInfo> privacy_blacklists_; |
| 337 | 345 |
| 338 // Optional list of NPAPI plugins and associated properties. | 346 // Optional list of NPAPI plugins and associated properties. |
| 339 std::vector<PluginInfo> plugins_; | 347 std::vector<PluginInfo> plugins_; |
| 340 | 348 |
| 341 // Optional URL to a master page of which a single instance should be always | 349 // Optional URL to a master page of which a single instance should be always |
| 342 // loaded in the background. | 350 // loaded in the background. |
| 343 GURL background_url_; | 351 GURL background_url_; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 398 |
| 391 // True if the background page is ready. | 399 // True if the background page is ready. |
| 392 bool background_page_ready_; | 400 bool background_page_ready_; |
| 393 | 401 |
| 394 FRIEND_TEST(ExtensionTest, LoadPageActionHelper); | 402 FRIEND_TEST(ExtensionTest, LoadPageActionHelper); |
| 395 | 403 |
| 396 DISALLOW_COPY_AND_ASSIGN(Extension); | 404 DISALLOW_COPY_AND_ASSIGN(Extension); |
| 397 }; | 405 }; |
| 398 | 406 |
| 399 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 407 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| OLD | NEW |