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

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

Issue 1172183002: Move StartsWith[ASCII] to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util3
Patch Set: merger Created 5 years, 6 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 if (inner_json->HasKey(kAnswerJsonImage)) { 99 if (inner_json->HasKey(kAnswerJsonImage)) {
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_ = GURL( 109 image_line->image_url_ =
110 StartsWith(url_string, base::ASCIIToUTF16("//"), false) ? 110 GURL(base::StartsWith(url_string, base::ASCIIToUTF16("//"), false)
111 (base::ASCIIToUTF16(url::kHttpsScheme) + base::ASCIIToUTF16(":") + 111 ? (base::ASCIIToUTF16(url::kHttpsScheme) +
112 url_string) : 112 base::ASCIIToUTF16(":") + url_string)
113 url_string); 113 : url_string);
114 114
115 if (!image_line->image_url_.is_valid()) 115 if (!image_line->image_url_.is_valid())
116 return false; 116 return false;
117 } 117 }
118 118
119 return true; 119 return true;
120 } 120 }
121 121
122 bool SuggestionAnswer::ImageLine::Equals(const ImageLine& line) const { 122 bool SuggestionAnswer::ImageLine::Equals(const ImageLine& line) const {
123 if (text_fields_.size() != line.text_fields_.size()) 123 if (text_fields_.size() != line.text_fields_.size())
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 first_line_.Equals(answer.first_line_) && 182 first_line_.Equals(answer.first_line_) &&
183 second_line_.Equals(answer.second_line_); 183 second_line_.Equals(answer.second_line_);
184 } 184 }
185 185
186 void SuggestionAnswer::AddImageURLsTo(std::vector<GURL>* urls) const { 186 void SuggestionAnswer::AddImageURLsTo(std::vector<GURL>* urls) const {
187 if (first_line_.image_url().is_valid()) 187 if (first_line_.image_url().is_valid())
188 urls->push_back(first_line_.image_url()); 188 urls->push_back(first_line_.image_url());
189 if (second_line_.image_url().is_valid()) 189 if (second_line_.image_url().is_valid())
190 urls->push_back(second_line_.image_url()); 190 urls->push_back(second_line_.image_url());
191 } 191 }
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