OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |