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

Unified Diff: chrome/common/extensions/mime_types_handler.h

Issue 12381035: Move Mime type handling to streamsPrivate API, so that it works on Desktop Chrome. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Initialize test variable Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/mime_types_handler.h
diff --git a/chrome/common/extensions/mime_types_handler.h b/chrome/common/extensions/mime_types_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..ed1c6308ebc7558fa49505c5f3a813bdf1369eee
--- /dev/null
+++ b/chrome/common/extensions/mime_types_handler.h
@@ -0,0 +1,74 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_EXTENSIONS_MIME_TYPES_HANDLER_H_
+#define CHROME_COMMON_EXTENSIONS_MIME_TYPES_HANDLER_H_
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/manifest_handler.h"
+#include "extensions/common/url_pattern.h"
+#include "extensions/common/url_pattern_set.h"
+#include "googleurl/src/gurl.h"
+
+class URLPattern;
+
+class MimeTypesHandler {
+ public:
+ // Returns list of extensions' ids that are allowed to use MIME type filters.
+ static std::vector<std::string> GetMIMETypeWhitelist();
+
+ static MimeTypesHandler* GetHandler(const extensions::Extension* extension);
+
+ // Whitelists the extension to use MIME type filters for a test.
+ // |extension_id| should be owned by the test code.
+ static void set_extension_whitelisted_for_test(std::string* extension_id) {
+ g_test_extension_id_ = extension_id;
+ }
+
+ MimeTypesHandler();
+ ~MimeTypesHandler();
+
+ // extension id
+ std::string extension_id() const { return extension_id_; }
+ void set_extension_id(const std::string& extension_id) {
+ extension_id_ = extension_id;
+ }
+
+ // Adds a MIME type filter to the handler.
+ void AddMIMEType(const std::string& mime_type);
+ // Tests if the handler has registered a filter for the MIME type.
+ bool CanHandleMIMEType(const std::string& mime_type) const;
+
+ private:
+ // The id of the extension that will be whitelisted to use MIME type filters
+ // during tests.
+ static std::string* g_test_extension_id_;
+
+ // The id for the extension this action belongs to (as defined in the
+ // extension manifest).
+ std::string extension_id_;
+
+ // A list of MIME type filters.
+ std::set<std::string> mime_type_set_;
+};
+
+class MimeTypesHandlerParser : public extensions::ManifestHandler {
+ public:
+ MimeTypesHandlerParser();
+ virtual ~MimeTypesHandlerParser();
+
+ virtual bool Parse(extensions::Extension* extension,
+ string16* error) OVERRIDE;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+};
+
+#endif // CHROME_COMMON_EXTENSIONS_MIME_TYPES_HANDLER_H_
+
« no previous file with comments | « chrome/common/extensions/extension_manifest_constants.cc ('k') | chrome/common/extensions/mime_types_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698