Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/localized_error.h" | 5 #include "components/error_page/common/localized_error.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | |
| 15 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
| 16 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/values.h" | 21 #include "base/values.h" |
| 21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 22 #include "components/error_page/common/error_page_params.h" | 23 #include "components/error_page/common/error_page_params.h" |
| 23 #include "components/error_page/common/error_page_switches.h" | 24 #include "components/error_page/common/error_page_switches.h" |
| 24 #include "components/error_page/common/net_error_info.h" | 25 #include "components/error_page/common/net_error_info.h" |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 } | 498 } |
| 498 } | 499 } |
| 499 } | 500 } |
| 500 | 501 |
| 501 // Helper function that creates a single entry dictionary and adds it | 502 // Helper function that creates a single entry dictionary and adds it |
| 502 // to a ListValue, | 503 // to a ListValue, |
| 503 void AddSingleEntryDictionaryToList(base::ListValue* list, | 504 void AddSingleEntryDictionaryToList(base::ListValue* list, |
| 504 const char* path, | 505 const char* path, |
| 505 int message_id, | 506 int message_id, |
| 506 bool insert_as_first_item) { | 507 bool insert_as_first_item) { |
| 507 base::DictionaryValue* suggestion_list_item = new base::DictionaryValue; | 508 std::unique_ptr<base::DictionaryValue> suggestion_list_item( |
| 509 new base::DictionaryValue); | |
| 508 suggestion_list_item->SetString(path, l10n_util::GetStringUTF16(message_id)); | 510 suggestion_list_item->SetString(path, l10n_util::GetStringUTF16(message_id)); |
| 509 | 511 |
| 510 if (insert_as_first_item) { | 512 if (insert_as_first_item) { |
| 511 list->Insert(0, suggestion_list_item); | 513 list->Insert(0, suggestion_list_item.release()); |
|
blundell
2016/08/29 07:39:15
I assume that this is targeted for followup?
dcheng
2016/08/30 17:41:55
Yes, there's no equivalent for Insert() atm.
| |
| 512 } else { | 514 } else { |
| 513 list->Append(suggestion_list_item); | 515 list->Append(std::move(suggestion_list_item)); |
| 514 } | 516 } |
| 515 } | 517 } |
| 516 | 518 |
| 517 // Adds a linked suggestion dictionary entry to the suggestions list. | 519 // Adds a linked suggestion dictionary entry to the suggestions list. |
| 518 void AddLinkedSuggestionToList(const int error_code, | 520 void AddLinkedSuggestionToList(const int error_code, |
| 519 const std::string& locale, | 521 const std::string& locale, |
| 520 base::ListValue* suggestions_summary_list, | 522 base::ListValue* suggestions_summary_list, |
| 521 bool standalone_suggestion) { | 523 bool standalone_suggestion) { |
| 522 GURL learn_more_url; | 524 GURL learn_more_url; |
| 523 base::string16 suggestion_string = standalone_suggestion ? | 525 base::string16 suggestion_string = standalone_suggestion ? |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 } | 723 } |
| 722 | 724 |
| 723 if (header_message_id) { | 725 if (header_message_id) { |
| 724 suggestion_list_item->SetString("header", | 726 suggestion_list_item->SetString("header", |
| 725 l10n_util::GetStringUTF16(header_message_id)); | 727 l10n_util::GetStringUTF16(header_message_id)); |
| 726 } | 728 } |
| 727 if (body_message_id) { | 729 if (body_message_id) { |
| 728 suggestion_list_item->SetString("body", | 730 suggestion_list_item->SetString("body", |
| 729 l10n_util::GetStringUTF16(body_message_id)); | 731 l10n_util::GetStringUTF16(body_message_id)); |
| 730 } | 732 } |
| 731 list->Append(suggestion_list_item); | 733 list->Append(base::WrapUnique(suggestion_list_item)); |
| 732 return suggestion_list_item; | 734 return suggestion_list_item; |
| 733 } | 735 } |
| 734 | 736 |
| 735 // Certain suggestions have supporting details which get displayed under | 737 // Certain suggestions have supporting details which get displayed under |
| 736 // the "Details" button. | 738 // the "Details" button. |
| 737 void AddSuggestionsDetails(int error_code, | 739 void AddSuggestionsDetails(int error_code, |
| 738 base::DictionaryValue* error_strings, | 740 base::DictionaryValue* error_strings, |
| 739 int suggestions, | 741 int suggestions, |
| 740 base::ListValue* suggestions_details) { | 742 base::ListValue* suggestions_details) { |
| 741 if (suggestions & SUGGEST_CHECK_CONNECTION) { | 743 if (suggestions & SUGGEST_CHECK_CONNECTION) { |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 | 1018 |
| 1017 bool LocalizedError::HasStrings(const std::string& error_domain, | 1019 bool LocalizedError::HasStrings(const std::string& error_domain, |
| 1018 int error_code) { | 1020 int error_code) { |
| 1019 // Whether or not the there are strings for an error does not depend on | 1021 // Whether or not the there are strings for an error does not depend on |
| 1020 // whether or not the page was be generated by a POST, so just claim it was | 1022 // whether or not the page was be generated by a POST, so just claim it was |
| 1021 // not. | 1023 // not. |
| 1022 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != nullptr; | 1024 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != nullptr; |
| 1023 } | 1025 } |
| 1024 | 1026 |
| 1025 } // namespace error_page | 1027 } // namespace error_page |
| OLD | NEW |