1 // Copyright (c) 2012 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.
5 #ifndef CHROME_COMMON_EXTENSIONS_MIME_TYPES_HANDLER_H_
6 #define CHROME_COMMON_EXTENSIONS_MIME_TYPES_HANDLER_H_
12 #include "base/basictypes.h"
13 #include "extensions/common/extension.h"
14 #include "extensions/common/manifest_handler.h"
16 class MimeTypesHandler {
18 // Returns list of extensions' ids that are allowed to use MIME type filters.
19 static std::vector<std::string> GetMIMETypeWhitelist();
21 static MimeTypesHandler* GetHandler(const extensions::Extension* extension);
27 std::string extension_id() const { return extension_id_; }
28 void set_extension_id(const std::string& extension_id) {
29 extension_id_ = extension_id;
32 // Adds a MIME type filter to the handler.
33 void AddMIMEType(const std::string& mime_type);
34 // Tests if the handler has registered a filter for the MIME type.
35 bool CanHandleMIMEType(const std::string& mime_type) const;
38 // The id for the extension this action belongs to (as defined in the
39 // extension manifest).
40 std::string extension_id_;
42 // A list of MIME type filters.
43 std::set<std::string> mime_type_set_;
46 class MimeTypesHandlerParser : public extensions::ManifestHandler {
48 MimeTypesHandlerParser();
49 virtual ~MimeTypesHandlerParser();
51 virtual bool Parse(extensions::Extension* extension,
52 base::string16* error) OVERRIDE;
55 virtual const std::vector<std::string> Keys() const OVERRIDE;
58 #endif // CHROME_COMMON_EXTENSIONS_MIME_TYPES_HANDLER_H_