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

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: Created 7 years, 9 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/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/hash_tables.h" 17 #include "base/hash_tables.h"
18 #include "base/memory/linked_ptr.h" 18 #include "base/memory/linked_ptr.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
22 #include "base/threading/thread_checker.h" 22 #include "base/threading/thread_checker.h"
23 #include "chrome/common/extensions/extension_constants.h" 23 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/common/extensions/extension_icon_set.h" 24 #include "chrome/common/extensions/extension_icon_set.h"
25 #include "chrome/common/extensions/extension_resource.h"
25 #include "chrome/common/extensions/manifest.h" 26 #include "chrome/common/extensions/manifest.h"
26 #include "chrome/common/extensions/permissions/api_permission.h" 27 #include "chrome/common/extensions/permissions/api_permission.h"
27 #include "chrome/common/extensions/permissions/permission_message.h" 28 #include "chrome/common/extensions/permissions/permission_message.h"
28 #include "chrome/common/extensions/user_script.h" 29 #include "chrome/common/extensions/user_script.h"
29 #include "extensions/common/install_warning.h" 30 #include "extensions/common/install_warning.h"
30 #include "extensions/common/url_pattern.h" 31 #include "extensions/common/url_pattern.h"
31 #include "extensions/common/url_pattern_set.h" 32 #include "extensions/common/url_pattern_set.h"
32 #include "googleurl/src/gurl.h" 33 #include "googleurl/src/gurl.h"
33 #include "ui/base/accelerators/accelerator.h" 34 #include "ui/base/accelerators/accelerator.h"
34 #include "ui/gfx/size.h" 35 #include "ui/gfx/size.h"
35 36
36 class ExtensionAction; 37 class ExtensionAction;
37 class ExtensionResource;
38 class SkBitmap; 38 class SkBitmap;
39 class Version; 39 class Version;
40 40
41 namespace base { 41 namespace base {
42 class DictionaryValue; 42 class DictionaryValue;
43 class ListValue; 43 class ListValue;
44 } 44 }
45 45
46 namespace gfx { 46 namespace gfx {
47 class ImageSkia; 47 class ImageSkia;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 // In a few special circumstances, we want to create an Extension and give it 188 // In a few special circumstances, we want to create an Extension and give it
189 // an explicit id. Most consumers should just use the other Create() method. 189 // an explicit id. Most consumers should just use the other Create() method.
190 static scoped_refptr<Extension> Create(const base::FilePath& path, 190 static scoped_refptr<Extension> Create(const base::FilePath& path,
191 Manifest::Location location, 191 Manifest::Location location,
192 const base::DictionaryValue& value, 192 const base::DictionaryValue& value,
193 int flags, 193 int flags,
194 const std::string& explicit_id, 194 const std::string& explicit_id,
195 std::string* error); 195 std::string* error);
196 196
197 // Max size (both dimensions) for browser and page actions.
198 static const int kPageActionIconMaxSize;
199 static const int kBrowserActionIconMaxSize;
200
201 // Valid schemes for web extent URLPatterns. 197 // Valid schemes for web extent URLPatterns.
202 static const int kValidWebExtentSchemes; 198 static const int kValidWebExtentSchemes;
203 199
204 // Valid schemes for host permission URLPatterns. 200 // Valid schemes for host permission URLPatterns.
205 static const int kValidHostPermissionSchemes; 201 static const int kValidHostPermissionSchemes;
206 202
207 // The name of the manifest inside an extension. 203 // The name of the manifest inside an extension.
208 static const base::FilePath::CharType kManifestFilename[]; 204 static const base::FilePath::CharType kManifestFilename[];
209 205
210 // The name of locale folder inside an extension. 206 // The name of locale folder inside an extension.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // always generate the same output ID. 280 // always generate the same output ID.
285 static bool GenerateId(const std::string& input, 281 static bool GenerateId(const std::string& input,
286 std::string* output) WARN_UNUSED_RESULT; 282 std::string* output) WARN_UNUSED_RESULT;
287 283
288 // Expects base64 encoded |input| and formats into |output| including 284 // Expects base64 encoded |input| and formats into |output| including
289 // the appropriate header & footer. 285 // the appropriate header & footer.
290 static bool FormatPEMForFileOutput(const std::string& input, 286 static bool FormatPEMForFileOutput(const std::string& input,
291 std::string* output, 287 std::string* output,
292 bool is_public); 288 bool is_public);
293 289
294 // Given an extension, icon size, and match type, read a valid icon if present
295 // and decode it into result. In the browser process, this will DCHECK if not
296 // called on the file thread. To easily load extension images on the UI
297 // thread, see ImageLoader.
298 static void DecodeIcon(const Extension* extension,
299 int icon_size,
300 ExtensionIconSet::MatchType match_type,
301 scoped_ptr<SkBitmap>* result);
302
303 // Given an extension and icon size, read it if present and decode it into
304 // result. In the browser process, this will DCHECK if not called on the
305 // file thread. To easily load extension images on the UI thread, see
306 // ImageLoader.
307 static void DecodeIcon(const Extension* extension,
308 int icon_size,
309 scoped_ptr<SkBitmap>* result);
310
311 // Given an icon_path and icon size, read it if present and decode it into
312 // result. In the browser process, this will DCHECK if not called on the
313 // file thread. To easily load extension images on the UI thread, see
314 // ImageLoader.
315 static void DecodeIconFromPath(const base::FilePath& icon_path,
316 int icon_size,
317 scoped_ptr<SkBitmap>* result);
318
319 // Returns the default extension/app icon (for extensions or apps that don't
320 // have one).
321 static const gfx::ImageSkia& GetDefaultIcon(bool is_app);
322
323 // Returns the base extension url for a given |extension_id|. 290 // Returns the base extension url for a given |extension_id|.
324 static GURL GetBaseURLFromExtensionId(const std::string& extension_id); 291 static GURL GetBaseURLFromExtensionId(const std::string& extension_id);
325 292
326 // Adds an extension to the scripting whitelist. Used for testing only. 293 // Adds an extension to the scripting whitelist. Used for testing only.
327 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist); 294 static void SetScriptingWhitelist(const ScriptingWhitelist& whitelist);
328 static const ScriptingWhitelist* GetScriptingWhitelist(); 295 static const ScriptingWhitelist* GetScriptingWhitelist();
329 296
330 // Parses the host and api permissions from the specified permission |key| 297 // Parses the host and api permissions from the specified permission |key|
331 // from |manifest_|. 298 // from |manifest_|.
332 bool ParsePermissions(const char* key, 299 bool ParsePermissions(const char* key,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // Gets the extension's active permission set. 354 // Gets the extension's active permission set.
388 scoped_refptr<const PermissionSet> GetActivePermissions() const; 355 scoped_refptr<const PermissionSet> GetActivePermissions() const;
389 356
390 // Whether context menu should be shown for page and browser actions. 357 // Whether context menu should be shown for page and browser actions.
391 bool ShowConfigureContextMenus() const; 358 bool ShowConfigureContextMenus() const;
392 359
393 // Returns a list of paths (relative to the extension dir) for images that 360 // Returns a list of paths (relative to the extension dir) for images that
394 // the browser might load (like themes and page action icons). 361 // the browser might load (like themes and page action icons).
395 std::set<base::FilePath> GetBrowserImages() const; 362 std::set<base::FilePath> GetBrowserImages() const;
396 363
397 // Get an extension icon as a resource or URL.
398 ExtensionResource GetIconResource(
399 int size, ExtensionIconSet::MatchType match_type) const;
400 GURL GetIconURL(int size, ExtensionIconSet::MatchType match_type) const;
401
402 // Gets the fully resolved absolute launch URL. 364 // Gets the fully resolved absolute launch URL.
403 GURL GetFullLaunchURL() const; 365 GURL GetFullLaunchURL() const;
404 366
405 // Returns true if this extension can execute script on a page. If a 367 // 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 368 // UserScript object is passed, permission to run that specific script is
407 // checked (using its matches list). Otherwise, permission to execute script 369 // checked (using its matches list). Otherwise, permission to execute script
408 // programmatically is checked (using the extension's host permission). 370 // programmatically is checked (using the extension's host permission).
409 // 371 //
410 // This method is also aware of certain special pages that extensions are 372 // This method is also aware of certain special pages that extensions are
411 // usually not allowed to run script on. 373 // usually not allowed to run script on.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // (NULL after initialization is completed.) 495 // (NULL after initialization is completed.)
534 APIPermissionSet* initial_api_permissions() { 496 APIPermissionSet* initial_api_permissions() {
535 return initial_api_permissions_.get(); 497 return initial_api_permissions_.get();
536 } 498 }
537 // Appends |new_warning[s]| to install_warnings_. 499 // Appends |new_warning[s]| to install_warnings_.
538 void AddInstallWarning(const InstallWarning& new_warning); 500 void AddInstallWarning(const InstallWarning& new_warning);
539 void AddInstallWarnings(const std::vector<InstallWarning>& new_warnings); 501 void AddInstallWarnings(const std::vector<InstallWarning>& new_warnings);
540 const std::vector<InstallWarning>& install_warnings() const { 502 const std::vector<InstallWarning>& install_warnings() const {
541 return install_warnings_; 503 return install_warnings_;
542 } 504 }
543 const ExtensionIconSet& icons() const { return icons_; }
544 const extensions::Manifest* manifest() const { 505 const extensions::Manifest* manifest() const {
545 return manifest_.get(); 506 return manifest_.get();
546 } 507 }
547 bool incognito_split_mode() const { return incognito_split_mode_; } 508 bool incognito_split_mode() const { return incognito_split_mode_; }
548 bool offline_enabled() const { return offline_enabled_; } 509 bool offline_enabled() const { return offline_enabled_; }
549 bool wants_file_access() const { return wants_file_access_; } 510 bool wants_file_access() const { return wants_file_access_; }
550 int creation_flags() const { return creation_flags_; } 511 int creation_flags() const { return creation_flags_; }
551 bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; } 512 bool from_webstore() const { return (creation_flags_ & FROM_WEBSTORE) != 0; }
552 bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; } 513 bool from_bookmark() const { return (creation_flags_ & FROM_BOOKMARK) != 0; }
553 bool was_installed_by_default() const { 514 bool was_installed_by_default() const {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 URLPatternSet* extent, 614 URLPatternSet* extent,
654 const char* list_error, 615 const char* list_error,
655 const char* value_error, 616 const char* value_error,
656 string16* error); 617 string16* error);
657 bool LoadLaunchContainer(string16* error); 618 bool LoadLaunchContainer(string16* error);
658 bool LoadLaunchURL(string16* error); 619 bool LoadLaunchURL(string16* error);
659 620
660 bool LoadSharedFeatures(string16* error); 621 bool LoadSharedFeatures(string16* error);
661 bool LoadDescription(string16* error); 622 bool LoadDescription(string16* error);
662 bool LoadManifestVersion(string16* error); 623 bool LoadManifestVersion(string16* error);
663 bool LoadIcons(string16* error);
664 bool LoadPlugins(string16* error); 624 bool LoadPlugins(string16* error);
665 bool LoadNaClModules(string16* error); 625 bool LoadNaClModules(string16* error);
666 bool LoadSandboxedPages(string16* error); 626 bool LoadSandboxedPages(string16* error);
667 // Must be called after LoadPlugins(). 627 // Must be called after LoadPlugins().
668 bool LoadRequirements(string16* error); 628 bool LoadRequirements(string16* error);
669 bool LoadOfflineEnabled(string16* error); 629 bool LoadOfflineEnabled(string16* error);
670 bool LoadBackgroundScripts(string16* error); 630 bool LoadBackgroundScripts(string16* error);
671 bool LoadBackgroundScripts(const std::string& key, string16* error); 631 bool LoadBackgroundScripts(const std::string& key, string16* error);
672 bool LoadBackgroundPage(string16* error); 632 bool LoadBackgroundPage(string16* error);
673 bool LoadBackgroundPage(const std::string& key, 633 bool LoadBackgroundPage(const std::string& key,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 733
774 // The set of permissions the extension can request at runtime. 734 // The set of permissions the extension can request at runtime.
775 scoped_refptr<const PermissionSet> optional_permission_set_; 735 scoped_refptr<const PermissionSet> optional_permission_set_;
776 736
777 // The extension's required / default set of permissions. 737 // The extension's required / default set of permissions.
778 scoped_refptr<const PermissionSet> required_permission_set_; 738 scoped_refptr<const PermissionSet> required_permission_set_;
779 739
780 // Any warnings that occurred when trying to create/parse the extension. 740 // Any warnings that occurred when trying to create/parse the extension.
781 std::vector<InstallWarning> install_warnings_; 741 std::vector<InstallWarning> install_warnings_;
782 742
783 // The icons for the extension.
784 ExtensionIconSet icons_;
785
786 // The base extension url for the extension. 743 // The base extension url for the extension.
787 GURL extension_url_; 744 GURL extension_url_;
788 745
789 // The extension's version. 746 // The extension's version.
790 scoped_ptr<Version> version_; 747 scoped_ptr<Version> version_;
791 748
792 // An optional longer description of the extension. 749 // An optional longer description of the extension.
793 std::string description_; 750 std::string description_;
794 751
795 // True if the extension was generated from a user script. (We show slightly 752 // True if the extension was generated from a user script. (We show slightly
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 905
949 UpdatedExtensionPermissionsInfo( 906 UpdatedExtensionPermissionsInfo(
950 const Extension* extension, 907 const Extension* extension,
951 const PermissionSet* permissions, 908 const PermissionSet* permissions,
952 Reason reason); 909 Reason reason);
953 }; 910 };
954 911
955 } // namespace extensions 912 } // namespace extensions
956 913
957 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_ 914 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698