summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-12 17:28:12 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-12 17:28:12 +0000
commit187f9ad7e4dd8eda57744b6100ff35990e21a4a6 (patch)
tree149548c73c9c0ac8a151f472dd626f09813d1b69 /chrome
parent0435f737a39aa8d6a0b8d567264dbfd02242c0d9 (diff)
downloadchromium_src-187f9ad7e4dd8eda57744b6100ff35990e21a4a6.zip
chromium_src-187f9ad7e4dd8eda57744b6100ff35990e21a4a6.tar.gz
chromium_src-187f9ad7e4dd8eda57744b6100ff35990e21a4a6.tar.bz2
Allows OSDD files to contain https.
BUG=2153 TEST=covered by unit tests Review URL: http://codereview.chromium.org/2454 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2119 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/template_url_parser.cc10
-rw-r--r--chrome/browser/template_url_parser.h14
-rw-r--r--chrome/browser/template_url_parser_unittest.cc4
3 files changed, 15 insertions, 13 deletions
diff --git a/chrome/browser/template_url_parser.cc b/chrome/browser/template_url_parser.cc
index f87692b..8c4f8be 100644
--- a/chrome/browser/template_url_parser.cc
+++ b/chrome/browser/template_url_parser.cc
@@ -518,16 +518,16 @@ void CharactersImpl(void *ctx, const xmlChar *ch, int len) {
}
// Returns true if the ref is null, or the url wrapped by ref is
-// valid with a spec of http.
+// valid with a spec of http/https.
bool IsHTTPRef(const TemplateURLRef* ref) {
if (ref == NULL)
return true;
GURL url(ref->url());
- return (url.is_valid() && url.SchemeIs("http"));
+ return (url.is_valid() && (url.SchemeIs("http") || url.SchemeIs("https")));
}
// Returns true if the TemplateURL is legal. A legal TemplateURL is one
-// where all URLs have a spec of http.
+// where all URLs have a spec of http/https.
bool IsLegal(TemplateURL* url) {
if (!IsHTTPRef(url->url()) || !IsHTTPRef(url->suggestions_url()))
return false;
@@ -535,8 +535,10 @@ bool IsLegal(TemplateURL* url) {
const std::vector<TemplateURL::ImageRef>& image_refs = url->image_refs();
for (size_t i = 0; i < image_refs.size(); i++) {
GURL image_url(image_refs[i].url);
- if (!image_url.is_valid() || !image_url.SchemeIs("http"))
+ if (!image_url.is_valid() ||
+ !(image_url.SchemeIs("http") || image_url.SchemeIs("https"))) {
return false;
+ }
}
return true;
}
diff --git a/chrome/browser/template_url_parser.h b/chrome/browser/template_url_parser.h
index dcdd5eb..facf7c6 100644
--- a/chrome/browser/template_url_parser.h
+++ b/chrome/browser/template_url_parser.h
@@ -19,16 +19,16 @@ class TemplateURLParser {
public:
// Invoked for each parameter of the template URL while parsing. If this
// methods returns false, the parameter is not included.
- virtual bool KeepParameter(const std::string& key,
- const std::string& value) = 0;
+ virtual bool KeepParameter(const std::string& key,
+ const std::string& value) = 0;
};
// Decodes the chunk of data representing a TemplateURL. If data does
// not describe a valid TemplateURL false is returned. Additionally, if the
- // URLs referenced do not point to valid http resources, false is returned.
- // |parameter_filter| can be used if you want to filter out some parameters
- // out of the URL. For example when importing from another browser we remove
- // any parameter identifying that browser. If set to NULL, the URL is not
- // modified.
+ // URLs referenced do not point to valid http/https resources, false is
+ // returned. |parameter_filter| can be used if you want to filter out some
+ // parameters out of the URL. For example when importing from another browser
+ // we remove any parameter identifying that browser. If set to NULL, the URL
+ // is not modified.
//
// NOTE: This does not clear all values of the supplied TemplateURL; it's
// expected callers will supply a new TemplateURL to this method.
diff --git a/chrome/browser/template_url_parser_unittest.cc b/chrome/browser/template_url_parser_unittest.cc
index f9ce496..f849e88 100644
--- a/chrome/browser/template_url_parser_unittest.cc
+++ b/chrome/browser/template_url_parser_unittest.cc
@@ -49,9 +49,9 @@ TEST_F(TemplateURLParserTest, FailOnBogusURL) {
EXPECT_FALSE(parse_result_);
}
-TEST_F(TemplateURLParserTest, FailOnHTTPS) {
+TEST_F(TemplateURLParserTest, PassOnHTTPS) {
ParseFile(L"https.xml", NULL);
- EXPECT_FALSE(parse_result_);
+ EXPECT_TRUE(parse_result_);
}
TEST_F(TemplateURLParserTest, FailOnPost) {