Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Side by Side Diff: chrome/common/extensions/extension.h

Issue 8654001: Reland restrict extension features based on the extension type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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>
(...skipping 12 matching lines...) Expand all
23 #include "chrome/common/extensions/user_script.h" 23 #include "chrome/common/extensions/user_script.h"
24 #include "chrome/common/extensions/url_pattern.h" 24 #include "chrome/common/extensions/url_pattern.h"
25 #include "chrome/common/extensions/url_pattern_set.h" 25 #include "chrome/common/extensions/url_pattern_set.h"
26 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
27 #include "ui/gfx/size.h" 27 #include "ui/gfx/size.h"
28 #include "webkit/glue/web_intent_service_data.h" 28 #include "webkit/glue/web_intent_service_data.h"
29 29
30 class ExtensionAction; 30 class ExtensionAction;
31 class ExtensionResource; 31 class ExtensionResource;
32 class ExtensionSidebarDefaults; 32 class ExtensionSidebarDefaults;
33 class ManifestValue;
33 class FileBrowserHandler; 34 class FileBrowserHandler;
34 class SkBitmap; 35 class SkBitmap;
35 class Version; 36 class Version;
36 37
37 namespace base { 38 namespace base {
38 class DictionaryValue; 39 class DictionaryValue;
39 class ListValue; 40 class ListValue;
40 } 41 }
41 42
42 // Represents a Chrome extension. 43 // Represents a Chrome extension.
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 362
362 // Returns the base extension url for a given |extension_id|. 363 // Returns the base extension url for a given |extension_id|.
363 static GURL GetBaseURLFromExtensionId(const std::string& extension_id); 364 static GURL GetBaseURLFromExtensionId(const std::string& extension_id);
364 365
365 // Adds an extension to the scripting whitelist. Used for testing only. 366 // Adds an extension to the scripting whitelist. Used for testing only.
366 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); 367 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist);
367 static const ScriptingWhitelist* GetScriptingWhitelist(); 368 static const ScriptingWhitelist* GetScriptingWhitelist();
368 369
369 // Parses the host and api permissions from the specified permission |key| 370 // Parses the host and api permissions from the specified permission |key|
370 // in the manifest |source|. 371 // in the manifest |source|.
371 bool ParsePermissions(const base::DictionaryValue* source, 372 bool ParsePermissions(const ManifestValue* source,
372 const char* key, 373 const char* key,
373 int flags, 374 int flags,
374 std::string* error, 375 std::string* error,
375 ExtensionAPIPermissionSet* api_permissions, 376 ExtensionAPIPermissionSet* api_permissions,
376 URLPatternSet* host_permissions); 377 URLPatternSet* host_permissions);
377 378
378 bool HasAPIPermission(ExtensionAPIPermission::ID permission) const; 379 bool HasAPIPermission(ExtensionAPIPermission::ID permission) const;
379 bool HasAPIPermission(const std::string& function_name) const; 380 bool HasAPIPermission(const std::string& function_name) const;
380 381
381 const URLPatternSet& GetEffectiveHostPermissions() const; 382 const URLPatternSet& GetEffectiveHostPermissions() const;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 const GURL& options_url() const { return options_url_; } 519 const GURL& options_url() const { return options_url_; }
519 const GURL& devtools_url() const { return devtools_url_; } 520 const GURL& devtools_url() const { return devtools_url_; }
520 const ExtensionPermissionSet* optional_permission_set() const { 521 const ExtensionPermissionSet* optional_permission_set() const {
521 return optional_permission_set_.get(); 522 return optional_permission_set_.get();
522 } 523 }
523 const ExtensionPermissionSet* required_permission_set() const { 524 const ExtensionPermissionSet* required_permission_set() const {
524 return required_permission_set_.get(); 525 return required_permission_set_.get();
525 } 526 }
526 const GURL& update_url() const { return update_url_; } 527 const GURL& update_url() const { return update_url_; }
527 const ExtensionIconSet& icons() const { return icons_; } 528 const ExtensionIconSet& icons() const { return icons_; }
528 const base::DictionaryValue* manifest_value() const { 529 const ManifestValue* manifest_value() const {
529 return manifest_value_.get(); 530 return manifest_value_.get();
530 } 531 }
531 const std::string default_locale() const { return default_locale_; } 532 const std::string default_locale() const { return default_locale_; }
532 const URLOverrideMap& GetChromeURLOverrides() const { 533 const URLOverrideMap& GetChromeURLOverrides() const {
533 return chrome_url_overrides_; 534 return chrome_url_overrides_;
534 } 535 }
535 const std::string omnibox_keyword() const { return omnibox_keyword_; } 536 const std::string omnibox_keyword() const { return omnibox_keyword_; }
536 bool incognito_split_mode() const { return incognito_split_mode_; } 537 bool incognito_split_mode() const { return incognito_split_mode_; }
537 bool offline_enabled() const { return offline_enabled_; } 538 bool offline_enabled() const { return offline_enabled_; }
538 const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; } 539 const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 // sure the drive letter is uppercase. 602 // sure the drive letter is uppercase.
602 static FilePath MaybeNormalizePath(const FilePath& path); 603 static FilePath MaybeNormalizePath(const FilePath& path);
603 604
604 // Returns true if this extension id is from a trusted provider. 605 // Returns true if this extension id is from a trusted provider.
605 static bool IsTrustedId(const std::string& id); 606 static bool IsTrustedId(const std::string& id);
606 607
607 Extension(const FilePath& path, Location location); 608 Extension(const FilePath& path, Location location);
608 ~Extension(); 609 ~Extension();
609 610
610 // Initialize the extension from a parsed manifest. 611 // Initialize the extension from a parsed manifest.
611 bool InitFromValue(const base::DictionaryValue& value, int flags, 612 bool InitFromValue(const ManifestValue& value, int flags,
612 std::string* error); 613 std::string* error);
613 614
614 // Helper function for implementing HasCachedImage/GetCachedImage. A return 615 // Helper function for implementing HasCachedImage/GetCachedImage. A return
615 // value of NULL means there is no matching image cached (we allow caching an 616 // value of NULL means there is no matching image cached (we allow caching an
616 // empty SkBitmap). 617 // empty SkBitmap).
617 SkBitmap* GetCachedImageImpl(const ExtensionResource& source, 618 SkBitmap* GetCachedImageImpl(const ExtensionResource& source,
618 const gfx::Size& max_size) const; 619 const gfx::Size& max_size) const;
619 620
620 // Helper method that loads a UserScript object from a 621 // Helper method that loads a UserScript object from a
621 // dictionary in the content_script list of the manifest. 622 // dictionary in the content_script list of the manifest.
622 bool LoadUserScriptHelper(const base::DictionaryValue* content_script, 623 bool LoadUserScriptHelper(const base::DictionaryValue* content_script,
623 int definition_index, 624 int definition_index,
624 int flags, 625 int flags,
625 std::string* error, 626 std::string* error,
626 UserScript* result); 627 UserScript* result);
627 628
628 // Helper method that loads either the include_globs or exclude_globs list 629 // Helper method that loads either the include_globs or exclude_globs list
629 // from an entry in the content_script lists of the manifest. 630 // from an entry in the content_script lists of the manifest.
630 bool LoadGlobsHelper(const base::DictionaryValue* content_script, 631 bool LoadGlobsHelper(const base::DictionaryValue* content_script,
631 int content_script_index, 632 int content_script_index,
632 const char* globs_property_name, 633 const char* globs_property_name,
633 std::string* error, 634 std::string* error,
634 void(UserScript::*add_method)(const std::string& glob), 635 void(UserScript::*add_method)(const std::string& glob),
635 UserScript *instance); 636 UserScript *instance);
636 637
637 // Helpers to load various chunks of the manifest. 638 // Helpers to load various chunks of the manifest.
638 bool LoadIsApp(const base::DictionaryValue* manifest, std::string* error); 639 bool LoadIsApp(const ManifestValue* manifest, std::string* error);
639 bool LoadExtent(const base::DictionaryValue* manifest, 640 bool LoadExtent(const ManifestValue* manifest,
640 const char* key, 641 const char* key,
641 URLPatternSet* extent, 642 URLPatternSet* extent,
642 const char* list_error, 643 const char* list_error,
643 const char* value_error, 644 const char* value_error,
644 URLPattern::ParseOption parse_strictness, 645 URLPattern::ParseOption parse_strictness,
645 std::string* error); 646 std::string* error);
646 bool LoadLaunchContainer(const base::DictionaryValue* manifest, 647 bool LoadLaunchContainer(const ManifestValue* manifest,
647 std::string* error); 648 std::string* error);
648 bool LoadLaunchURL(const base::DictionaryValue* manifest, 649 bool LoadLaunchURL(const ManifestValue* manifest,
649 std::string* error); 650 std::string* error);
650 bool LoadAppIsolation(const base::DictionaryValue* manifest, 651 bool LoadAppIsolation(const ManifestValue* manifest,
651 std::string* error); 652 std::string* error);
652 bool LoadWebIntentServices(const base::DictionaryValue& manifest, 653 bool LoadWebIntentServices(const ManifestValue& manifest,
653 std::string* error); 654 std::string* error);
654 bool EnsureNotHybridApp(const base::DictionaryValue* manifest,
655 std::string* error);
656 655
657 // Helper method to load an ExtensionAction from the page_action or 656 // Helper method to load an ExtensionAction from the page_action or
658 // browser_action entries in the manifest. 657 // browser_action entries in the manifest.
659 ExtensionAction* LoadExtensionActionHelper( 658 ExtensionAction* LoadExtensionActionHelper(
660 const base::DictionaryValue* extension_action, std::string* error); 659 const base::DictionaryValue* extension_action, std::string* error);
661 660
662 // Helper method to load an FileBrowserHandlerList from the manifest. 661 // Helper method to load an FileBrowserHandlerList from the manifest.
663 FileBrowserHandlerList* LoadFileBrowserHandlers( 662 FileBrowserHandlerList* LoadFileBrowserHandlers(
664 const base::ListValue* extension_actions, std::string* error); 663 const base::ListValue* extension_actions, std::string* error);
665 // Helper method to load an FileBrowserHandler from manifest. 664 // Helper method to load an FileBrowserHandler from manifest.
666 FileBrowserHandler* LoadFileBrowserHandler( 665 FileBrowserHandler* LoadFileBrowserHandler(
667 const base::DictionaryValue* file_browser_handlers, std::string* error); 666 const base::DictionaryValue* file_browser_handlers, std::string* error);
668 667
669 // Helper method to load an ExtensionSidebarDefaults from the sidebar manifest 668 // Helper method to load an ExtensionSidebarDefaults from the sidebar manifest
670 // entry. 669 // entry.
671 ExtensionSidebarDefaults* LoadExtensionSidebarDefaults( 670 ExtensionSidebarDefaults* LoadExtensionSidebarDefaults(
672 const base::DictionaryValue* sidebar, std::string* error); 671 const base::DictionaryValue* sidebar, std::string* error);
673 672
674 // Returns true if the extension has more than one "UI surface". For example, 673 // Returns true if the extension has more than one "UI surface". For example,
675 // an extension that has a browser action and a page action. 674 // an extension that has a browser action and a page action.
676 bool HasMultipleUISurfaces() const; 675 bool HasMultipleUISurfaces() const;
677 676
678 // Figures out if a source contains keys not associated with themes - we
679 // don't want to allow scripts and such to be bundled with themes.
680 bool ContainsNonThemeKeys(const base::DictionaryValue& source) const;
681
682 // Updates the launch URL and extents for the extension using the given 677 // Updates the launch URL and extents for the extension using the given
683 // |override_url|. 678 // |override_url|.
684 void OverrideLaunchUrl(const GURL& override_url); 679 void OverrideLaunchUrl(const GURL& override_url);
685 680
686 // Returns true if this extension can specify |api|. 681 // Returns true if this extension can specify |api|.
687 bool CanSpecifyAPIPermission(const ExtensionAPIPermission* api, 682 bool CanSpecifyAPIPermission(const ExtensionAPIPermission* api,
688 std::string* error) const; 683 std::string* error) const;
689 bool CanSpecifyComponentOnlyPermission() const; 684 bool CanSpecifyComponentOnlyPermission() const;
690 bool CanSpecifyExperimentalPermission() const; 685 bool CanSpecifyExperimentalPermission() const;
691 bool CanSpecifyPermissionForHostedApp( 686 bool CanSpecifyPermissionForHostedApp(
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 bool is_theme_; 813 bool is_theme_;
819 814
820 // The homepage for this extension. Useful if it is not hosted by Google and 815 // The homepage for this extension. Useful if it is not hosted by Google and
821 // therefore does not have a Gallery URL. 816 // therefore does not have a Gallery URL.
822 GURL homepage_url_; 817 GURL homepage_url_;
823 818
824 // URL for fetching an update manifest 819 // URL for fetching an update manifest
825 GURL update_url_; 820 GURL update_url_;
826 821
827 // A copy of the manifest that this extension was created from. 822 // A copy of the manifest that this extension was created from.
828 scoped_ptr<base::DictionaryValue> manifest_value_; 823 scoped_ptr<ManifestValue> manifest_value_;
829 824
830 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs 825 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs
831 // which override the handling of those URLs. (see ExtensionOverrideUI). 826 // which override the handling of those URLs. (see ExtensionOverrideUI).
832 URLOverrideMap chrome_url_overrides_; 827 URLOverrideMap chrome_url_overrides_;
833 828
834 // Whether this extension uses app features. 829 // Whether this extension uses app features.
835 bool is_app_; 830 bool is_app_;
836 831
837 // Whether this app uses platform features. 832 // Whether this app uses platform features.
838 bool is_platform_app_; 833 bool is_platform_app_;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 // only contain the removed permissions. 935 // only contain the removed permissions.
941 const ExtensionPermissionSet* permissions; 936 const ExtensionPermissionSet* permissions;
942 937
943 UpdatedExtensionPermissionsInfo( 938 UpdatedExtensionPermissionsInfo(
944 const Extension* extension, 939 const Extension* extension,
945 const ExtensionPermissionSet* permissions, 940 const ExtensionPermissionSet* permissions,
946 Reason reason); 941 Reason reason);
947 }; 942 };
948 943
949 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 944 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698