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

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: Latest master + Yoyo's requests 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) 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/api/extension_action/action_info.h" 24 #include "chrome/common/extensions/api/extension_action/action_info.h"
25 #include "chrome/common/extensions/command.h" 25 #include "chrome/common/extensions/command.h"
26 #include "chrome/common/extensions/extension_constants.h" 26 #include "chrome/common/extensions/extension_constants.h"
27 #include "chrome/common/extensions/extension_icon_set.h" 27 #include "chrome/common/extensions/extension_icon_set.h"
28 #include "chrome/common/extensions/extension_resource.h"
28 #include "chrome/common/extensions/permissions/api_permission.h" 29 #include "chrome/common/extensions/permissions/api_permission.h"
29 #include "chrome/common/extensions/permissions/api_permission_set.h" 30 #include "chrome/common/extensions/permissions/api_permission_set.h"
30 #include "chrome/common/extensions/permissions/permission_message.h" 31 #include "chrome/common/extensions/permissions/permission_message.h"
31 #include "chrome/common/extensions/user_script.h" 32 #include "chrome/common/extensions/user_script.h"
32 #include "extensions/common/url_pattern.h" 33 #include "extensions/common/url_pattern.h"
33 #include "extensions/common/url_pattern_set.h" 34 #include "extensions/common/url_pattern_set.h"
34 #include "googleurl/src/gurl.h" 35 #include "googleurl/src/gurl.h"
35 #include "ui/base/accelerators/accelerator.h" 36 #include "ui/base/accelerators/accelerator.h"
36 #include "ui/gfx/size.h" 37 #include "ui/gfx/size.h"
37 38
38 class ExtensionAction; 39 class ExtensionAction;
39 class ExtensionResource;
40 class SkBitmap; 40 class SkBitmap;
41 class Version; 41 class Version;
42 42
43 namespace base { 43 namespace base {
44 class DictionaryValue; 44 class DictionaryValue;
45 class ListValue; 45 class ListValue;
46 } 46 }
47 47
48 namespace gfx { 48 namespace gfx {
49 class ImageSkia; 49 class ImageSkia;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 const base::DictionaryValue& value, 259 const base::DictionaryValue& value,
260 int flags, 260 int flags,
261 const std::string& explicit_id, 261 const std::string& explicit_id,
262 std::string* error); 262 std::string* error);
263 263
264 // Given two install sources, return the one which should take priority 264 // Given two install sources, return the one which should take priority
265 // over the other. If an extension is installed from two sources A and B, 265 // over the other. If an extension is installed from two sources A and B,
266 // its install source should be set to GetHigherPriorityLocation(A, B). 266 // its install source should be set to GetHigherPriorityLocation(A, B).
267 static Location GetHigherPriorityLocation(Location loc1, Location loc2); 267 static Location GetHigherPriorityLocation(Location loc1, Location loc2);
268 268
269 // Max size (both dimensions) for browser and page actions.
270 static const int kPageActionIconMaxSize;
271 static const int kBrowserActionIconMaxSize;
272
273 // Valid schemes for web extent URLPatterns. 269 // Valid schemes for web extent URLPatterns.
274 static const int kValidWebExtentSchemes; 270 static const int kValidWebExtentSchemes;
275 271
276 // Valid schemes for host permission URLPatterns. 272 // Valid schemes for host permission URLPatterns.
277 static const int kValidHostPermissionSchemes; 273 static const int kValidHostPermissionSchemes;
278 274
279 // The name of the manifest inside an extension. 275 // The name of the manifest inside an extension.
280 static const FilePath::CharType kManifestFilename[]; 276 static const FilePath::CharType kManifestFilename[];
281 277
282 // The name of locale folder inside an extension. 278 // The name of locale folder inside an extension.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // always generate the same output ID. 379 // always generate the same output ID.
384 static bool GenerateId(const std::string& input, 380 static bool GenerateId(const std::string& input,
385 std::string* output) WARN_UNUSED_RESULT; 381 std::string* output) WARN_UNUSED_RESULT;
386 382
387 // Expects base64 encoded |input| and formats into |output| including 383 // Expects base64 encoded |input| and formats into |output| including
388 // the appropriate header & footer. 384 // the appropriate header & footer.
389 static bool FormatPEMForFileOutput(const std::string& input, 385 static bool FormatPEMForFileOutput(const std::string& input,
390 std::string* output, 386 std::string* output,
391 bool is_public); 387 bool is_public);
392 388
393 // Given an extension, icon size, and match type, read a valid icon if present
394 // and decode it into result. In the browser process, this will DCHECK if not
395 // called on the file thread. To easily load extension images on the UI
396 // thread, see ImageLoadingTracker.
397 static void DecodeIcon(const Extension* extension,
398 int icon_size,
399 ExtensionIconSet::MatchType match_type,
400 scoped_ptr<SkBitmap>* result);
401
402 // Given an extension and icon size, read it if present and decode it into
403 // result. In the browser process, this will DCHECK if not called on the
404 // file thread. To easily load extension images on the UI thread, see
405 // ImageLoadingTracker.
406 static void DecodeIcon(const Extension* extension,
407 int icon_size,
408 scoped_ptr<SkBitmap>* result);
409
410 // Given an icon_path and icon size, read it if present and decode it into
411 // result. In the browser process, this will DCHECK if not called on the
412 // file thread. To easily load extension images on the UI thread, see
413 // ImageLoadingTracker.
414 static void DecodeIconFromPath(const FilePath& icon_path,
415 int icon_size,
416 scoped_ptr<SkBitmap>* result);
417
418 // Returns the default extension/app icon (for extensions or apps that don't
419 // have one).
420 static const gfx::ImageSkia& GetDefaultIcon(bool is_app);
421
422 // Returns the base extension url for a given |extension_id|. 389 // Returns the base extension url for a given |extension_id|.
423 static GURL GetBaseURLFromExtensionId(const std::string& extension_id); 390 static GURL GetBaseURLFromExtensionId(const std::string& extension_id);
424 391
425 // Adds an extension to the scripting whitelist. Used for testing only. 392 // Adds an extension to the scripting whitelist. Used for testing only.
426 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); 393 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist);
427 static const ScriptingWhitelist* GetScriptingWhitelist(); 394 static const ScriptingWhitelist* GetScriptingWhitelist();
428 395
429 // Parses the host and api permissions from the specified permission |key| 396 // Parses the host and api permissions from the specified permission |key|
430 // from |manifest_|. 397 // from |manifest_|.
431 bool ParsePermissions(const char* key, 398 bool ParsePermissions(const char* key,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 // Gets the extension's active permission set. 453 // Gets the extension's active permission set.
487 scoped_refptr<const PermissionSet> GetActivePermissions() const; 454 scoped_refptr<const PermissionSet> GetActivePermissions() const;
488 455
489 // Whether context menu should be shown for page and browser actions. 456 // Whether context menu should be shown for page and browser actions.
490 bool ShowConfigureContextMenus() const; 457 bool ShowConfigureContextMenus() const;
491 458
492 // Returns a list of paths (relative to the extension dir) for images that 459 // Returns a list of paths (relative to the extension dir) for images that
493 // the browser might load (like themes and page action icons). 460 // the browser might load (like themes and page action icons).
494 std::set<FilePath> GetBrowserImages() const; 461 std::set<FilePath> GetBrowserImages() const;
495 462
496 // Get an extension icon as a resource or URL.
497 ExtensionResource GetIconResource(
498 int size, ExtensionIconSet::MatchType match_type) const;
499 GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const;
500
501 // Gets the fully resolved absolute launch URL. 463 // Gets the fully resolved absolute launch URL.
502 GURL GetFullLaunchURL() const; 464 GURL GetFullLaunchURL() const;
503 465
504 // Image cache related methods. These are only valid on the UI thread and 466 // Image cache related methods. These are only valid on the UI thread and
505 // not maintained by this class. See ImageLoadingTracker for usage. The 467 // not maintained by this class. See ImageLoadingTracker for usage. The
506 // |original_size| parameter should be the size of the image at |source| 468 // |original_size| parameter should be the size of the image at |source|
507 // before any scaling may have been done to produce the pixels in |image|. 469 // before any scaling may have been done to produce the pixels in |image|.
508 void SetCachedImage(const ExtensionResource& source, 470 void SetCachedImage(const ExtensionResource& source,
509 const SkBitmap& image, 471 const SkBitmap& image,
510 const gfx::Size& original_size) const; 472 const gfx::Size& original_size) const;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 } 627 }
666 const PermissionSet* required_permission_set() const { 628 const PermissionSet* required_permission_set() const {
667 return required_permission_set_.get(); 629 return required_permission_set_.get();
668 } 630 }
669 // Appends |new_warning[s]| to install_warnings_. 631 // Appends |new_warning[s]| to install_warnings_.
670 void AddInstallWarning(const InstallWarning& new_warning); 632 void AddInstallWarning(const InstallWarning& new_warning);
671 void AddInstallWarnings(const InstallWarningVector& new_warnings); 633 void AddInstallWarnings(const InstallWarningVector& new_warnings);
672 const InstallWarningVector& install_warnings() const { 634 const InstallWarningVector& install_warnings() const {
673 return install_warnings_; 635 return install_warnings_;
674 } 636 }
675 const ExtensionIconSet& icons() const { return icons_; }
676 const extensions::Manifest* manifest() const { 637 const extensions::Manifest* manifest() const {
677 return manifest_.get(); 638 return manifest_.get();
678 } 639 }
679 const std::string default_locale() const { return default_locale_; } 640 const std::string default_locale() const { return default_locale_; }
680 bool incognito_split_mode() const { return incognito_split_mode_; } 641 bool incognito_split_mode() const { return incognito_split_mode_; }
681 bool offline_enabled() const { return offline_enabled_; } 642 bool offline_enabled() const { return offline_enabled_; }
682 const OAuth2Info& oauth2_info() const { return oauth2_info_; } 643 const OAuth2Info& oauth2_info() const { return oauth2_info_; }
683 bool wants_file_access() const { return wants_file_access_; } 644 bool wants_file_access() const { return wants_file_access_; }
684 int creation_flags() const { return creation_flags_; } 645 int creation_flags() const { return creation_flags_; }
685 bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; } 646 bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 const char* list_error, 765 const char* list_error,
805 const char* value_error, 766 const char* value_error,
806 string16* error); 767 string16* error);
807 bool LoadLaunchContainer(string16* error); 768 bool LoadLaunchContainer(string16* error);
808 bool LoadLaunchURL(string16* error); 769 bool LoadLaunchURL(string16* error);
809 770
810 bool LoadSharedFeatures(const APIPermissionSet& api_permissions, 771 bool LoadSharedFeatures(const APIPermissionSet& api_permissions,
811 string16* error); 772 string16* error);
812 bool LoadDescription(string16* error); 773 bool LoadDescription(string16* error);
813 bool LoadManifestVersion(string16* error); 774 bool LoadManifestVersion(string16* error);
814 bool LoadIcons(string16* error);
815 bool LoadCommands(string16* error); 775 bool LoadCommands(string16* error);
816 bool LoadPlugins(string16* error); 776 bool LoadPlugins(string16* error);
817 bool LoadNaClModules(string16* error); 777 bool LoadNaClModules(string16* error);
818 bool LoadWebAccessibleResources(string16* error); 778 bool LoadWebAccessibleResources(string16* error);
819 bool LoadSandboxedPages(string16* error); 779 bool LoadSandboxedPages(string16* error);
820 // Must be called after LoadPlugins(). 780 // Must be called after LoadPlugins().
821 bool LoadRequirements(string16* error); 781 bool LoadRequirements(string16* error);
822 bool LoadDefaultLocale(string16* error); 782 bool LoadDefaultLocale(string16* error);
823 bool LoadOfflineEnabled(string16* error); 783 bool LoadOfflineEnabled(string16* error);
824 bool LoadBackgroundScripts(string16* error); 784 bool LoadBackgroundScripts(string16* error);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 920
961 // The set of permissions the extension can request at runtime. 921 // The set of permissions the extension can request at runtime.
962 scoped_refptr<const PermissionSet> optional_permission_set_; 922 scoped_refptr<const PermissionSet> optional_permission_set_;
963 923
964 // The extension's required / default set of permissions. 924 // The extension's required / default set of permissions.
965 scoped_refptr<const PermissionSet> required_permission_set_; 925 scoped_refptr<const PermissionSet> required_permission_set_;
966 926
967 // Any warnings that occurred when trying to create/parse the extension. 927 // Any warnings that occurred when trying to create/parse the extension.
968 InstallWarningVector install_warnings_; 928 InstallWarningVector install_warnings_;
969 929
970 // The icons for the extension.
971 ExtensionIconSet icons_;
972
973 // The base extension url for the extension. 930 // The base extension url for the extension.
974 GURL extension_url_; 931 GURL extension_url_;
975 932
976 // The extension's version. 933 // The extension's version.
977 scoped_ptr<Version> version_; 934 scoped_ptr<Version> version_;
978 935
979 // An optional longer description of the extension. 936 // An optional longer description of the extension.
980 std::string description_; 937 std::string description_;
981 938
982 // True if the extension was generated from a user script. (We show slightly 939 // True if the extension was generated from a user script. (We show slightly
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1133
1177 UpdatedExtensionPermissionsInfo( 1134 UpdatedExtensionPermissionsInfo(
1178 const Extension* extension, 1135 const Extension* extension,
1179 const PermissionSet* permissions, 1136 const PermissionSet* permissions,
1180 Reason reason); 1137 Reason reason);
1181 }; 1138 };
1182 1139
1183 } // namespace extensions 1140 } // namespace extensions
1184 1141
1185 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 1142 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698