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 "EnableGoogleCachedCopyTextExperiment"; | |
62 static const char kCachedCopyButtonExpTypeControl[] = "control"; | |
63 static const char kCachedCopyButtonExpTypeCopy[] = "copy"; | |
59 | 64 |
60 enum NAV_SUGGESTIONS { | 65 enum NAV_SUGGESTIONS { |
61 SUGGEST_NONE = 0, | 66 SUGGEST_NONE = 0, |
62 SUGGEST_RELOAD = 1 << 0, | 67 SUGGEST_RELOAD = 1 << 0, |
63 SUGGEST_CHECK_CONNECTION = 1 << 1, | 68 SUGGEST_CHECK_CONNECTION = 1 << 1, |
64 SUGGEST_DNS_CONFIG = 1 << 2, | 69 SUGGEST_DNS_CONFIG = 1 << 2, |
65 SUGGEST_FIREWALL_CONFIG = 1 << 3, | 70 SUGGEST_FIREWALL_CONFIG = 1 << 3, |
66 SUGGEST_PROXY_CONFIG = 1 << 4, | 71 SUGGEST_PROXY_CONFIG = 1 << 4, |
67 SUGGEST_DISABLE_EXTENSION = 1 << 5, | 72 SUGGEST_DISABLE_EXTENSION = 1 << 5, |
68 SUGGEST_LEARNMORE = 1 << 6, | 73 SUGGEST_LEARNMORE = 1 << 6, |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 error_domain == chrome_common_net::kDnsProbeErrorDomain)) | 516 error_domain == chrome_common_net::kDnsProbeErrorDomain)) |
512 return "icon-offline"; | 517 return "icon-offline"; |
513 | 518 |
514 return "icon-generic"; | 519 return "icon-generic"; |
515 } | 520 } |
516 | 521 |
517 } // namespace | 522 } // namespace |
518 | 523 |
519 const char LocalizedError::kHttpErrorDomain[] = "http"; | 524 const char LocalizedError::kHttpErrorDomain[] = "http"; |
520 | 525 |
526 void LocalizedError::EnableGoogleCachedCopyButtonExperiment( | |
sky
2015/06/02 16:18:06
Make position match that of header.
edwardjung
2015/06/03 13:40:36
Done.
| |
527 base::ListValue* suggestions, | |
528 base::DictionaryValue* error_strings) { | |
529 std::string field_trial_exp_type_ = | |
530 base::FieldTrialList::FindFullName(kCachedCopyButtonFieldTrial); | |
531 | |
532 // If the first suggestion is for a Google cache copy. Promote the | |
533 // suggestion to a separate set of strings for displaying as a button. | |
534 if (!suggestions->empty() && !field_trial_exp_type_.empty() && | |
535 field_trial_exp_type_ != kCachedCopyButtonExpTypeControl) { | |
536 base::DictionaryValue* suggestion; | |
537 suggestions->GetDictionary(0, &suggestion); | |
538 int type = -1; | |
539 suggestion->GetInteger("type", &type); | |
540 | |
541 if (type == 0) { | |
sky
2015/06/02 16:18:06
where does 0 come from? Please use a constant.
edwardjung
2015/06/03 13:40:36
Done.
| |
542 base::string16 cache_url; | |
543 suggestion->GetString("urlCorrection", &cache_url); | |
544 int cache_tracking_id = -1; | |
545 suggestion->GetInteger("trackingId", &cache_tracking_id); | |
546 | |
547 scoped_ptr<base::DictionaryValue> cache_button(new base::DictionaryValue); | |
548 | |
549 if (field_trial_exp_type_ == kCachedCopyButtonExpTypeCopy) { | |
550 cache_button->SetString( | |
551 "msg", | |
552 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_CACHED_COPY)); | |
553 } else { | |
554 // Default to "Show cached page" button label. | |
555 cache_button->SetString( | |
556 "msg", | |
557 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_CACHED_PAGE)); | |
558 } | |
559 cache_button->SetString("cacheUrl", cache_url); | |
sky
2015/06/02 16:18:06
You're not checking the url is valid. Should you?
edwardjung
2015/06/03 13:40:36
This link is returned from the link doctor so I wo
| |
560 cache_button->SetInteger("trackingId", cache_tracking_id); | |
561 error_strings->Set("cacheButton", cache_button.release()); | |
562 suggestions->Remove(0, NULL); | |
sky
2015/06/02 16:18:06
Why do you need to remove?
sky
2015/06/02 16:18:06
nullptr
edwardjung
2015/06/03 13:40:36
As the suggestion text would be displayed in the d
edwardjung
2015/06/03 13:40:36
Done.
| |
563 } | |
564 } | |
565 } | |
566 | |
521 void LocalizedError::GetStrings(int error_code, | 567 void LocalizedError::GetStrings(int error_code, |
522 const std::string& error_domain, | 568 const std::string& error_domain, |
523 const GURL& failed_url, | 569 const GURL& failed_url, |
524 bool is_post, | 570 bool is_post, |
525 bool stale_copy_in_cache, | 571 bool stale_copy_in_cache, |
526 const std::string& locale, | 572 const std::string& locale, |
527 const std::string& accept_languages, | 573 const std::string& accept_languages, |
528 scoped_ptr<error_page::ErrorPageParams> params, | 574 scoped_ptr<error_page::ErrorPageParams> params, |
529 base::DictionaryValue* error_strings) { | 575 base::DictionaryValue* error_strings) { |
530 webui::SetLoadTimeDataDefaults(locale, error_strings); | 576 webui::SetLoadTimeDataDefaults(locale, error_strings); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
664 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); | 710 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); |
665 } | 711 } |
666 | 712 |
667 base::ListValue* suggestions = NULL; | 713 base::ListValue* suggestions = NULL; |
668 bool use_default_suggestions = true; | 714 bool use_default_suggestions = true; |
669 if (!params->override_suggestions) { | 715 if (!params->override_suggestions) { |
670 suggestions = new base::ListValue(); | 716 suggestions = new base::ListValue(); |
671 } else { | 717 } else { |
672 suggestions = params->override_suggestions.release(); | 718 suggestions = params->override_suggestions.release(); |
673 use_default_suggestions = false; | 719 use_default_suggestions = false; |
720 EnableGoogleCachedCopyButtonExperiment(suggestions, error_strings); | |
674 } | 721 } |
675 | 722 |
676 error_strings->Set("suggestions", suggestions); | 723 error_strings->Set("suggestions", suggestions); |
677 | 724 |
678 if (params->search_url.is_valid()) { | 725 if (params->search_url.is_valid()) { |
679 error_strings->SetString("searchHeader", | 726 error_strings->SetString("searchHeader", |
680 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); | 727 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); |
681 error_strings->SetString("searchUrl", params->search_url.spec()); | 728 error_strings->SetString("searchUrl", params->search_url.spec()); |
682 error_strings->SetString("searchTerms", params->search_terms); | 729 error_strings->SetString("searchTerms", params->search_terms); |
683 error_strings->SetInteger("searchTrackingId", params->search_tracking_id); | 730 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); | 967 GURL learn_more_url(kAppWarningLearnMoreUrl); |
921 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); | 968 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); |
922 suggest_learn_more->SetString("msg", | 969 suggest_learn_more->SetString("msg", |
923 l10n_util::GetStringUTF16( | 970 l10n_util::GetStringUTF16( |
924 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); | 971 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); |
925 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); | 972 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); |
926 error_strings->Set("suggestionsLearnMore", suggest_learn_more); | 973 error_strings->Set("suggestionsLearnMore", suggest_learn_more); |
927 #endif // defined(OS_CHROMEOS) | 974 #endif // defined(OS_CHROMEOS) |
928 } | 975 } |
929 #endif | 976 #endif |
OLD | NEW |