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 extensions { 18 19struct IconsInfo : public Extension::ManifestData { 20 // The icons for the extension. 21 ExtensionIconSet icons; 22 23 // Return the icon set for the given |extension|. 24 static const ExtensionIconSet& GetIcons(const Extension* extension); 25 26 // Get an extension icon as a resource or URL. 27 static ExtensionResource GetIconResource( 28 const Extension* extension, 29 int size, 30 ExtensionIconSet::MatchType match_type); 31 static GURL GetIconURL(const Extension* extension, 32 int size, 33 ExtensionIconSet::MatchType match_type); 34}; 35 36// Parses the "icons" manifest key. 37class IconsHandler : public ManifestHandler { 38 public: 39 IconsHandler(); 40 virtual ~IconsHandler(); 41 42 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE; 43 virtual bool Validate(const Extension* extension, 44 std::string* error, 45 std::vector<InstallWarning>* warnings) const OVERRIDE; 46 47 private: 48 virtual const std::vector<std::string> Keys() const OVERRIDE; 49}; 50 51} // namespace extensions 52 53#endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_ICONS_HANDLER_H_ 54