| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 17 #include "base/ref_counted.h" | 17 #include "base/ref_counted.h" |
| 18 #include "chrome/common/extensions/extension_constants.h" | 18 #include "chrome/common/extensions/extension_constants.h" |
| 19 #include "chrome/common/extensions/extension_extent.h" | 19 #include "chrome/common/extensions/extension_extent.h" |
| 20 #include "chrome/common/extensions/extension_icon_set.h" | 20 #include "chrome/common/extensions/extension_icon_set.h" |
| 21 #include "chrome/common/extensions/user_script.h" | 21 #include "chrome/common/extensions/user_script.h" |
| 22 #include "chrome/common/extensions/url_pattern.h" | 22 #include "chrome/common/extensions/url_pattern.h" |
| 23 #include "gfx/size.h" | 23 #include "gfx/size.h" |
| 24 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
| 25 | 25 |
| 26 class DictionaryValue; | 26 class DictionaryValue; |
| 27 class ExtensionAction; | 27 class ExtensionAction; |
| 28 class ExtensionResource; | 28 class ExtensionResource; |
| 29 class ExtensionSidebarDefaults; |
| 29 class SkBitmap; | 30 class SkBitmap; |
| 30 class Version; | 31 class Version; |
| 31 | 32 |
| 32 // Represents a Chrome extension. | 33 // Represents a Chrome extension. |
| 33 class Extension : public base::RefCountedThreadSafe<Extension> { | 34 class Extension : public base::RefCountedThreadSafe<Extension> { |
| 34 public: | 35 public: |
| 35 typedef std::map<const std::string, GURL> URLOverrideMap; | 36 typedef std::map<const std::string, GURL> URLOverrideMap; |
| 36 typedef std::vector<std::string> ScriptingWhitelist; | 37 typedef std::vector<std::string> ScriptingWhitelist; |
| 37 | 38 |
| 38 // What an extension was loaded from. | 39 // What an extension was loaded from. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // to |old_list|. | 145 // to |old_list|. |
| 145 static bool IsElevatedHostList( | 146 static bool IsElevatedHostList( |
| 146 const URLPatternList& old_list, const URLPatternList& new_list); | 147 const URLPatternList& old_list, const URLPatternList& new_list); |
| 147 | 148 |
| 148 // Icon sizes used by the extension system. | 149 // Icon sizes used by the extension system. |
| 149 static const int kIconSizes[]; | 150 static const int kIconSizes[]; |
| 150 | 151 |
| 151 // Max size (both dimensions) for browser and page actions. | 152 // Max size (both dimensions) for browser and page actions. |
| 152 static const int kPageActionIconMaxSize; | 153 static const int kPageActionIconMaxSize; |
| 153 static const int kBrowserActionIconMaxSize; | 154 static const int kBrowserActionIconMaxSize; |
| 155 static const int kSidebarIconMaxSize; |
| 154 | 156 |
| 155 // Each permission is a module that the extension is permitted to use. | 157 // Each permission is a module that the extension is permitted to use. |
| 156 // | 158 // |
| 157 // NOTE: To add a new permission, define it here, and add an entry to | 159 // NOTE: To add a new permission, define it here, and add an entry to |
| 158 // Extension::kPermissions. | 160 // Extension::kPermissions. |
| 159 static const char kBackgroundPermission[]; | 161 static const char kBackgroundPermission[]; |
| 160 static const char kBookmarkPermission[]; | 162 static const char kBookmarkPermission[]; |
| 161 static const char kContextMenusPermission[]; | 163 static const char kContextMenusPermission[]; |
| 162 static const char kCookiePermission[]; | 164 static const char kCookiePermission[]; |
| 163 static const char kExperimentalPermission[]; | 165 static const char kExperimentalPermission[]; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 const std::string VersionString() const; | 409 const std::string VersionString() const; |
| 408 const std::string& name() const { return name_; } | 410 const std::string& name() const { return name_; } |
| 409 const std::string& public_key() const { return public_key_; } | 411 const std::string& public_key() const { return public_key_; } |
| 410 const std::string& description() const { return description_; } | 412 const std::string& description() const { return description_; } |
| 411 bool converted_from_user_script() const { | 413 bool converted_from_user_script() const { |
| 412 return converted_from_user_script_; | 414 return converted_from_user_script_; |
| 413 } | 415 } |
| 414 const UserScriptList& content_scripts() const { return content_scripts_; } | 416 const UserScriptList& content_scripts() const { return content_scripts_; } |
| 415 ExtensionAction* page_action() const { return page_action_.get(); } | 417 ExtensionAction* page_action() const { return page_action_.get(); } |
| 416 ExtensionAction* browser_action() const { return browser_action_.get(); } | 418 ExtensionAction* browser_action() const { return browser_action_.get(); } |
| 419 ExtensionSidebarDefaults* sidebar_defaults() const { |
| 420 return sidebar_defaults_.get(); |
| 421 } |
| 417 const std::vector<PluginInfo>& plugins() const { return plugins_; } | 422 const std::vector<PluginInfo>& plugins() const { return plugins_; } |
| 418 const GURL& background_url() const { return background_url_; } | 423 const GURL& background_url() const { return background_url_; } |
| 419 const GURL& options_url() const { return options_url_; } | 424 const GURL& options_url() const { return options_url_; } |
| 420 const GURL& devtools_url() const { return devtools_url_; } | 425 const GURL& devtools_url() const { return devtools_url_; } |
| 421 const std::vector<GURL>& toolstrips() const { return toolstrips_; } | 426 const std::vector<GURL>& toolstrips() const { return toolstrips_; } |
| 422 const std::set<std::string>& api_permissions() const { | 427 const std::set<std::string>& api_permissions() const { |
| 423 return api_permissions_; | 428 return api_permissions_; |
| 424 } | 429 } |
| 425 const URLPatternList& host_permissions() const { return host_permissions_; } | 430 const URLPatternList& host_permissions() const { return host_permissions_; } |
| 426 const GURL& update_url() const { return update_url_; } | 431 const GURL& update_url() const { return update_url_; } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 const char* value_error, std::string* error); | 531 const char* value_error, std::string* error); |
| 527 bool LoadLaunchContainer(const DictionaryValue* manifest, std::string* error); | 532 bool LoadLaunchContainer(const DictionaryValue* manifest, std::string* error); |
| 528 bool LoadLaunchURL(const DictionaryValue* manifest, std::string* error); | 533 bool LoadLaunchURL(const DictionaryValue* manifest, std::string* error); |
| 529 bool EnsureNotHybridApp(const DictionaryValue* manifest, std::string* error); | 534 bool EnsureNotHybridApp(const DictionaryValue* manifest, std::string* error); |
| 530 | 535 |
| 531 // Helper method to load an ExtensionAction from the page_action or | 536 // Helper method to load an ExtensionAction from the page_action or |
| 532 // browser_action entries in the manifest. | 537 // browser_action entries in the manifest. |
| 533 ExtensionAction* LoadExtensionActionHelper( | 538 ExtensionAction* LoadExtensionActionHelper( |
| 534 const DictionaryValue* extension_action, std::string* error); | 539 const DictionaryValue* extension_action, std::string* error); |
| 535 | 540 |
| 541 // Helper method to load a ExtensionSidebarDefaults from the sidebar manifest |
| 542 // entry. |
| 543 ExtensionSidebarDefaults* LoadExtensionSidebarDefaults( |
| 544 const DictionaryValue* sidebar, std::string* error); |
| 545 |
| 536 // Calculates the effective host permissions from the permissions and content | 546 // Calculates the effective host permissions from the permissions and content |
| 537 // script petterns. | 547 // script petterns. |
| 538 void InitEffectiveHostPermissions(); | 548 void InitEffectiveHostPermissions(); |
| 539 | 549 |
| 540 // Returns true if the extension has more than one "UI surface". For example, | 550 // Returns true if the extension has more than one "UI surface". For example, |
| 541 // an extension that has a browser action and a page action. | 551 // an extension that has a browser action and a page action. |
| 542 bool HasMultipleUISurfaces() const; | 552 bool HasMultipleUISurfaces() const; |
| 543 | 553 |
| 544 // Figures out if a source contains keys not associated with themes - we | 554 // Figures out if a source contains keys not associated with themes - we |
| 545 // don't want to allow scripts and such to be bundled with themes. | 555 // don't want to allow scripts and such to be bundled with themes. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 | 629 |
| 620 // Paths to the content scripts the extension contains. | 630 // Paths to the content scripts the extension contains. |
| 621 UserScriptList content_scripts_; | 631 UserScriptList content_scripts_; |
| 622 | 632 |
| 623 // The extension's page action, if any. | 633 // The extension's page action, if any. |
| 624 scoped_ptr<ExtensionAction> page_action_; | 634 scoped_ptr<ExtensionAction> page_action_; |
| 625 | 635 |
| 626 // The extension's browser action, if any. | 636 // The extension's browser action, if any. |
| 627 scoped_ptr<ExtensionAction> browser_action_; | 637 scoped_ptr<ExtensionAction> browser_action_; |
| 628 | 638 |
| 639 // The extension's sidebar, if any. |
| 640 scoped_ptr<ExtensionSidebarDefaults> sidebar_defaults_; |
| 641 |
| 629 // Optional list of NPAPI plugins and associated properties. | 642 // Optional list of NPAPI plugins and associated properties. |
| 630 std::vector<PluginInfo> plugins_; | 643 std::vector<PluginInfo> plugins_; |
| 631 | 644 |
| 632 // Optional URL to a master page of which a single instance should be always | 645 // Optional URL to a master page of which a single instance should be always |
| 633 // loaded in the background. | 646 // loaded in the background. |
| 634 GURL background_url_; | 647 GURL background_url_; |
| 635 | 648 |
| 636 // Optional URL to a page for setting options/preferences. | 649 // Optional URL to a page for setting options/preferences. |
| 637 GURL options_url_; | 650 GURL options_url_; |
| 638 | 651 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 // Was the extension already disabled? | 769 // Was the extension already disabled? |
| 757 bool already_disabled; | 770 bool already_disabled; |
| 758 | 771 |
| 759 // The extension being unloaded - this should always be non-NULL. | 772 // The extension being unloaded - this should always be non-NULL. |
| 760 const Extension* extension; | 773 const Extension* extension; |
| 761 | 774 |
| 762 UnloadedExtensionInfo(const Extension* extension, Reason reason); | 775 UnloadedExtensionInfo(const Extension* extension, Reason reason); |
| 763 }; | 776 }; |
| 764 | 777 |
| 765 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 778 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| OLD | NEW |