OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/error_page/renderer/net_error_helper_core.h" | 5 #include "components/error_page/renderer/net_error_helper_core.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 28 matching lines...) Expand all Loading... | |
39 #include "url/url_constants.h" | 39 #include "url/url_constants.h" |
40 | 40 |
41 namespace error_page { | 41 namespace error_page { |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 // |NetErrorNavigationCorrectionTypes| enum id for Web search query. | 45 // |NetErrorNavigationCorrectionTypes| enum id for Web search query. |
46 // Other correction types uses the |kCorrectionResourceTable| array order. | 46 // Other correction types uses the |kCorrectionResourceTable| array order. |
47 const int kWebSearchQueryUMAId = 100; | 47 const int kWebSearchQueryUMAId = 100; |
48 | 48 |
49 // Number of URL correction suggestions to display. | |
50 const int kUrlCorrectionsToDisplay = 1; | |
mmenke
2016/02/18 19:51:19
+kMaxUrl...?
edwardjung
2016/02/19 18:18:22
Done.
| |
51 | |
49 struct CorrectionTypeToResourceTable { | 52 struct CorrectionTypeToResourceTable { |
50 int resource_id; | 53 int resource_id; |
51 const char* correction_type; | 54 const char* correction_type; |
52 }; | 55 }; |
53 | 56 |
54 // Note: Ordering should be the same as |NetErrorNavigationCorrectionTypes| enum | 57 // Note: Ordering should be the same as |NetErrorNavigationCorrectionTypes| enum |
55 // in histograms.xml. | 58 // in histograms.xml. |
56 const CorrectionTypeToResourceTable kCorrectionResourceTable[] = { | 59 const CorrectionTypeToResourceTable kCorrectionResourceTable[] = { |
57 {IDS_ERRORPAGES_SUGGESTION_VISIT_GOOGLE_CACHE, "cachedPage"}, | 60 {IDS_ERRORPAGES_SUGGESTION_VISIT_GOOGLE_CACHE, "cachedPage"}, |
58 // "reloadPage" is has special handling. | 61 // "reloadPage" is has special handling. |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 } | 332 } |
330 | 333 |
331 // Allow reload page and web search query to be empty strings, but not | 334 // Allow reload page and web search query to be empty strings, but not |
332 // links. | 335 // links. |
333 if ((*it)->url_correction.empty()) | 336 if ((*it)->url_correction.empty()) |
334 continue; | 337 continue; |
335 size_t correction_index; | 338 size_t correction_index; |
336 for (correction_index = 0; | 339 for (correction_index = 0; |
337 correction_index < arraysize(kCorrectionResourceTable); | 340 correction_index < arraysize(kCorrectionResourceTable); |
338 ++correction_index) { | 341 ++correction_index) { |
342 if (params->override_suggestions->GetSize() == kUrlCorrectionsToDisplay) { | |
mmenke
2016/02/18 19:51:19
Think this should be >=, for clarity. Also, this
edwardjung
2016/02/19 18:18:22
Thanks for spotting this.
I actually needed to u
| |
343 break; | |
344 } | |
mmenke
2016/02/18 19:51:19
Remove braces
edwardjung
2016/02/19 18:18:22
Done.
| |
339 if ((*it)->correction_type != | 345 if ((*it)->correction_type != |
340 kCorrectionResourceTable[correction_index].correction_type) { | 346 kCorrectionResourceTable[correction_index].correction_type) { |
341 continue; | 347 continue; |
342 } | 348 } |
343 base::DictionaryValue* suggest = new base::DictionaryValue(); | 349 base::DictionaryValue* suggest = new base::DictionaryValue(); |
344 suggest->SetString("header", | 350 suggest->SetString("summary", |
345 l10n_util::GetStringUTF16( | 351 l10n_util::GetStringUTF16( |
346 kCorrectionResourceTable[correction_index].resource_id)); | 352 kCorrectionResourceTable[correction_index].resource_id)); |
347 suggest->SetString("urlCorrection", (*it)->url_correction); | 353 suggest->SetString("urlCorrection", (*it)->url_correction); |
348 suggest->SetString( | 354 suggest->SetString( |
349 "urlCorrectionForDisplay", | 355 "urlCorrectionForDisplay", |
350 FormatURLForDisplay(GURL((*it)->url_correction), is_rtl, | 356 FormatURLForDisplay(GURL((*it)->url_correction), is_rtl, |
351 accept_languages)); | 357 accept_languages)); |
352 suggest->SetString("originalUrlForDisplay", original_url_for_display); | 358 suggest->SetString("originalUrlForDisplay", original_url_for_display); |
353 suggest->SetInteger("trackingId", tracking_id); | 359 suggest->SetInteger("trackingId", tracking_id); |
354 suggest->SetInteger("type", static_cast<int>(correction_index)); | 360 suggest->SetInteger("type", static_cast<int>(correction_index)); |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1076 | 1082 |
1077 OfflinePageStatus NetErrorHelperCore::GetOfflinePageStatus() const { | 1083 OfflinePageStatus NetErrorHelperCore::GetOfflinePageStatus() const { |
1078 #if defined(OS_ANDROID) | 1084 #if defined(OS_ANDROID) |
1079 return offline_page_status_; | 1085 return offline_page_status_; |
1080 #else | 1086 #else |
1081 return OfflinePageStatus::NONE; | 1087 return OfflinePageStatus::NONE; |
1082 #endif // defined(OS_ANDROID) | 1088 #endif // defined(OS_ANDROID) |
1083 } | 1089 } |
1084 | 1090 |
1085 } // namespace error_page | 1091 } // namespace error_page |
OLD | NEW |