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.
5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_
6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_
10 #include "base/basictypes.h"
12 class SearchTermsData
;
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() {}
30 // Decodes the chunk of data representing a TemplateURL, creates the
31 // TemplateURL, and returns it. The caller owns the returned object.
32 // Returns NULL if data does not describe a valid TemplateURL, the
33 // URLs referenced do not point to valid http/https resources, or for some
34 // other reason we do not support the described TemplateURL.
35 // |parameter_filter| can be used if you want to filter some parameters out of
36 // the URL. For example, when importing from another browser, we remove any
37 // parameter identifying that browser. If set to NULL, the URL is not
39 static TemplateURL
* Parse(const SearchTermsData
& search_terms_data
,
40 bool show_in_default_list
,
43 ParameterFilter
* parameter_filter
);
46 // No one should create one of these.
49 DISALLOW_COPY_AND_ASSIGN(TemplateURLParser
);
52 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_