| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_COMMON_EXTENSIONS_API_ICONS_ICONS_HANDLER_H_ | |
| 6 #define CHROME_COMMON_EXTENSIONS_API_ICONS_ICONS_HANDLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "chrome/common/extensions/extension.h" | |
| 11 #include "chrome/common/extensions/extension_icon_set.h" | |
| 12 #include "chrome/common/extensions/manifest_handler.h" | |
| 13 #include "extensions/common/extension_resource.h" | |
| 14 | |
| 15 namespace extensions { | |
| 16 | |
| 17 struct IconsInfo : public Extension::ManifestData { | |
| 18 // Max size (both dimensions) for browser and page actions. | |
| 19 static const int kPageActionIconMaxSize; | |
| 20 static const int kBrowserActionIconMaxSize; | |
| 21 | |
| 22 // The icons for the extension. | |
| 23 ExtensionIconSet icons; | |
| 24 | |
| 25 // Return the icon set for the given |extension|. | |
| 26 static const ExtensionIconSet& GetIcons(const Extension* extension); | |
| 27 | |
| 28 // Given an extension, icon size, and match type, read a valid icon if present | |
| 29 // and decode it into |result|. In the browser process, this will DCHECK if | |
| 30 // not called on the file thread. To easily load extension images on the UI | |
| 31 // thread, see ImageLoader. | |
| 32 static void DecodeIcon(const Extension* extension, | |
| 33 int icon_size, | |
| 34 ExtensionIconSet::MatchType match_type, | |
| 35 scoped_ptr<SkBitmap>* result); | |
| 36 | |
| 37 // Given an extension and icon size, read it if present and decode it into | |
| 38 // |result|. In the browser process, this will DCHECK if not called on the | |
| 39 // file thread. To easily load extension images on the UI thread, see | |
| 40 // ImageLoader. | |
| 41 static void DecodeIcon(const Extension* extension, | |
| 42 int icon_size, | |
| 43 scoped_ptr<SkBitmap>* result); | |
| 44 | |
| 45 // Given an icon_path and icon size, read it if present and decode it into | |
| 46 // |result|. In the browser process, this will DCHECK if not called on the | |
| 47 // file thread. To easily load extension images on the UI thread, see | |
| 48 // ImageLoader. | |
| 49 static void DecodeIconFromPath(const base::FilePath& icon_path, | |
| 50 int icon_size, | |
| 51 scoped_ptr<SkBitmap>* result); | |
| 52 | |
| 53 // Returns the default extension/app icon (for extensions or apps that don't | |
| 54 // have one). | |
| 55 static const gfx::ImageSkia& GetDefaultExtensionIcon(); | |
| 56 static const gfx::ImageSkia& GetDefaultAppIcon(); | |
| 57 | |
| 58 // Get an extension icon as a resource or URL. | |
| 59 static ExtensionResource GetIconResource( | |
| 60 const Extension* extension, | |
| 61 int size, | |
| 62 ExtensionIconSet::MatchType match_type); | |
| 63 static GURL GetIconURL(const Extension* extension, | |
| 64 int size, | |
| 65 ExtensionIconSet::MatchType match_type); | |
| 66 }; | |
| 67 | |
| 68 // Parses the "icons" manifest key. | |
| 69 class IconsHandler : public ManifestHandler { | |
| 70 public: | |
| 71 IconsHandler(); | |
| 72 virtual ~IconsHandler(); | |
| 73 | |
| 74 virtual bool Parse(Extension* extension, string16* error) OVERRIDE; | |
| 75 virtual bool Validate(const Extension* extension, | |
| 76 std::string* error, | |
| 77 std::vector<InstallWarning>* warnings) const OVERRIDE; | |
| 78 | |
| 79 private: | |
| 80 virtual const std::vector<std::string> Keys() const OVERRIDE; | |
| 81 }; | |
| 82 | |
| 83 } // namespace extensions | |
| 84 | |
| 85 #endif // CHROME_COMMON_EXTENSIONS_API_ICONS_ICONS_HANDLER_H_ | |
| OLD | NEW |