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

Side by Side Diff: chrome/common/extensions/manifest_handlers/mime_types_handler.h

Issue 797183005: Add a mimeHandler extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@streams-lifetime
Patch Set: rebase Created 5 years, 11 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
(Empty)
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 CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_MIME_TYPES_HANDLER_H_
6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_MIME_TYPES_HANDLER_H_
7
8 #include <set>
9 #include <string>
10 #include <vector>
11
12 #include "base/basictypes.h"
13 #include "extensions/common/extension.h"
14 #include "extensions/common/manifest_handler.h"
15
16 class MimeTypesHandler {
17 public:
18 // Returns list of extensions' ids that are allowed to use MIME type filters.
19 static std::vector<std::string> GetMIMETypeWhitelist();
20
21 static MimeTypesHandler* GetHandler(const extensions::Extension* extension);
22
23 MimeTypesHandler();
24 ~MimeTypesHandler();
25
26 // extension id
27 std::string extension_id() const { return extension_id_; }
28 void set_extension_id(const std::string& extension_id) {
29 extension_id_ = extension_id;
30 }
31
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;
36
37 // Set the URL that will be used to handle MIME type requests.
38 void set_handler_url(const std::string& handler_url) {
39 handler_url_ = handler_url;
40 }
41 // The URL that will be used to handle MIME type requests.
42 const std::string& handler_url() const { return handler_url_; }
43
44 const std::set<std::string>& mime_type_set() const { return mime_type_set_; }
45
46 private:
47 // The id for the extension this action belongs to (as defined in the
48 // extension manifest).
49 std::string extension_id_;
50
51 // A list of MIME type filters.
52 std::set<std::string> mime_type_set_;
53
54 std::string handler_url_;
55 };
56
57 class MimeTypesHandlerParser : public extensions::ManifestHandler {
58 public:
59 MimeTypesHandlerParser();
60 ~MimeTypesHandlerParser() override;
61
62 bool Parse(extensions::Extension* extension, base::string16* error) override;
63
64 private:
65 const std::vector<std::string> Keys() const override;
66 };
67
68 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_MIME_TYPES_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | chrome/common/extensions/manifest_handlers/mime_types_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698