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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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(); |
673 use_default_suggestions = false; | 679 use_default_suggestions = false; |
680 | |
681 std::string fieldTrialExpType = | |
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); | |
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; | |
700 | |
701 if (fieldTrialExpType == kCachedCopyButtonExpTypeCopy) { | |
702 cache_button->SetString("msg", | |
703 l10n_util::GetStringUTF16( | |
704 IDS_ERRORPAGES_BUTTON_SHOW_CACHED_COPY)); | |
705 } else if (fieldTrialExpType == kCachedCopyButtonExpTypePage) { | |
felt
2015/05/12 14:15:08
You might have had the right idea with the else br
edwardjung
2015/05/13 09:59:56
Reverted back to using the else statement
| |
706 cache_button->SetString("msg", | |
707 l10n_util::GetStringUTF16( | |
708 IDS_ERRORPAGES_BUTTON_SHOW_CACHED_PAGE)); | |
709 } | |
710 cache_button->SetString("cacheUrl", cache_url); | |
711 cache_button->SetInteger("trackingId", cache_tracking_id); | |
712 error_strings->Set("cacheButton", cache_button); | |
713 suggestions->Remove(0, NULL); | |
714 } | |
715 } | |
674 } | 716 } |
675 | 717 |
676 error_strings->Set("suggestions", suggestions); | 718 error_strings->Set("suggestions", suggestions); |
677 | 719 |
678 if (params->search_url.is_valid()) { | 720 if (params->search_url.is_valid()) { |
679 error_strings->SetString("searchHeader", | 721 error_strings->SetString("searchHeader", |
680 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); | 722 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); |
681 error_strings->SetString("searchUrl", params->search_url.spec()); | 723 error_strings->SetString("searchUrl", params->search_url.spec()); |
682 error_strings->SetString("searchTerms", params->search_terms); | 724 error_strings->SetString("searchTerms", params->search_terms); |
683 error_strings->SetInteger("searchTrackingId", params->search_tracking_id); | 725 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); | 962 GURL learn_more_url(kAppWarningLearnMoreUrl); |
921 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); | 963 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); |
922 suggest_learn_more->SetString("msg", | 964 suggest_learn_more->SetString("msg", |
923 l10n_util::GetStringUTF16( | 965 l10n_util::GetStringUTF16( |
924 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); | 966 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); |
925 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); | 967 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); |
926 error_strings->Set("suggestionsLearnMore", suggest_learn_more); | 968 error_strings->Set("suggestionsLearnMore", suggest_learn_more); |
927 #endif // defined(OS_CHROMEOS) | 969 #endif // defined(OS_CHROMEOS) |
928 } | 970 } |
929 #endif | 971 #endif |
OLD | NEW |