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

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

Issue 11786003: Move Icons out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: License year update Created 7 years, 11 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) 2012 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/command.h" 24 #include "chrome/common/extensions/command.h"
25 #include "chrome/common/extensions/extension_constants.h" 25 #include "chrome/common/extensions/extension_constants.h"
26 #include "chrome/common/extensions/extension_icon_set.h" 26 #include "chrome/common/extensions/extension_icon_set.h"
27 #include "chrome/common/extensions/extension_resource.h"
27 #include "chrome/common/extensions/permissions/api_permission.h" 28 #include "chrome/common/extensions/permissions/api_permission.h"
28 #include "chrome/common/extensions/permissions/api_permission_set.h" 29 #include "chrome/common/extensions/permissions/api_permission_set.h"
29 #include "chrome/common/extensions/permissions/permission_message.h" 30 #include "chrome/common/extensions/permissions/permission_message.h"
30 #include "chrome/common/extensions/user_script.h" 31 #include "chrome/common/extensions/user_script.h"
31 #include "extensions/common/url_pattern.h" 32 #include "extensions/common/url_pattern.h"
32 #include "extensions/common/url_pattern_set.h" 33 #include "extensions/common/url_pattern_set.h"
33 #include "googleurl/src/gurl.h" 34 #include "googleurl/src/gurl.h"
34 #include "ui/base/accelerators/accelerator.h" 35 #include "ui/base/accelerators/accelerator.h"
35 #include "ui/gfx/size.h" 36 #include "ui/gfx/size.h"
36 37
37 class ExtensionAction; 38 class ExtensionAction;
38 class ExtensionResource;
39 class SkBitmap; 39 class SkBitmap;
40 class Version; 40 class Version;
41 41
42 namespace base { 42 namespace base {
43 class DictionaryValue; 43 class DictionaryValue;
44 class ListValue; 44 class ListValue;
45 } 45 }
46 46
47 namespace gfx { 47 namespace gfx {
48 class ImageSkia; 48 class ImageSkia;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 const base::DictionaryValue& value, 287 const base::DictionaryValue& value,
288 int flags, 288 int flags,
289 const std::string& explicit_id, 289 const std::string& explicit_id,
290 std::string* error); 290 std::string* error);
291 291
292 // Given two install sources, return the one which should take priority 292 // Given two install sources, return the one which should take priority
293 // over the other. If an extension is installed from two sources A and B, 293 // over the other. If an extension is installed from two sources A and B,
294 // its install source should be set to GetHigherPriorityLocation(A, B). 294 // its install source should be set to GetHigherPriorityLocation(A, B).
295 static Location GetHigherPriorityLocation(Location loc1, Location loc2); 295 static Location GetHigherPriorityLocation(Location loc1, Location loc2);
296 296
297 // Max size (both dimensions) for browser and page actions.
298 static const int kPageActionIconMaxSize;
299 static const int kBrowserActionIconMaxSize;
300
301 // Valid schemes for web extent URLPatterns. 297 // Valid schemes for web extent URLPatterns.
302 static const int kValidWebExtentSchemes; 298 static const int kValidWebExtentSchemes;
303 299
304 // Valid schemes for host permission URLPatterns. 300 // Valid schemes for host permission URLPatterns.
305 static const int kValidHostPermissionSchemes; 301 static const int kValidHostPermissionSchemes;
306 302
307 // The name of the manifest inside an extension. 303 // The name of the manifest inside an extension.
308 static const FilePath::CharType kManifestFilename[]; 304 static const FilePath::CharType kManifestFilename[];
309 305
310 // The name of locale folder inside an extension. 306 // The name of locale folder inside an extension.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // always generate the same output ID. 407 // always generate the same output ID.
412 static bool GenerateId(const std::string& input, 408 static bool GenerateId(const std::string& input,
413 std::string* output) WARN_UNUSED_RESULT; 409 std::string* output) WARN_UNUSED_RESULT;
414 410
415 // Expects base64 encoded |input| and formats into |output| including 411 // Expects base64 encoded |input| and formats into |output| including
416 // the appropriate header & footer. 412 // the appropriate header & footer.
417 static bool FormatPEMForFileOutput(const std::string& input, 413 static bool FormatPEMForFileOutput(const std::string& input,
418 std::string* output, 414 std::string* output,
419 bool is_public); 415 bool is_public);
420 416
421 // Given an extension, icon size, and match type, read a valid icon if present
422 // and decode it into result. In the browser process, this will DCHECK if not
423 // called on the file thread. To easily load extension images on the UI
424 // thread, see ImageLoadingTracker.
425 static void DecodeIcon(const Extension* extension,
426 int icon_size,
427 ExtensionIconSet::MatchType match_type,
428 scoped_ptr<SkBitmap>* result);
429
430 // Given an extension and icon size, read it if present and decode it into
431 // result. In the browser process, this will DCHECK if not called on the
432 // file thread. To easily load extension images on the UI thread, see
433 // ImageLoadingTracker.
434 static void DecodeIcon(const Extension* extension,
435 int icon_size,
436 scoped_ptr<SkBitmap>* result);
437
438 // Given an icon_path and icon size, read it if present and decode it into
439 // result. In the browser process, this will DCHECK if not called on the
440 // file thread. To easily load extension images on the UI thread, see
441 // ImageLoadingTracker.
442 static void DecodeIconFromPath(const FilePath& icon_path,
443 int icon_size,
444 scoped_ptr<SkBitmap>* result);
445
446 // Returns the default extension/app icon (for extensions or apps that don't
447 // have one).
448 static const gfx::ImageSkia& GetDefaultIcon(bool is_app);
449
450 // Returns the base extension url for a given |extension_id|. 417 // Returns the base extension url for a given |extension_id|.
451 static GURL GetBaseURLFromExtensionId(const std::string& extension_id); 418 static GURL GetBaseURLFromExtensionId(const std::string& extension_id);
452 419
453 // Adds an extension to the scripting whitelist. Used for testing only. 420 // Adds an extension to the scripting whitelist. Used for testing only.
454 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); 421 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist);
455 static const ScriptingWhitelist* GetScriptingWhitelist(); 422 static const ScriptingWhitelist* GetScriptingWhitelist();
456 423
457 // Parses the host and api permissions from the specified permission |key| 424 // Parses the host and api permissions from the specified permission |key|
458 // from |manifest_|. 425 // from |manifest_|.
459 bool ParsePermissions(const char* key, 426 bool ParsePermissions(const char* key,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 486
520 // Returns the Homepage URL for this extension. If homepage_url was not 487 // Returns the Homepage URL for this extension. If homepage_url was not
521 // specified in the manifest, this returns the Google Gallery URL. For 488 // specified in the manifest, this returns the Google Gallery URL. For
522 // third-party extensions, this returns a blank GURL. 489 // third-party extensions, this returns a blank GURL.
523 GURL GetHomepageURL() const; 490 GURL GetHomepageURL() const;
524 491
525 // Returns a list of paths (relative to the extension dir) for images that 492 // Returns a list of paths (relative to the extension dir) for images that
526 // the browser might load (like themes and page action icons). 493 // the browser might load (like themes and page action icons).
527 std::set<FilePath> GetBrowserImages() const; 494 std::set<FilePath> GetBrowserImages() const;
528 495
529 // Get an extension icon as a resource or URL.
530 ExtensionResource GetIconResource(
531 int size, ExtensionIconSet::MatchType match_type) const;
532 GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const;
533
534 // Gets the fully resolved absolute launch URL. 496 // Gets the fully resolved absolute launch URL.
535 GURL GetFullLaunchURL() const; 497 GURL GetFullLaunchURL() const;
536 498
537 // Image cache related methods. These are only valid on the UI thread and 499 // Image cache related methods. These are only valid on the UI thread and
538 // not maintained by this class. See ImageLoadingTracker for usage. The 500 // not maintained by this class. See ImageLoadingTracker for usage. The
539 // |original_size| parameter should be the size of the image at |source| 501 // |original_size| parameter should be the size of the image at |source|
540 // before any scaling may have been done to produce the pixels in |image|. 502 // before any scaling may have been done to produce the pixels in |image|.
541 void SetCachedImage(const ExtensionResource& source, 503 void SetCachedImage(const ExtensionResource& source,
542 const SkBitmap& image, 504 const SkBitmap& image,
543 const gfx::Size& original_size) const; 505 const gfx::Size& original_size) const;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 const PermissionSet* required_permission_set() const { 663 const PermissionSet* required_permission_set() const {
702 return required_permission_set_.get(); 664 return required_permission_set_.get();
703 } 665 }
704 // Appends |new_warning[s]| to install_warnings_. 666 // Appends |new_warning[s]| to install_warnings_.
705 void AddInstallWarning(const InstallWarning& new_warning); 667 void AddInstallWarning(const InstallWarning& new_warning);
706 void AddInstallWarnings(const InstallWarningVector& new_warnings); 668 void AddInstallWarnings(const InstallWarningVector& new_warnings);
707 const InstallWarningVector& install_warnings() const { 669 const InstallWarningVector& install_warnings() const {
708 return install_warnings_; 670 return install_warnings_;
709 } 671 }
710 const GURL& update_url() const { return update_url_; } 672 const GURL& update_url() const { return update_url_; }
711 const ExtensionIconSet& icons() const { return icons_; }
712 const extensions::Manifest* manifest() const { 673 const extensions::Manifest* manifest() const {
713 return manifest_.get(); 674 return manifest_.get();
714 } 675 }
715 const std::string default_locale() const { return default_locale_; } 676 const std::string default_locale() const { return default_locale_; }
716 const URLOverrideMap& GetChromeURLOverrides() const { 677 const URLOverrideMap& GetChromeURLOverrides() const {
717 return chrome_url_overrides_; 678 return chrome_url_overrides_;
718 } 679 }
719 bool incognito_split_mode() const { return incognito_split_mode_; } 680 bool incognito_split_mode() const { return incognito_split_mode_; }
720 bool offline_enabled() const { return offline_enabled_; } 681 bool offline_enabled() const { return offline_enabled_; }
721 const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; } 682 const std::vector<TtsVoice>& tts_voices() const { return tts_voices_; }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 string16* error); 812 string16* error);
852 bool LoadLaunchContainer(string16* error); 813 bool LoadLaunchContainer(string16* error);
853 bool LoadLaunchURL(string16* error); 814 bool LoadLaunchURL(string16* error);
854 815
855 bool LoadSharedFeatures(const APIPermissionSet& api_permissions, 816 bool LoadSharedFeatures(const APIPermissionSet& api_permissions,
856 string16* error); 817 string16* error);
857 bool LoadDescription(string16* error); 818 bool LoadDescription(string16* error);
858 bool LoadManifestVersion(string16* error); 819 bool LoadManifestVersion(string16* error);
859 bool LoadHomepageURL(string16* error); 820 bool LoadHomepageURL(string16* error);
860 bool LoadUpdateURL(string16* error); 821 bool LoadUpdateURL(string16* error);
861 bool LoadIcons(string16* error);
862 bool LoadCommands(string16* error); 822 bool LoadCommands(string16* error);
863 bool LoadPlugins(string16* error); 823 bool LoadPlugins(string16* error);
864 bool LoadNaClModules(string16* error); 824 bool LoadNaClModules(string16* error);
865 bool LoadWebAccessibleResources(string16* error); 825 bool LoadWebAccessibleResources(string16* error);
866 bool LoadSandboxedPages(string16* error); 826 bool LoadSandboxedPages(string16* error);
867 // Must be called after LoadPlugins(). 827 // Must be called after LoadPlugins().
868 bool LoadRequirements(string16* error); 828 bool LoadRequirements(string16* error);
869 bool LoadDefaultLocale(string16* error); 829 bool LoadDefaultLocale(string16* error);
870 bool LoadOfflineEnabled(string16* error); 830 bool LoadOfflineEnabled(string16* error);
871 bool LoadOptionsPage(string16* error); 831 bool LoadOptionsPage(string16* error);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 971
1012 // The set of permissions the extension can request at runtime. 972 // The set of permissions the extension can request at runtime.
1013 scoped_refptr<const PermissionSet> optional_permission_set_; 973 scoped_refptr<const PermissionSet> optional_permission_set_;
1014 974
1015 // The extension's required / default set of permissions. 975 // The extension's required / default set of permissions.
1016 scoped_refptr<const PermissionSet> required_permission_set_; 976 scoped_refptr<const PermissionSet> required_permission_set_;
1017 977
1018 // Any warnings that occurred when trying to create/parse the extension. 978 // Any warnings that occurred when trying to create/parse the extension.
1019 InstallWarningVector install_warnings_; 979 InstallWarningVector install_warnings_;
1020 980
1021 // The icons for the extension.
1022 ExtensionIconSet icons_;
1023
1024 // The base extension url for the extension. 981 // The base extension url for the extension.
1025 GURL extension_url_; 982 GURL extension_url_;
1026 983
1027 // The extension's version. 984 // The extension's version.
1028 scoped_ptr<Version> version_; 985 scoped_ptr<Version> version_;
1029 986
1030 // An optional longer description of the extension. 987 // An optional longer description of the extension.
1031 std::string description_; 988 std::string description_;
1032 989
1033 // True if the extension was generated from a user script. (We show slightly 990 // True if the extension was generated from a user script. (We show slightly
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 1207
1251 UpdatedExtensionPermissionsInfo( 1208 UpdatedExtensionPermissionsInfo(
1252 const Extension* extension, 1209 const Extension* extension,
1253 const PermissionSet* permissions, 1210 const PermissionSet* permissions,
1254 Reason reason); 1211 Reason reason);
1255 }; 1212 };
1256 1213
1257 } // namespace extensions 1214 } // namespace extensions
1258 1215
1259 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 1216 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698