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

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

Issue 12316077: Move the parsing of app.launch related keys out of Extension class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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"
18 #include "base/hash_tables.h" 17 #include "base/hash_tables.h"
19 #include "base/memory/linked_ptr.h" 18 #include "base/memory/linked_ptr.h"
20 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
21 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
22 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
23 #include "base/threading/thread_checker.h" 22 #include "base/threading/thread_checker.h"
24 #include "chrome/common/extensions/extension_constants.h" 23 #include "chrome/common/extensions/extension_constants.h"
25 #include "chrome/common/extensions/extension_icon_set.h" 24 #include "chrome/common/extensions/extension_icon_set.h"
26 #include "chrome/common/extensions/manifest.h" 25 #include "chrome/common/extensions/manifest.h"
27 #include "chrome/common/extensions/permissions/api_permission.h" 26 #include "chrome/common/extensions/permissions/api_permission.h"
(...skipping 13 matching lines...) Expand all
41 40
42 namespace base { 41 namespace base {
43 class DictionaryValue; 42 class DictionaryValue;
44 class ListValue; 43 class ListValue;
45 } 44 }
46 45
47 namespace gfx { 46 namespace gfx {
48 class ImageSkia; 47 class ImageSkia;
49 } 48 }
50 49
51 FORWARD_DECLARE_TEST(TabStripModelTest, Apps);
52
53 namespace extensions { 50 namespace extensions {
54 struct ActionInfo; 51 struct ActionInfo;
55 class APIPermissionSet; 52 class APIPermissionSet;
56 class PermissionSet; 53 class PermissionSet;
57 54
58 // Represents a Chrome extension. 55 // Represents a Chrome extension.
59 class Extension : public base::RefCountedThreadSafe<Extension> { 56 class Extension : public base::RefCountedThreadSafe<Extension> {
60 public: 57 public:
61 struct ManifestData; 58 struct ManifestData;
62 59
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 389
393 // Returns a list of paths (relative to the extension dir) for images that 390 // Returns a list of paths (relative to the extension dir) for images that
394 // the browser might load (like themes and page action icons). 391 // the browser might load (like themes and page action icons).
395 std::set<base::FilePath> GetBrowserImages() const; 392 std::set<base::FilePath> GetBrowserImages() const;
396 393
397 // Get an extension icon as a resource or URL. 394 // Get an extension icon as a resource or URL.
398 ExtensionResource GetIconResource( 395 ExtensionResource GetIconResource(
399 int size, ExtensionIconSet::MatchType match_type) const; 396 int size, ExtensionIconSet::MatchType match_type) const;
400 GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const; 397 GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const;
401 398
402 // Gets the fully resolved absolute launch URL.
403 GURL GetFullLaunchURL() const;
404
405 // Returns true if this extension can execute script on a page. If a 399 // Returns true if this extension can execute script on a page. If a
406 // UserScript object is passed, permission to run that specific script is 400 // UserScript object is passed, permission to run that specific script is
407 // checked (using its matches list). Otherwise, permission to execute script 401 // checked (using its matches list). Otherwise, permission to execute script
408 // programmatically is checked (using the extension's host permission). 402 // programmatically is checked (using the extension's host permission).
409 // 403 //
410 // This method is also aware of certain special pages that extensions are 404 // This method is also aware of certain special pages that extensions are
411 // usually not allowed to run script on. 405 // usually not allowed to run script on.
412 bool CanExecuteScriptOnPage(const GURL& document_url, 406 bool CanExecuteScriptOnPage(const GURL& document_url,
413 const GURL& top_document_url, 407 const GURL& top_document_url,
414 int tab_id, 408 int tab_id,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 bool is_app() const { 552 bool is_app() const {
559 return is_legacy_packaged_app() || is_hosted_app() || is_platform_app(); 553 return is_legacy_packaged_app() || is_hosted_app() || is_platform_app();
560 } 554 }
561 bool is_platform_app() const; 555 bool is_platform_app() const;
562 bool is_hosted_app() const; 556 bool is_hosted_app() const;
563 bool is_legacy_packaged_app() const; 557 bool is_legacy_packaged_app() const;
564 bool is_extension() const; 558 bool is_extension() const;
565 bool is_storage_isolated() const { return is_storage_isolated_; } 559 bool is_storage_isolated() const { return is_storage_isolated_; }
566 bool can_be_incognito_enabled() const; 560 bool can_be_incognito_enabled() const;
567 void AddWebExtentPattern(const URLPattern& pattern); 561 void AddWebExtentPattern(const URLPattern& pattern);
562 void ClearWebExtentPatterns();
568 const URLPatternSet& web_extent() const { return extent_; } 563 const URLPatternSet& web_extent() const { return extent_; }
569 const std::string& launch_local_path() const { return launch_local_path_; }
570 const std::string& launch_web_url() const { return launch_web_url_; }
571 extension_misc::LaunchContainer launch_container() const {
572 return launch_container_;
573 }
574 int launch_width() const { return launch_width_; }
575 int launch_height() const { return launch_height_; }
576 564
577 // Theme-related. 565 // Theme-related.
578 bool is_theme() const; 566 bool is_theme() const;
579 567
580 // Content pack related. 568 // Content pack related.
581 bool is_content_pack() const; 569 bool is_content_pack() const;
582 ExtensionResource GetContentPackSiteList() const; 570 ExtensionResource GetContentPackSiteList() const;
583 571
584 GURL GetBackgroundURL() const; 572 GURL GetBackgroundURL() const;
585 573
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 bool LoadRequiredFeatures(string16* error); 635 bool LoadRequiredFeatures(string16* error);
648 bool LoadName(string16* error); 636 bool LoadName(string16* error);
649 bool LoadVersion(string16* error); 637 bool LoadVersion(string16* error);
650 638
651 bool LoadAppFeatures(string16* error); 639 bool LoadAppFeatures(string16* error);
652 bool LoadExtent(const char* key, 640 bool LoadExtent(const char* key,
653 URLPatternSet* extent, 641 URLPatternSet* extent,
654 const char* list_error, 642 const char* list_error,
655 const char* value_error, 643 const char* value_error,
656 string16* error); 644 string16* error);
657 bool LoadLaunchContainer(string16* error);
658 bool LoadLaunchURL(string16* error);
659 645
660 bool LoadSharedFeatures(string16* error); 646 bool LoadSharedFeatures(string16* error);
661 bool LoadDescription(string16* error); 647 bool LoadDescription(string16* error);
662 bool LoadManifestVersion(string16* error); 648 bool LoadManifestVersion(string16* error);
663 bool LoadIcons(string16* error); 649 bool LoadIcons(string16* error);
664 bool LoadPlugins(string16* error); 650 bool LoadPlugins(string16* error);
665 bool LoadNaClModules(string16* error); 651 bool LoadNaClModules(string16* error);
666 bool LoadSandboxedPages(string16* error); 652 bool LoadSandboxedPages(string16* error);
667 // Must be called after LoadPlugins(). 653 // Must be called after LoadPlugins().
668 bool LoadRequirements(string16* error); 654 bool LoadRequirements(string16* error);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 int content_script_index, 687 int content_script_index,
702 const char* globs_property_name, 688 const char* globs_property_name,
703 string16* error, 689 string16* error,
704 void(UserScript::*add_method)(const std::string& glob), 690 void(UserScript::*add_method)(const std::string& glob),
705 UserScript* instance); 691 UserScript* instance);
706 692
707 // Returns true if the extension has more than one "UI surface". For example, 693 // Returns true if the extension has more than one "UI surface". For example,
708 // an extension that has a browser action and a page action. 694 // an extension that has a browser action and a page action.
709 bool HasMultipleUISurfaces() const; 695 bool HasMultipleUISurfaces() const;
710 696
711 // Updates the launch URL and extents for the extension using the given
712 // |override_url|.
713 void OverrideLaunchUrl(const GURL& override_url);
714
715 // Custom checks for the experimental permission that can't be expressed in 697 // Custom checks for the experimental permission that can't be expressed in
716 // _permission_features.json. 698 // _permission_features.json.
717 bool CanSpecifyExperimentalPermission() const; 699 bool CanSpecifyExperimentalPermission() const;
718 700
719 // Checks whether the host |pattern| is allowed for this extension, given API 701 // Checks whether the host |pattern| is allowed for this extension, given API
720 // permissions |permissions|. 702 // permissions |permissions|.
721 bool CanSpecifyHostPermission(const URLPattern& pattern, 703 bool CanSpecifyHostPermission(const URLPattern& pattern,
722 const APIPermissionSet& permissions) const; 704 const APIPermissionSet& permissions) const;
723 705
724 bool CheckMinimumChromeVersion(string16* error) const; 706 bool CheckMinimumChromeVersion(string16* error) const;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 bool finished_parsing_manifest_; 833 bool finished_parsing_manifest_;
852 834
853 // Ensures that any call to GetManifestData() prior to finishing 835 // Ensures that any call to GetManifestData() prior to finishing
854 // initialization happens from the same thread (this can happen when certain 836 // initialization happens from the same thread (this can happen when certain
855 // parts of the initialization process need information from previous parts). 837 // parts of the initialization process need information from previous parts).
856 base::ThreadChecker thread_checker_; 838 base::ThreadChecker thread_checker_;
857 839
858 // Whether this extension requests isolated storage. 840 // Whether this extension requests isolated storage.
859 bool is_storage_isolated_; 841 bool is_storage_isolated_;
860 842
861 // The local path inside the extension to use with the launcher.
862 std::string launch_local_path_;
863
864 // A web url to use with the launcher. Note that this might be relative or
865 // absolute. If relative, it is relative to web_origin.
866 std::string launch_web_url_;
867
868 // The window type that an app's manifest specifies to launch into.
869 // This is not always the window type an app will open into, because
870 // users can override the way each app launches. See
871 // ExtensionPrefs::GetLaunchContainer(), which looks at a per-app pref
872 // to decide what container an app will launch in.
873 extension_misc::LaunchContainer launch_container_;
874
875 // The default size of the container when launching. Only respected for
876 // containers like panels and windows.
877 int launch_width_;
878 int launch_height_;
879
880 // Should this app be shown in the app launcher. 843 // Should this app be shown in the app launcher.
881 bool display_in_launcher_; 844 bool display_in_launcher_;
882 845
883 // Should this app be shown in the browser New Tab Page. 846 // Should this app be shown in the browser New Tab Page.
884 bool display_in_new_tab_page_; 847 bool display_in_new_tab_page_;
885 848
886 // Whether the extension has host permissions or user script patterns that 849 // Whether the extension has host permissions or user script patterns that
887 // imply access to file:/// scheme URLs (the user may not have actually 850 // imply access to file:/// scheme URLs (the user may not have actually
888 // granted it that access). 851 // granted it that access).
889 bool wants_file_access_; 852 bool wants_file_access_;
890 853
891 // The flags that were passed to InitFromValue. 854 // The flags that were passed to InitFromValue.
892 int creation_flags_; 855 int creation_flags_;
893 856
894 FRIEND_TEST_ALL_PREFIXES(::TabStripModelTest, Apps);
895
896 DISALLOW_COPY_AND_ASSIGN(Extension); 857 DISALLOW_COPY_AND_ASSIGN(Extension);
897 }; 858 };
898 859
899 typedef std::vector<scoped_refptr<const Extension> > ExtensionList; 860 typedef std::vector<scoped_refptr<const Extension> > ExtensionList;
900 typedef std::set<std::string> ExtensionIdSet; 861 typedef std::set<std::string> ExtensionIdSet;
901 typedef std::vector<std::string> ExtensionIdList; 862 typedef std::vector<std::string> ExtensionIdList;
902 863
903 // Handy struct to pass core extension info around. 864 // Handy struct to pass core extension info around.
904 struct ExtensionInfo { 865 struct ExtensionInfo {
905 ExtensionInfo(const base::DictionaryValue* manifest, 866 ExtensionInfo(const base::DictionaryValue* manifest,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 911
951 UpdatedExtensionPermissionsInfo( 912 UpdatedExtensionPermissionsInfo(
952 const Extension* extension, 913 const Extension* extension,
953 const PermissionSet* permissions, 914 const PermissionSet* permissions,
954 Reason reason); 915 Reason reason);
955 }; 916 };
956 917
957 } // namespace extensions 918 } // namespace extensions
958 919
959 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 920 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698