1 // Copyright 2013 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_API_URL_HANDLERS_URL_HANDLERS_PARSER_H_
6 #define CHROME_COMMON_EXTENSIONS_API_URL_HANDLERS_URL_HANDLERS_PARSER_H_
11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/manifest_handler.h"
13 #include "extensions/common/url_pattern.h"
17 namespace extensions {
19 struct UrlHandlerInfo {
23 // ID identifying this handler in the manifest.
25 // Handler title to display in all relevant UI.
27 // URL patterns associated with this handler.
28 URLPatternSet patterns;
31 struct UrlHandlers : public Extension::ManifestData {
33 virtual ~UrlHandlers();
35 // Returns an array of URL handlers |extension| has defined in its manifest.
36 static const std::vector<UrlHandlerInfo>* GetUrlHandlers(
37 const Extension* extension);
39 // Determines whether |extension| has at least one URL handler that matches
41 static bool CanExtensionHandleUrl(
42 const Extension* extension,
45 // Finds a matching URL handler for |extension|, if any. Returns NULL in none
47 static const UrlHandlerInfo* FindMatchingUrlHandler(
48 const Extension* extension,
51 std::vector<UrlHandlerInfo> handlers;
54 // Parses the "url_handlers" manifest key.
55 class UrlHandlersParser : public ManifestHandler {
58 virtual ~UrlHandlersParser();
60 // ManifestHandler API
61 virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
64 virtual const std::vector<std::string> Keys() const OVERRIDE;
66 DISALLOW_COPY_AND_ASSIGN(UrlHandlersParser);
69 } // namespace extensions
71 #endif // CHROME_COMMON_EXTENSIONS_API_URL_HANDLERS_URL_HANDLERS_PARSER_H_