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 "chrome/common/localized_error.h" | 5 #include "chrome/common/localized_error.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | |
| 10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/grit/chromium_strings.h" | 17 #include "chrome/grit/chromium_strings.h" |
| 17 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 18 #include "components/error_page/common/error_page_params.h" | 19 #include "components/error_page/common/error_page_params.h" |
| 19 #include "components/error_page/common/net_error_info.h" | 20 #include "components/error_page/common/net_error_info.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 49 static const char kRedirectLoopLearnMoreUrl[] = | 50 static const char kRedirectLoopLearnMoreUrl[] = |
| 50 "https://www.google.com/support/chrome/bin/answer.py?answer=95626"; | 51 "https://www.google.com/support/chrome/bin/answer.py?answer=95626"; |
| 51 static const char kWeakDHKeyLearnMoreUrl[] = | 52 static const char kWeakDHKeyLearnMoreUrl[] = |
| 52 "http://sites.google.com/a/chromium.org/dev/" | 53 "http://sites.google.com/a/chromium.org/dev/" |
| 53 "err_ssl_weak_server_ephemeral_dh_key"; | 54 "err_ssl_weak_server_ephemeral_dh_key"; |
| 54 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
| 55 static const char kAppWarningLearnMoreUrl[] = | 56 static const char kAppWarningLearnMoreUrl[] = |
| 56 "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html" | 57 "chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html" |
| 57 "?answer=1721911"; | 58 "?answer=1721911"; |
| 58 #endif // defined(OS_CHROMEOS) | 59 #endif // defined(OS_CHROMEOS) |
| 60 static const char kCachedCopyButtonFieldTrial[] = | |
| 61 "enable_google_cached_copy_text_experiment"; | |
| 62 static const char kCachedCopyButtonExpTypeControl[] = "control"; | |
| 63 static const char kCachedCopyButtonExpTypeCopy[] = "copy"; | |
| 64 static const char kCachedCopyButtonExpTypePage[] = "page"; | |
| 59 | 65 |
| 60 enum NAV_SUGGESTIONS { | 66 enum NAV_SUGGESTIONS { |
| 61 SUGGEST_NONE = 0, | 67 SUGGEST_NONE = 0, |
| 62 SUGGEST_RELOAD = 1 << 0, | 68 SUGGEST_RELOAD = 1 << 0, |
| 63 SUGGEST_CHECK_CONNECTION = 1 << 1, | 69 SUGGEST_CHECK_CONNECTION = 1 << 1, |
| 64 SUGGEST_DNS_CONFIG = 1 << 2, | 70 SUGGEST_DNS_CONFIG = 1 << 2, |
| 65 SUGGEST_FIREWALL_CONFIG = 1 << 3, | 71 SUGGEST_FIREWALL_CONFIG = 1 << 3, |
| 66 SUGGEST_PROXY_CONFIG = 1 << 4, | 72 SUGGEST_PROXY_CONFIG = 1 << 4, |
| 67 SUGGEST_DISABLE_EXTENSION = 1 << 5, | 73 SUGGEST_DISABLE_EXTENSION = 1 << 5, |
| 68 SUGGEST_LEARNMORE = 1 << 6, | 74 SUGGEST_LEARNMORE = 1 << 6, |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 662 if (!params) { | 668 if (!params) { |
| 663 params.reset(new error_page::ErrorPageParams()); | 669 params.reset(new error_page::ErrorPageParams()); |
| 664 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); | 670 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); |
| 665 } | 671 } |
| 666 | 672 |
| 667 base::ListValue* suggestions = NULL; | 673 base::ListValue* suggestions = NULL; |
| 668 bool use_default_suggestions = true; | 674 bool use_default_suggestions = true; |
| 669 if (!params->override_suggestions) { | 675 if (!params->override_suggestions) { |
| 670 suggestions = new base::ListValue(); | 676 suggestions = new base::ListValue(); |
| 671 } else { | 677 } else { |
| 672 suggestions = params->override_suggestions.release(); | 678 suggestions = params->override_suggestions.release(); |
|
sky
2015/05/13 15:52:03
How about moving this block to it's own function?
edwardjung
2015/05/13 17:34:34
Done.
| |
| 673 use_default_suggestions = false; | 679 use_default_suggestions = false; |
| 680 | |
| 681 std::string fieldTrialExpType = | |
|
sky
2015/05/13 15:52:03
field_trial_exp_type.
edwardjung
2015/05/13 17:34:34
Done.
| |
| 682 base::FieldTrialList::FindFullName(kCachedCopyButtonFieldTrial); | |
| 683 | |
| 684 // If the first suggestion is for a Google cache copy. Promote the | |
| 685 // suggestion to a separate set of strings for displaying as a button. | |
| 686 if (!suggestions->empty() && !fieldTrialExpType.empty() && | |
| 687 fieldTrialExpType != kCachedCopyButtonExpTypeControl) { | |
| 688 base::DictionaryValue* suggestion; | |
| 689 suggestions->GetDictionary(0, &suggestion); | |
|
sky
2015/05/13 15:52:03
Don't you need to check the return value here?
edwardjung
2015/05/13 17:34:34
Yes, I do via DictionaryValue suggestion.
| |
| 690 int type = -1; | |
| 691 suggestion->GetInteger("type", &type); | |
| 692 | |
| 693 if (type == 0) { | |
| 694 base::string16 cache_url; | |
| 695 suggestion->GetString("urlCorrection", &cache_url); | |
| 696 int cache_tracking_id = -1; | |
| 697 suggestion->GetInteger("trackingId", &cache_tracking_id); | |
| 698 | |
| 699 base::DictionaryValue* cache_button = new base::DictionaryValue; | |
|
sky
2015/05/13 15:52:03
used scoped_ptr and release when passing to Set be
edwardjung
2015/05/13 17:34:34
Done.
| |
| 700 | |
| 701 if (fieldTrialExpType == kCachedCopyButtonExpTypeCopy) { | |
| 702 cache_button->SetString("msg", | |
| 703 l10n_util::GetStringUTF16( | |
| 704 IDS_ERRORPAGES_BUTTON_SHOW_CACHED_COPY)); | |
| 705 } else { | |
| 706 // Default to "Show cached page" button label. | |
| 707 cache_button->SetString("msg", | |
| 708 l10n_util::GetStringUTF16( | |
| 709 IDS_ERRORPAGES_BUTTON_SHOW_CACHED_PAGE)); | |
| 710 } | |
| 711 cache_button->SetString("cacheUrl", cache_url); | |
| 712 cache_button->SetInteger("trackingId", cache_tracking_id); | |
| 713 error_strings->Set("cacheButton", cache_button); | |
| 714 suggestions->Remove(0, NULL); | |
| 715 } | |
| 716 } | |
| 674 } | 717 } |
| 675 | 718 |
| 676 error_strings->Set("suggestions", suggestions); | 719 error_strings->Set("suggestions", suggestions); |
| 677 | 720 |
| 678 if (params->search_url.is_valid()) { | 721 if (params->search_url.is_valid()) { |
| 679 error_strings->SetString("searchHeader", | 722 error_strings->SetString("searchHeader", |
| 680 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); | 723 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); |
| 681 error_strings->SetString("searchUrl", params->search_url.spec()); | 724 error_strings->SetString("searchUrl", params->search_url.spec()); |
| 682 error_strings->SetString("searchTerms", params->search_terms); | 725 error_strings->SetString("searchTerms", params->search_terms); |
| 683 error_strings->SetInteger("searchTrackingId", params->search_tracking_id); | 726 error_strings->SetInteger("searchTrackingId", params->search_tracking_id); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 920 GURL learn_more_url(kAppWarningLearnMoreUrl); | 963 GURL learn_more_url(kAppWarningLearnMoreUrl); |
| 921 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); | 964 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); |
| 922 suggest_learn_more->SetString("msg", | 965 suggest_learn_more->SetString("msg", |
| 923 l10n_util::GetStringUTF16( | 966 l10n_util::GetStringUTF16( |
| 924 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); | 967 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); |
| 925 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); | 968 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); |
| 926 error_strings->Set("suggestionsLearnMore", suggest_learn_more); | 969 error_strings->Set("suggestionsLearnMore", suggest_learn_more); |
| 927 #endif // defined(OS_CHROMEOS) | 970 #endif // defined(OS_CHROMEOS) |
| 928 } | 971 } |
| 929 #endif | 972 #endif |
| OLD | NEW |