icons_handler.h revision c5cede9ae108bb15f6b7a8aea21c7e1fefa2834c
1// Copyright 2014 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 EXTENSIONS_COMMON_MANIFEST_HANDLERS_ICONS_HANDLER_H_
6#define EXTENSIONS_COMMON_MANIFEST_HANDLERS_ICONS_HANDLER_H_
7
8#include <string>
9
10#include "extensions/common/extension.h"
11#include "extensions/common/extension_icon_set.h"
12#include "extensions/common/extension_resource.h"
13#include "extensions/common/manifest_handler.h"
14
15class GURL;
16
17namespace gfx {
18class ImageSkia;
19}
20
21namespace extensions {
22
23struct IconsInfo : public Extension::ManifestData {
24  // The icons for the extension.
25  ExtensionIconSet icons;
26
27  // Return the icon set for the given |extension|.
28  static const ExtensionIconSet& GetIcons(const Extension* extension);
29
30  // Returns the default extension/app icon (for extensions or apps that don't
31  // have one).
32  static const gfx::ImageSkia& GetDefaultExtensionIcon();
33  static const gfx::ImageSkia& GetDefaultAppIcon();
34
35  // Get an extension icon as a resource or URL.
36  static ExtensionResource GetIconResource(
37      const Extension* extension,
38      int size,
39      ExtensionIconSet::MatchType match_type);
40  static GURL GetIconURL(const Extension* extension,
41                         int size,
42                         ExtensionIconSet::MatchType match_type);
43};
44
45// Parses the "icons" manifest key.
46class IconsHandler : public ManifestHandler {
47 public:
48  IconsHandler();
49  virtual ~IconsHandler();
50
51  virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE;
52  virtual bool Validate(const Extension* extension,
53                        std::string* error,
54                        std::vector<InstallWarning>* warnings) const OVERRIDE;
55
56 private:
57  virtual const std::vector<std::string> Keys() const OVERRIDE;
58};
59
60}  // namespace extensions
61
62#endif  // EXTENSIONS_COMMON_MANIFEST_HANDLERS_ICONS_HANDLER_H_
63