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

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

Issue 12256031: Add a non-const APIPermissionSet to Extension to be manipulated during initialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 months 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
« no previous file with comments | « no previous file | chrome/common/extensions/extension.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/file_path.h" 16 #include "base/file_path.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/hash_tables.h" 18 #include "base/hash_tables.h"
19 #include "base/memory/linked_ptr.h" 19 #include "base/memory/linked_ptr.h"
20 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
21 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
22 #include "base/synchronization/lock.h" 22 #include "base/synchronization/lock.h"
23 #include "base/threading/thread_checker.h" 23 #include "base/threading/thread_checker.h"
24 #include "chrome/common/extensions/extension_constants.h" 24 #include "chrome/common/extensions/extension_constants.h"
25 #include "chrome/common/extensions/extension_icon_set.h" 25 #include "chrome/common/extensions/extension_icon_set.h"
26 #include "chrome/common/extensions/manifest.h" 26 #include "chrome/common/extensions/manifest.h"
27 #include "chrome/common/extensions/permissions/api_permission.h" 27 #include "chrome/common/extensions/permissions/api_permission.h"
28 #include "chrome/common/extensions/permissions/api_permission_set.h"
29 #include "chrome/common/extensions/permissions/permission_message.h" 28 #include "chrome/common/extensions/permissions/permission_message.h"
30 #include "chrome/common/extensions/user_script.h" 29 #include "chrome/common/extensions/user_script.h"
31 #include "extensions/common/install_warning.h" 30 #include "extensions/common/install_warning.h"
32 #include "extensions/common/url_pattern.h" 31 #include "extensions/common/url_pattern.h"
33 #include "extensions/common/url_pattern_set.h" 32 #include "extensions/common/url_pattern_set.h"
34 #include "googleurl/src/gurl.h" 33 #include "googleurl/src/gurl.h"
35 #include "ui/base/accelerators/accelerator.h" 34 #include "ui/base/accelerators/accelerator.h"
36 #include "ui/gfx/size.h" 35 #include "ui/gfx/size.h"
37 36
38 class ExtensionAction; 37 class ExtensionAction;
39 class ExtensionResource; 38 class ExtensionResource;
40 class SkBitmap; 39 class SkBitmap;
41 class Version; 40 class Version;
42 41
43 namespace base { 42 namespace base {
44 class DictionaryValue; 43 class DictionaryValue;
45 class ListValue; 44 class ListValue;
46 } 45 }
47 46
48 namespace gfx { 47 namespace gfx {
49 class ImageSkia; 48 class ImageSkia;
50 } 49 }
51 50
52 FORWARD_DECLARE_TEST(TabStripModelTest, Apps); 51 FORWARD_DECLARE_TEST(TabStripModelTest, Apps);
53 52
54 namespace extensions { 53 namespace extensions {
55 struct ActionInfo; 54 struct ActionInfo;
55 class APIPermissionSet;
56 class PermissionSet; 56 class PermissionSet;
57 57
58 // Represents a Chrome extension. 58 // Represents a Chrome extension.
59 class Extension : public base::RefCountedThreadSafe<Extension> { 59 class Extension : public base::RefCountedThreadSafe<Extension> {
60 public: 60 public:
61 struct ManifestData; 61 struct ManifestData;
62 62
63 typedef std::vector<std::string> ScriptingWhitelist; 63 typedef std::vector<std::string> ScriptingWhitelist;
64 typedef std::map<const std::string, linked_ptr<ManifestData> > 64 typedef std::map<const std::string, linked_ptr<ManifestData> >
65 ManifestDataMap; 65 ManifestDataMap;
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 522 }
523 bool has_lazy_background_page() const { 523 bool has_lazy_background_page() const {
524 return has_background_page() && !background_page_is_persistent_; 524 return has_background_page() && !background_page_is_persistent_;
525 } 525 }
526 const PermissionSet* optional_permission_set() const { 526 const PermissionSet* optional_permission_set() const {
527 return optional_permission_set_.get(); 527 return optional_permission_set_.get();
528 } 528 }
529 const PermissionSet* required_permission_set() const { 529 const PermissionSet* required_permission_set() const {
530 return required_permission_set_.get(); 530 return required_permission_set_.get();
531 } 531 }
532 // Returns the temporary APIPermissionSet used in initialization.
533 // (NULL after initialization is completed.)
534 APIPermissionSet* initial_api_permissions() {
535 return initial_api_permissions_.get();
536 }
532 // Appends |new_warning[s]| to install_warnings_. 537 // Appends |new_warning[s]| to install_warnings_.
533 void AddInstallWarning(const InstallWarning& new_warning); 538 void AddInstallWarning(const InstallWarning& new_warning);
534 void AddInstallWarnings(const std::vector<InstallWarning>& new_warnings); 539 void AddInstallWarnings(const std::vector<InstallWarning>& new_warnings);
535 const std::vector<InstallWarning>& install_warnings() const { 540 const std::vector<InstallWarning>& install_warnings() const {
536 return install_warnings_; 541 return install_warnings_;
537 } 542 }
538 const ExtensionIconSet& icons() const { return icons_; } 543 const ExtensionIconSet& icons() const { return icons_; }
539 const extensions::Manifest* manifest() const { 544 const extensions::Manifest* manifest() const {
540 return manifest_.get(); 545 return manifest_.get();
541 } 546 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 // TODO(aa): Rename to just Init()? There's no Value here anymore. 640 // TODO(aa): Rename to just Init()? There's no Value here anymore.
636 // TODO(aa): It is really weird the way this class essentially contains a copy 641 // TODO(aa): It is really weird the way this class essentially contains a copy
637 // of the underlying DictionaryValue in its members. We should decide to 642 // of the underlying DictionaryValue in its members. We should decide to
638 // either wrap the DictionaryValue and go with that only, or we should parse 643 // either wrap the DictionaryValue and go with that only, or we should parse
639 // into strong types and discard the value. But doing both is bad. 644 // into strong types and discard the value. But doing both is bad.
640 bool InitFromValue(int flags, string16* error); 645 bool InitFromValue(int flags, string16* error);
641 646
642 // The following are helpers for InitFromValue to load various features of the 647 // The following are helpers for InitFromValue to load various features of the
643 // extension from the manifest. 648 // extension from the manifest.
644 649
645 bool LoadAppIsolation(const APIPermissionSet& api_permissions, 650 bool LoadAppIsolation(string16* error);
646 string16* error);
647 651
648 bool LoadRequiredFeatures(string16* error); 652 bool LoadRequiredFeatures(string16* error);
649 bool LoadName(string16* error); 653 bool LoadName(string16* error);
650 bool LoadVersion(string16* error); 654 bool LoadVersion(string16* error);
651 655
652 bool LoadAppFeatures(string16* error); 656 bool LoadAppFeatures(string16* error);
653 bool LoadExtent(const char* key, 657 bool LoadExtent(const char* key,
654 URLPatternSet* extent, 658 URLPatternSet* extent,
655 const char* list_error, 659 const char* list_error,
656 const char* value_error, 660 const char* value_error,
657 string16* error); 661 string16* error);
658 bool LoadLaunchContainer(string16* error); 662 bool LoadLaunchContainer(string16* error);
659 bool LoadLaunchURL(string16* error); 663 bool LoadLaunchURL(string16* error);
660 664
661 bool LoadSharedFeatures(const APIPermissionSet& api_permissions, 665 bool LoadSharedFeatures(string16* error);
662 string16* error);
663 bool LoadDescription(string16* error); 666 bool LoadDescription(string16* error);
664 bool LoadManifestVersion(string16* error); 667 bool LoadManifestVersion(string16* error);
665 bool LoadIcons(string16* error); 668 bool LoadIcons(string16* error);
666 bool LoadPlugins(string16* error); 669 bool LoadPlugins(string16* error);
667 bool LoadNaClModules(string16* error); 670 bool LoadNaClModules(string16* error);
668 bool LoadSandboxedPages(string16* error); 671 bool LoadSandboxedPages(string16* error);
669 // Must be called after LoadPlugins(). 672 // Must be called after LoadPlugins().
670 bool LoadRequirements(string16* error); 673 bool LoadRequirements(string16* error);
671 bool LoadOfflineEnabled(string16* error); 674 bool LoadOfflineEnabled(string16* error);
672 bool LoadBackgroundScripts(string16* error); 675 bool LoadBackgroundScripts(string16* error);
673 bool LoadBackgroundScripts(const std::string& key, string16* error); 676 bool LoadBackgroundScripts(const std::string& key, string16* error);
674 bool LoadBackgroundPage(const APIPermissionSet& api_permissions, 677 bool LoadBackgroundPage(string16* error);
678 bool LoadBackgroundPage(const std::string& key,
675 string16* error); 679 string16* error);
676 bool LoadBackgroundPage(const std::string& key, 680 bool LoadBackgroundPersistent(string16* error);
677 const APIPermissionSet& api_permissions, 681 bool LoadBackgroundAllowJSAccess(string16* error);
678 string16* error); 682 bool LoadExtensionFeatures(string16* error);
679 bool LoadBackgroundPersistent(
680 const APIPermissionSet& api_permissions,
681 string16* error);
682 bool LoadBackgroundAllowJSAccess(
683 const APIPermissionSet& api_permissions,
684 string16* error);
685 bool LoadExtensionFeatures(APIPermissionSet* api_permissions,
686 string16* error);
687 bool LoadContentScripts(string16* error); 683 bool LoadContentScripts(string16* error);
688 bool LoadBrowserAction(string16* error); 684 bool LoadBrowserAction(string16* error);
689 bool LoadSystemIndicator(APIPermissionSet* api_permissions, string16* error); 685 bool LoadSystemIndicator(string16* error);
690 bool LoadTextToSpeechVoices(string16* error); 686 bool LoadTextToSpeechVoices(string16* error);
691 bool LoadIncognitoMode(string16* error); 687 bool LoadIncognitoMode(string16* error);
692 bool LoadContentSecurityPolicy(string16* error); 688 bool LoadContentSecurityPolicy(string16* error);
693 bool LoadManagedModeFeatures(string16* error); 689 bool LoadManagedModeFeatures(string16* error);
694 bool LoadManagedModeSites( 690 bool LoadManagedModeSites(
695 const base::DictionaryValue* content_pack_value, 691 const base::DictionaryValue* content_pack_value,
696 string16* error); 692 string16* error);
697 bool LoadManagedModeConfigurations( 693 bool LoadManagedModeConfigurations(
698 const base::DictionaryValue* content_pack_value, 694 const base::DictionaryValue* content_pack_value,
699 string16* error); 695 string16* error);
(...skipping 22 matching lines...) Expand all
722 // |override_url|. 718 // |override_url|.
723 void OverrideLaunchUrl(const GURL& override_url); 719 void OverrideLaunchUrl(const GURL& override_url);
724 720
725 // Custom checks for the experimental permission that can't be expressed in 721 // Custom checks for the experimental permission that can't be expressed in
726 // _permission_features.json. 722 // _permission_features.json.
727 bool CanSpecifyExperimentalPermission() const; 723 bool CanSpecifyExperimentalPermission() const;
728 724
729 // Checks whether the host |pattern| is allowed for this extension, given API 725 // Checks whether the host |pattern| is allowed for this extension, given API
730 // permissions |permissions|. 726 // permissions |permissions|.
731 bool CanSpecifyHostPermission(const URLPattern& pattern, 727 bool CanSpecifyHostPermission(const URLPattern& pattern,
732 const APIPermissionSet& permissions) const; 728 const APIPermissionSet& permissions) const;
733 729
734 bool CheckMinimumChromeVersion(string16* error) const; 730 bool CheckMinimumChromeVersion(string16* error) const;
735 731
736 // Check that platform app features are valid. Called after InitFromValue. 732 // Check that platform app features are valid. Called after InitFromValue.
737 bool CheckPlatformAppFeatures(std::string* utf8_error) const; 733 bool CheckPlatformAppFeatures(std::string* utf8_error) const;
738 734
739 // Check that features don't conflict. Called after InitFromValue. 735 // Check that features don't conflict. Called after InitFromValue.
740 bool CheckConflictingFeatures(std::string* utf8_error) const; 736 bool CheckConflictingFeatures(std::string* utf8_error) const;
741 737
742 // The extension's human-readable name. Name is used for display purpose. It 738 // The extension's human-readable name. Name is used for display purpose. It
(...skipping 27 matching lines...) Expand all
770 // Whether the extension or app should be enabled when offline. 766 // Whether the extension or app should be enabled when offline.
771 bool offline_enabled_; 767 bool offline_enabled_;
772 768
773 // Defines the set of URLs in the extension's web content. 769 // Defines the set of URLs in the extension's web content.
774 URLPatternSet extent_; 770 URLPatternSet extent_;
775 771
776 // The extension runtime data. 772 // The extension runtime data.
777 mutable base::Lock runtime_data_lock_; 773 mutable base::Lock runtime_data_lock_;
778 mutable RuntimeData runtime_data_; 774 mutable RuntimeData runtime_data_;
779 775
776 // The API permission set; used during extension initialization.
777 // Cleared after permissions are finalized by SetActivePermissions.
778 scoped_ptr<APIPermissionSet> initial_api_permissions_;
779
780 // The set of permissions the extension can request at runtime. 780 // The set of permissions the extension can request at runtime.
781 scoped_refptr<const PermissionSet> optional_permission_set_; 781 scoped_refptr<const PermissionSet> optional_permission_set_;
782 782
783 // The extension's required / default set of permissions. 783 // The extension's required / default set of permissions.
784 scoped_refptr<const PermissionSet> required_permission_set_; 784 scoped_refptr<const PermissionSet> required_permission_set_;
785 785
786 // Any warnings that occurred when trying to create/parse the extension. 786 // Any warnings that occurred when trying to create/parse the extension.
787 std::vector<InstallWarning> install_warnings_; 787 std::vector<InstallWarning> install_warnings_;
788 788
789 // The icons for the extension. 789 // The icons for the extension.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 961
962 UpdatedExtensionPermissionsInfo( 962 UpdatedExtensionPermissionsInfo(
963 const Extension* extension, 963 const Extension* extension,
964 const PermissionSet* permissions, 964 const PermissionSet* permissions,
965 Reason reason); 965 Reason reason);
966 }; 966 };
967 967
968 } // namespace extensions 968 } // namespace extensions
969 969
970 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 970 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698