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

Side by Side Diff: components/omnibox/suggestion_answer.cc

Issue 1220653002: Fix some case-insensitive cases for StartsWith (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grt's review comments, Mac fix Created 5 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
« no previous file with comments | « components/omnibox/search_suggestion_parser.cc ('k') | components/omnibox/url_prefix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #include "components/omnibox/suggestion_answer.h" 5 #include "components/omnibox/suggestion_answer.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "net/base/escape.h" 10 #include "net/base/escape.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 base::string16 url_string; 100 base::string16 url_string;
101 if (!inner_json->GetString(kAnswerJsonImageData, &url_string) || 101 if (!inner_json->GetString(kAnswerJsonImageData, &url_string) ||
102 url_string.empty()) 102 url_string.empty())
103 return false; 103 return false;
104 // If necessary, concatenate scheme and host/path using only ':' as 104 // If necessary, concatenate scheme and host/path using only ':' as
105 // separator. This is due to the results delivering strings of the form 105 // separator. This is due to the results delivering strings of the form
106 // "//host/path", which is web-speak for "use the enclosing page's scheme", 106 // "//host/path", which is web-speak for "use the enclosing page's scheme",
107 // but not a valid path of an URL. The GWS frontend commonly (always?) 107 // but not a valid path of an URL. The GWS frontend commonly (always?)
108 // redirects to HTTPS so we just default to that here. 108 // redirects to HTTPS so we just default to that here.
109 image_line->image_url_ = 109 image_line->image_url_ =
110 GURL(base::StartsWith(url_string, base::ASCIIToUTF16("//"), false) 110 GURL(base::StartsWith(url_string, base::ASCIIToUTF16("//"),
111 base::CompareCase::SENSITIVE)
111 ? (base::ASCIIToUTF16(url::kHttpsScheme) + 112 ? (base::ASCIIToUTF16(url::kHttpsScheme) +
112 base::ASCIIToUTF16(":") + url_string) 113 base::ASCIIToUTF16(":") + url_string)
113 : url_string); 114 : url_string);
114 115
115 if (!image_line->image_url_.is_valid()) 116 if (!image_line->image_url_.is_valid())
116 return false; 117 return false;
117 } 118 }
118 119
119 return true; 120 return true;
120 } 121 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 first_line_.Equals(answer.first_line_) && 183 first_line_.Equals(answer.first_line_) &&
183 second_line_.Equals(answer.second_line_); 184 second_line_.Equals(answer.second_line_);
184 } 185 }
185 186
186 void SuggestionAnswer::AddImageURLsTo(std::vector<GURL>* urls) const { 187 void SuggestionAnswer::AddImageURLsTo(std::vector<GURL>* urls) const {
187 if (first_line_.image_url().is_valid()) 188 if (first_line_.image_url().is_valid())
188 urls->push_back(first_line_.image_url()); 189 urls->push_back(first_line_.image_url());
189 if (second_line_.image_url().is_valid()) 190 if (second_line_.image_url().is_valid())
190 urls->push_back(second_line_.image_url()); 191 urls->push_back(second_line_.image_url());
191 } 192 }
OLDNEW
« no previous file with comments | « components/omnibox/search_suggestion_parser.cc ('k') | components/omnibox/url_prefix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698