| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2008 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_TEMPLATE_URL_PARSER_H__ | |
| 6 #define CHROME_BROWSER_TEMPLATE_URL_PARSER_H__ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 | |
| 12 class TemplateURL; | |
| 13 | |
| 14 // TemplateURLParser, as the name implies, handling reading of TemplateURLs | |
| 15 // from OpenSearch description documents. | |
| 16 class TemplateURLParser { | |
| 17 public: | |
| 18 class ParameterFilter { | |
| 19 public: | |
| 20 // Invoked for each parameter of the template URL while parsing. If this | |
| 21 // methods returns false, the parameter is not included. | |
| 22 virtual bool KeepParameter(const std::string& key, | |
| 23 const std::string& value) = 0; | |
| 24 }; | |
| 25 // Decodes the chunk of data representing a TemplateURL. If data does | |
| 26 // not describe a valid TemplateURL false is returned. Additionally, if the | |
| 27 // URLs referenced do not point to valid http/https resources, false is | |
| 28 // returned. |parameter_filter| can be used if you want to filter out some | |
| 29 // parameters out of the URL. For example when importing from another browser | |
| 30 // we remove any parameter identifying that browser. If set to NULL, the URL | |
| 31 // is not modified. | |
| 32 // | |
| 33 // NOTE: This does not clear all values of the supplied TemplateURL; it's | |
| 34 // expected callers will supply a new TemplateURL to this method. | |
| 35 static bool Parse(const unsigned char* data, | |
| 36 size_t length, | |
| 37 ParameterFilter* parameter_filter, | |
| 38 TemplateURL* url); | |
| 39 | |
| 40 private: | |
| 41 // No one should create one of these. | |
| 42 TemplateURLParser(); | |
| 43 | |
| 44 DISALLOW_EVIL_CONSTRUCTORS(TemplateURLParser); | |
| 45 }; | |
| 46 | |
| 47 #endif // CHROME_BROWSER_TEMPLATE_URL_PARSER_H__ | |
| 48 | |
| OLD | NEW |