Print Preview: Changing displayed error message when PDF Viewer is missing.
[chromium-blink-merge.git] / chrome / browser / search_engines / template_url_parser.h
blobd978da530ff588685f54cc1431096c2475d899bc
1 // Copyright (c) 2010 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_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_
7 #pragma once
9 #include <string>
11 #include "base/basictypes.h"
13 class TemplateURL;
15 // TemplateURLParser, as the name implies, handling reading of TemplateURLs
16 // from OpenSearch description documents.
17 class TemplateURLParser {
18 public:
19 class ParameterFilter {
20 public:
21 // Invoked for each parameter of the template URL while parsing. If this
22 // methods returns false, the parameter is not included.
23 virtual bool KeepParameter(const std::string& key,
24 const std::string& value) = 0;
26 protected:
27 virtual ~ParameterFilter() {}
29 // Decodes the chunk of data representing a TemplateURL. If data does
30 // not describe a valid TemplateURL false is returned. Additionally, if the
31 // URLs referenced do not point to valid http/https resources, false is
32 // returned. |parameter_filter| can be used if you want to filter out some
33 // parameters out of the URL. For example when importing from another browser
34 // we remove any parameter identifying that browser. If set to NULL, the URL
35 // is not modified.
37 // NOTE: This does not clear all values of the supplied TemplateURL; it's
38 // expected callers will supply a new TemplateURL to this method.
39 static bool Parse(const unsigned char* data,
40 size_t length,
41 ParameterFilter* parameter_filter,
42 TemplateURL* url);
44 private:
45 // No one should create one of these.
46 TemplateURLParser();
48 DISALLOW_COPY_AND_ASSIGN(TemplateURLParser);
51 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_