| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "base/version.h" | 16 #include "base/version.h" |
| 17 #include "chrome/browser/extensions/user_script_master.h" | 17 #include "chrome/browser/extensions/user_script_master.h" |
| 18 #include "chrome/common/extensions/extension_action.h" | 18 #include "chrome/common/extensions/extension_action.h" |
| 19 #include "chrome/common/extensions/extension_action2.h" |
| 19 #include "chrome/common/extensions/extension_message_bundle.h" | 20 #include "chrome/common/extensions/extension_message_bundle.h" |
| 20 #include "chrome/common/extensions/extension_resource.h" | 21 #include "chrome/common/extensions/extension_resource.h" |
| 21 #include "chrome/common/extensions/user_script.h" | 22 #include "chrome/common/extensions/user_script.h" |
| 22 #include "chrome/common/extensions/url_pattern.h" | 23 #include "chrome/common/extensions/url_pattern.h" |
| 23 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
| 24 | 25 |
| 25 // Represents a Chrome extension. | 26 // Represents a Chrome extension. |
| 26 class Extension { | 27 class Extension { |
| 27 public: | 28 public: |
| 28 typedef std::vector<URLPattern> HostPermissions; | 29 typedef std::vector<URLPattern> HostPermissions; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 void set_location(Location location) { location_ = location; } | 185 void set_location(Location location) { location_ = location; } |
| 185 const std::string& id() const { return id_; } | 186 const std::string& id() const { return id_; } |
| 186 const Version* version() const { return version_.get(); } | 187 const Version* version() const { return version_.get(); } |
| 187 // String representation of the version number. | 188 // String representation of the version number. |
| 188 const std::string VersionString() const; | 189 const std::string VersionString() const; |
| 189 const std::string& name() const { return name_; } | 190 const std::string& name() const { return name_; } |
| 190 const std::string& public_key() const { return public_key_; } | 191 const std::string& public_key() const { return public_key_; } |
| 191 const std::string& description() const { return description_; } | 192 const std::string& description() const { return description_; } |
| 192 const UserScriptList& content_scripts() const { return content_scripts_; } | 193 const UserScriptList& content_scripts() const { return content_scripts_; } |
| 193 ExtensionAction* page_action() const { return page_action_.get(); } | 194 ExtensionAction* page_action() const { return page_action_.get(); } |
| 194 ExtensionAction* browser_action() const { return browser_action_.get(); } | 195 ExtensionAction2* browser_action() const { return browser_action_.get(); } |
| 195 ExtensionActionState* browser_action_state() { | |
| 196 return browser_action_state_.get(); | |
| 197 } | |
| 198 const std::vector<PrivacyBlacklistInfo>& privacy_blacklists() const { | 196 const std::vector<PrivacyBlacklistInfo>& privacy_blacklists() const { |
| 199 return privacy_blacklists_; | 197 return privacy_blacklists_; |
| 200 } | 198 } |
| 201 const std::vector<PluginInfo>& plugins() const { return plugins_; } | 199 const std::vector<PluginInfo>& plugins() const { return plugins_; } |
| 202 const GURL& background_url() const { return background_url_; } | 200 const GURL& background_url() const { return background_url_; } |
| 203 const GURL& options_url() const { return options_url_; } | 201 const GURL& options_url() const { return options_url_; } |
| 204 const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; } | 202 const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; } |
| 205 const std::vector<std::string>& api_permissions() const { | 203 const std::vector<std::string>& api_permissions() const { |
| 206 return api_permissions_; | 204 return api_permissions_; |
| 207 } | 205 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 std::string* error, | 279 std::string* error, |
| 282 UserScript* result); | 280 UserScript* result); |
| 283 | 281 |
| 284 // Helper method that loads a ExtensionAction object from a | 282 // Helper method that loads a ExtensionAction object from a |
| 285 // dictionary in the page_action or browser_action section of the manifest. | 283 // dictionary in the page_action or browser_action section of the manifest. |
| 286 ExtensionAction* LoadExtensionActionHelper( | 284 ExtensionAction* LoadExtensionActionHelper( |
| 287 const DictionaryValue* contextual_action, | 285 const DictionaryValue* contextual_action, |
| 288 std::string* error, | 286 std::string* error, |
| 289 ExtensionAction::ExtensionActionType action_type); | 287 ExtensionAction::ExtensionActionType action_type); |
| 290 | 288 |
| 289 // Helper method to load an ExtensionAction2 from the page_action or |
| 290 // browser_action entries in the manifest. |
| 291 // TODO(aa): ExtensionAction2 should replace ExtensionAction completely. |
| 292 ExtensionAction2* LoadExtensionAction2Helper( |
| 293 const DictionaryValue* extension_action, std::string* error); |
| 294 |
| 291 // Figures out if a source contains keys not associated with themes - we | 295 // Figures out if a source contains keys not associated with themes - we |
| 292 // don't want to allow scripts and such to be bundled with themes. | 296 // don't want to allow scripts and such to be bundled with themes. |
| 293 bool ContainsNonThemeKeys(const DictionaryValue& source); | 297 bool ContainsNonThemeKeys(const DictionaryValue& source); |
| 294 | 298 |
| 295 // The absolute path to the directory the extension is stored in. | 299 // The absolute path to the directory the extension is stored in. |
| 296 FilePath path_; | 300 FilePath path_; |
| 297 | 301 |
| 298 // The base extension url for the extension. | 302 // The base extension url for the extension. |
| 299 GURL extension_url_; | 303 GURL extension_url_; |
| 300 | 304 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 318 // An optional longer description of the extension. | 322 // An optional longer description of the extension. |
| 319 std::string description_; | 323 std::string description_; |
| 320 | 324 |
| 321 // Paths to the content scripts the extension contains. | 325 // Paths to the content scripts the extension contains. |
| 322 UserScriptList content_scripts_; | 326 UserScriptList content_scripts_; |
| 323 | 327 |
| 324 // The extension's page action, if any. | 328 // The extension's page action, if any. |
| 325 scoped_ptr<ExtensionAction> page_action_; | 329 scoped_ptr<ExtensionAction> page_action_; |
| 326 | 330 |
| 327 // The extension's browser action, if any. | 331 // The extension's browser action, if any. |
| 328 scoped_ptr<ExtensionAction> browser_action_; | 332 scoped_ptr<ExtensionAction2> browser_action_; |
| 329 | |
| 330 // The state of the browser action. Valid iff browser_action_ is non-NULL. | |
| 331 scoped_ptr<ExtensionActionState> browser_action_state_; | |
| 332 | 333 |
| 333 // Optional list of privacy blacklistrom. | 334 // Optional list of privacy blacklistrom. |
| 334 std::vector<PrivacyBlacklistInfo> privacy_blacklists_; | 335 std::vector<PrivacyBlacklistInfo> privacy_blacklists_; |
| 335 | 336 |
| 336 // Optional list of NPAPI plugins and associated properties. | 337 // Optional list of NPAPI plugins and associated properties. |
| 337 std::vector<PluginInfo> plugins_; | 338 std::vector<PluginInfo> plugins_; |
| 338 | 339 |
| 339 // Optional URL to a master page of which a single instance should be always | 340 // Optional URL to a master page of which a single instance should be always |
| 340 // loaded in the background. | 341 // loaded in the background. |
| 341 GURL background_url_; | 342 GURL background_url_; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 | 392 |
| 392 // True if the background page is ready. | 393 // True if the background page is ready. |
| 393 bool background_page_ready_; | 394 bool background_page_ready_; |
| 394 | 395 |
| 395 FRIEND_TEST(ExtensionTest, LoadPageActionHelper); | 396 FRIEND_TEST(ExtensionTest, LoadPageActionHelper); |
| 396 | 397 |
| 397 DISALLOW_COPY_AND_ASSIGN(Extension); | 398 DISALLOW_COPY_AND_ASSIGN(Extension); |
| 398 }; | 399 }; |
| 399 | 400 |
| 400 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 401 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| OLD | NEW |