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

Side by Side Diff: chrome/browser/search_engines/template_url_parser.h

Issue 367413003: No chrome dependencies in TemplateURLFetcher and TemplateURLParser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_ 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 11
12 class Profile; 12 class SearchTermsData;
13 class TemplateURL; 13 class TemplateURL;
14 14
15 // TemplateURLParser, as the name implies, handling reading of TemplateURLs 15 // TemplateURLParser, as the name implies, handling reading of TemplateURLs
16 // from OpenSearch description documents. 16 // from OpenSearch description documents.
17 class TemplateURLParser { 17 class TemplateURLParser {
18 public: 18 public:
19 class ParameterFilter { 19 class ParameterFilter {
20 public: 20 public:
21 // Invoked for each parameter of the template URL while parsing. If this 21 // Invoked for each parameter of the template URL while parsing. If this
22 // methods returns false, the parameter is not included. 22 // methods returns false, the parameter is not included.
23 virtual bool KeepParameter(const std::string& key, 23 virtual bool KeepParameter(const std::string& key,
24 const std::string& value) = 0; 24 const std::string& value) = 0;
25 25
26 protected: 26 protected:
27 virtual ~ParameterFilter() {} 27 virtual ~ParameterFilter() {}
28 }; 28 };
29 29
30 // Decodes the chunk of data representing a TemplateURL, creates the 30 // Decodes the chunk of data representing a TemplateURL, creates the
31 // TemplateURL, and returns it. The caller owns the returned object. 31 // TemplateURL, and returns it. The caller owns the returned object.
32 // |profile| should only be non-NULL if this function is called on the UI 32 // Returns NULL if data does not describe a valid TemplateURL, the
33 // thread. Returns NULL if data does not describe a valid TemplateURL, the
34 // URLs referenced do not point to valid http/https resources, or for some 33 // URLs referenced do not point to valid http/https resources, or for some
35 // other reason we do not support the described TemplateURL. 34 // other reason we do not support the described TemplateURL.
36 // |parameter_filter| can be used if you want to filter some parameters out of 35 // |parameter_filter| can be used if you want to filter some parameters out of
37 // the URL. For example, when importing from another browser, we remove any 36 // the URL. For example, when importing from another browser, we remove any
38 // parameter identifying that browser. If set to NULL, the URL is not 37 // parameter identifying that browser. If set to NULL, the URL is not
39 // modified. 38 // modified.
40 static TemplateURL* Parse(Profile* profile, 39 static TemplateURL* Parse(const SearchTermsData& search_terms_data,
41 bool show_in_default_list, 40 bool show_in_default_list,
42 const char* data, 41 const char* data,
43 size_t length, 42 size_t length,
44 ParameterFilter* parameter_filter); 43 ParameterFilter* parameter_filter);
45 44
46 private: 45 private:
47 // No one should create one of these. 46 // No one should create one of these.
48 TemplateURLParser(); 47 TemplateURLParser();
49 48
50 DISALLOW_COPY_AND_ASSIGN(TemplateURLParser); 49 DISALLOW_COPY_AND_ASSIGN(TemplateURLParser);
51 }; 50 };
52 51
53 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_ 52 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PARSER_H_
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_fetcher_unittest.cc ('k') | chrome/browser/search_engines/template_url_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698