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_
11 #include "base/basictypes.h"
15 // TemplateURLParser, as the name implies, handling reading of TemplateURLs
16 // from OpenSearch description documents.
17 class TemplateURLParser
{
19 class ParameterFilter
{
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;
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
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
,
41 ParameterFilter
* parameter_filter
,
45 // No one should create one of these.
48 DISALLOW_COPY_AND_ASSIGN(TemplateURLParser
);
51 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_