| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <algorithm> | 8 #include <algorithm> |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 // Returns true if the extension should be displayed in the app launcher. | 551 // Returns true if the extension should be displayed in the app launcher. |
| 552 bool ShouldDisplayInAppLauncher() const; | 552 bool ShouldDisplayInAppLauncher() const; |
| 553 | 553 |
| 554 // Returns true if the extension should be displayed in the browser NTP. | 554 // Returns true if the extension should be displayed in the browser NTP. |
| 555 bool ShouldDisplayInNewTabPage() const; | 555 bool ShouldDisplayInNewTabPage() const; |
| 556 | 556 |
| 557 // Returns true if the extension should be displayed in the extension | 557 // Returns true if the extension should be displayed in the extension |
| 558 // settings page (i.e. chrome://extensions). | 558 // settings page (i.e. chrome://extensions). |
| 559 bool ShouldDisplayInExtensionSettings() const; | 559 bool ShouldDisplayInExtensionSettings() const; |
| 560 | 560 |
| 561 // Returns true if the extension has a content script declared at |url|. | |
| 562 bool HasContentScriptAtURL(const GURL& url) const; | |
| 563 | |
| 564 // Gets the tab-specific host permissions of |tab_id|, or NULL if there | 561 // Gets the tab-specific host permissions of |tab_id|, or NULL if there |
| 565 // aren't any. | 562 // aren't any. |
| 566 scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id) | 563 scoped_refptr<const PermissionSet> GetTabSpecificPermissions(int tab_id) |
| 567 const; | 564 const; |
| 568 | 565 |
| 569 // Updates the tab-specific permissions of |tab_id| to include those from | 566 // Updates the tab-specific permissions of |tab_id| to include those from |
| 570 // |permissions|. | 567 // |permissions|. |
| 571 void UpdateTabSpecificPermissions( | 568 void UpdateTabSpecificPermissions( |
| 572 int tab_id, | 569 int tab_id, |
| 573 scoped_refptr<const PermissionSet> permissions) const; | 570 scoped_refptr<const PermissionSet> permissions) const; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 597 const std::string& non_localized_name() const { return non_localized_name_; } | 594 const std::string& non_localized_name() const { return non_localized_name_; } |
| 598 // Base64-encoded version of the key used to sign this extension. | 595 // Base64-encoded version of the key used to sign this extension. |
| 599 // In pseudocode, returns | 596 // In pseudocode, returns |
| 600 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). | 597 // base::Base64Encode(RSAPrivateKey(pem_file).ExportPublicKey()). |
| 601 const std::string& public_key() const { return public_key_; } | 598 const std::string& public_key() const { return public_key_; } |
| 602 const std::string& description() const { return description_; } | 599 const std::string& description() const { return description_; } |
| 603 int manifest_version() const { return manifest_version_; } | 600 int manifest_version() const { return manifest_version_; } |
| 604 bool converted_from_user_script() const { | 601 bool converted_from_user_script() const { |
| 605 return converted_from_user_script_; | 602 return converted_from_user_script_; |
| 606 } | 603 } |
| 607 const UserScriptList& content_scripts() const { return content_scripts_; } | |
| 608 const ActionInfo* page_action_info() const { return page_action_info_.get(); } | 604 const ActionInfo* page_action_info() const { return page_action_info_.get(); } |
| 609 const ActionInfo* browser_action_info() const { | 605 const ActionInfo* browser_action_info() const { |
| 610 return browser_action_info_.get(); | 606 return browser_action_info_.get(); |
| 611 } | 607 } |
| 612 const ActionInfo* system_indicator_info() const { | 608 const ActionInfo* system_indicator_info() const { |
| 613 return system_indicator_info_.get(); | 609 return system_indicator_info_.get(); |
| 614 } | 610 } |
| 615 const std::vector<PluginInfo>& plugins() const { return plugins_; } | 611 const std::vector<PluginInfo>& plugins() const { return plugins_; } |
| 616 const std::vector<NaClModuleInfo>& nacl_modules() const { | 612 const std::vector<NaClModuleInfo>& nacl_modules() const { |
| 617 return nacl_modules_; | 613 return nacl_modules_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 645 } | 641 } |
| 646 const ExtensionIconSet& icons() const { return icons_; } | 642 const ExtensionIconSet& icons() const { return icons_; } |
| 647 const extensions::Manifest* manifest() const { | 643 const extensions::Manifest* manifest() const { |
| 648 return manifest_.get(); | 644 return manifest_.get(); |
| 649 } | 645 } |
| 650 const std::string default_locale() const { return default_locale_; } | 646 const std::string default_locale() const { return default_locale_; } |
| 651 bool incognito_split_mode() const { return incognito_split_mode_; } | 647 bool incognito_split_mode() const { return incognito_split_mode_; } |
| 652 bool offline_enabled() const { return offline_enabled_; } | 648 bool offline_enabled() const { return offline_enabled_; } |
| 653 const OAuth2Info& oauth2_info() const { return oauth2_info_; } | 649 const OAuth2Info& oauth2_info() const { return oauth2_info_; } |
| 654 bool wants_file_access() const { return wants_file_access_; } | 650 bool wants_file_access() const { return wants_file_access_; } |
| 651 // TODO(rdevlin.cronin): This is needed for ContentScriptsHandler, and should |
| 652 // be moved out as part of crbug.com/159265. This should not be used anywhere |
| 653 // else. |
| 654 void set_wants_file_access(bool wants_file_access) { |
| 655 wants_file_access_ = wants_file_access; |
| 656 } |
| 655 int creation_flags() const { return creation_flags_; } | 657 int creation_flags() const { return creation_flags_; } |
| 656 bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; } | 658 bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; } |
| 657 bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; } | 659 bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; } |
| 658 bool was_installed_by_default() const { | 660 bool was_installed_by_default() const { |
| 659 return (creation_flags_ & WAS_INSTALLED_BY_DEFAULT) != 0; | 661 return (creation_flags_ & WAS_INSTALLED_BY_DEFAULT) != 0; |
| 660 } | 662 } |
| 661 | 663 |
| 662 // App-related. | 664 // App-related. |
| 663 bool is_app() const { | 665 bool is_app() const { |
| 664 return is_legacy_packaged_app() || is_hosted_app() || is_platform_app(); | 666 return is_legacy_packaged_app() || is_hosted_app() || is_platform_app(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 string16* error); | 802 string16* error); |
| 801 bool LoadBackgroundPersistent( | 803 bool LoadBackgroundPersistent( |
| 802 const APIPermissionSet& api_permissions, | 804 const APIPermissionSet& api_permissions, |
| 803 string16* error); | 805 string16* error); |
| 804 bool LoadBackgroundAllowJSAccess( | 806 bool LoadBackgroundAllowJSAccess( |
| 805 const APIPermissionSet& api_permissions, | 807 const APIPermissionSet& api_permissions, |
| 806 string16* error); | 808 string16* error); |
| 807 bool LoadExtensionFeatures(APIPermissionSet* api_permissions, | 809 bool LoadExtensionFeatures(APIPermissionSet* api_permissions, |
| 808 string16* error); | 810 string16* error); |
| 809 bool LoadManifestHandlerFeatures(string16* error); | 811 bool LoadManifestHandlerFeatures(string16* error); |
| 810 bool LoadContentScripts(string16* error); | |
| 811 bool LoadPageAction(string16* error); | 812 bool LoadPageAction(string16* error); |
| 812 bool LoadBrowserAction(string16* error); | 813 bool LoadBrowserAction(string16* error); |
| 813 bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error); | 814 bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error); |
| 814 bool LoadTextToSpeechVoices(string16* error); | 815 bool LoadTextToSpeechVoices(string16* error); |
| 815 bool LoadIncognitoMode(string16* error); | 816 bool LoadIncognitoMode(string16* error); |
| 816 bool LoadContentSecurityPolicy(string16* error); | 817 bool LoadContentSecurityPolicy(string16* error); |
| 817 | 818 |
| 818 bool LoadThemeFeatures(string16* error); | 819 bool LoadThemeFeatures(string16* error); |
| 819 bool LoadThemeImages(const base::DictionaryValue* theme_value, | 820 bool LoadThemeImages(const base::DictionaryValue* theme_value, |
| 820 string16* error); | 821 string16* error); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 832 bool LoadManagedModeConfigurations( | 833 bool LoadManagedModeConfigurations( |
| 833 const base::DictionaryValue* content_pack_value, | 834 const base::DictionaryValue* content_pack_value, |
| 834 string16* error); | 835 string16* error); |
| 835 | 836 |
| 836 // Helper function for implementing HasCachedImage/GetCachedImage. A return | 837 // Helper function for implementing HasCachedImage/GetCachedImage. A return |
| 837 // value of NULL means there is no matching image cached (we allow caching an | 838 // value of NULL means there is no matching image cached (we allow caching an |
| 838 // empty SkBitmap). | 839 // empty SkBitmap). |
| 839 SkBitmap* GetCachedImageImpl(const ExtensionResource& source, | 840 SkBitmap* GetCachedImageImpl(const ExtensionResource& source, |
| 840 const gfx::Size& max_size) const; | 841 const gfx::Size& max_size) const; |
| 841 | 842 |
| 842 // Helper method that loads a UserScript object from a | |
| 843 // dictionary in the content_script list of the manifest. | |
| 844 bool LoadUserScriptHelper(const base::DictionaryValue* content_script, | |
| 845 int definition_index, | |
| 846 string16* error, | |
| 847 UserScript* result); | |
| 848 | |
| 849 // Helper method that loads either the include_globs or exclude_globs list | |
| 850 // from an entry in the content_script lists of the manifest. | |
| 851 bool LoadGlobsHelper(const base::DictionaryValue* content_script, | |
| 852 int content_script_index, | |
| 853 const char* globs_property_name, | |
| 854 string16* error, | |
| 855 void(UserScript::*add_method)(const std::string& glob), | |
| 856 UserScript* instance); | |
| 857 | |
| 858 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key. | 843 // Helper method that loads the OAuth2 info from the 'oauth2' manifest key. |
| 859 bool LoadOAuth2Info(string16* error); | 844 bool LoadOAuth2Info(string16* error); |
| 860 | 845 |
| 861 // Returns true if the extension has more than one "UI surface". For example, | 846 // Returns true if the extension has more than one "UI surface". For example, |
| 862 // an extension that has a browser action and a page action. | 847 // an extension that has a browser action and a page action. |
| 863 bool HasMultipleUISurfaces() const; | 848 bool HasMultipleUISurfaces() const; |
| 864 | 849 |
| 865 // Updates the launch URL and extents for the extension using the given | 850 // Updates the launch URL and extents for the extension using the given |
| 866 // |override_url|. | 851 // |override_url|. |
| 867 void OverrideLaunchUrl(const GURL& override_url); | 852 void OverrideLaunchUrl(const GURL& override_url); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 // The extension's version. | 931 // The extension's version. |
| 947 scoped_ptr<Version> version_; | 932 scoped_ptr<Version> version_; |
| 948 | 933 |
| 949 // An optional longer description of the extension. | 934 // An optional longer description of the extension. |
| 950 std::string description_; | 935 std::string description_; |
| 951 | 936 |
| 952 // True if the extension was generated from a user script. (We show slightly | 937 // True if the extension was generated from a user script. (We show slightly |
| 953 // different UI if so). | 938 // different UI if so). |
| 954 bool converted_from_user_script_; | 939 bool converted_from_user_script_; |
| 955 | 940 |
| 956 // Paths to the content scripts the extension contains. | |
| 957 UserScriptList content_scripts_; | |
| 958 | |
| 959 // The extension's page action, if any. | 941 // The extension's page action, if any. |
| 960 scoped_ptr<ActionInfo> page_action_info_; | 942 scoped_ptr<ActionInfo> page_action_info_; |
| 961 | 943 |
| 962 // The extension's browser action, if any. | 944 // The extension's browser action, if any. |
| 963 scoped_ptr<ActionInfo> browser_action_info_; | 945 scoped_ptr<ActionInfo> browser_action_info_; |
| 964 | 946 |
| 965 // The extension's system indicator, if any. | 947 // The extension's system indicator, if any. |
| 966 scoped_ptr<ActionInfo> system_indicator_info_; | 948 scoped_ptr<ActionInfo> system_indicator_info_; |
| 967 | 949 |
| 968 // Optional list of NPAPI plugins and associated properties. | 950 // Optional list of NPAPI plugins and associated properties. |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 | 1119 |
| 1138 UpdatedExtensionPermissionsInfo( | 1120 UpdatedExtensionPermissionsInfo( |
| 1139 const Extension* extension, | 1121 const Extension* extension, |
| 1140 const PermissionSet* permissions, | 1122 const PermissionSet* permissions, |
| 1141 Reason reason); | 1123 Reason reason); |
| 1142 }; | 1124 }; |
| 1143 | 1125 |
| 1144 } // namespace extensions | 1126 } // namespace extensions |
| 1145 | 1127 |
| 1146 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ | 1128 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ |
| OLD | NEW |