Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/common/localized_error.cc

Issue 1129353005: Move Google Cache copy suggestion to an action button in the neterror interstitial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix size_t to int data loss warning Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/common/localized_error.h ('k') | chrome/renderer/resources/neterror.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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";
64 static const int kGoogleCachedCopySuggestionType = 0;
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
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 EnableGoogleCachedCopyButtonExperiment(suggestions, error_strings);
674 } 681 }
675 682
676 error_strings->Set("suggestions", suggestions); 683 error_strings->Set("suggestions", suggestions);
677 684
678 if (params->search_url.is_valid()) { 685 if (params->search_url.is_valid()) {
679 error_strings->SetString("searchHeader", 686 error_strings->SetString("searchHeader",
680 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); 687 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH));
681 error_strings->SetString("searchUrl", params->search_url.spec()); 688 error_strings->SetString("searchUrl", params->search_url.spec());
682 error_strings->SetString("searchTerms", params->search_terms); 689 error_strings->SetString("searchTerms", params->search_terms);
683 error_strings->SetInteger("searchTrackingId", params->search_tracking_id); 690 error_strings->SetInteger("searchTrackingId", params->search_tracking_id);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 GURL learn_more_url(kAppWarningLearnMoreUrl); 927 GURL learn_more_url(kAppWarningLearnMoreUrl);
921 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); 928 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue();
922 suggest_learn_more->SetString("msg", 929 suggest_learn_more->SetString("msg",
923 l10n_util::GetStringUTF16( 930 l10n_util::GetStringUTF16(
924 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); 931 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY));
925 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); 932 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
926 error_strings->Set("suggestionsLearnMore", suggest_learn_more); 933 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
927 #endif // defined(OS_CHROMEOS) 934 #endif // defined(OS_CHROMEOS)
928 } 935 }
929 #endif 936 #endif
937
938 void LocalizedError::EnableGoogleCachedCopyButtonExperiment(
939 base::ListValue* suggestions,
940 base::DictionaryValue* error_strings) {
941 std::string field_trial_exp_type_ =
942 base::FieldTrialList::FindFullName(kCachedCopyButtonFieldTrial);
943
944 // If the first suggestion is for a Google cache copy. Promote the
945 // suggestion to a separate set of strings for displaying as a button.
946 if (!suggestions->empty() && !field_trial_exp_type_.empty() &&
947 field_trial_exp_type_ != kCachedCopyButtonExpTypeControl) {
948 base::DictionaryValue* suggestion;
949 suggestions->GetDictionary(0, &suggestion);
950 int type = -1;
951 suggestion->GetInteger("type", &type);
952
953 if (type == kGoogleCachedCopySuggestionType) {
954 base::string16 cache_url;
955 suggestion->GetString("urlCorrection", &cache_url);
956 int cache_tracking_id = -1;
957 suggestion->GetInteger("trackingId", &cache_tracking_id);
958
959 scoped_ptr<base::DictionaryValue> cache_button(new base::DictionaryValue);
960
961 if (field_trial_exp_type_ == kCachedCopyButtonExpTypeCopy) {
962 cache_button->SetString(
963 "msg",
964 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_CACHED_COPY));
965 } else {
966 // Default to "Show cached page" button label.
967 cache_button->SetString(
968 "msg",
969 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_CACHED_PAGE));
970 }
971 cache_button->SetString("cacheUrl", cache_url);
972 cache_button->SetInteger("trackingId", cache_tracking_id);
973 error_strings->Set("cacheButton", cache_button.release());
974
975 // Remove the item from suggestions dictionary so that it does not get
976 // displayed by the template in the details section.
977 suggestions->Remove(0, nullptr);
978 }
979 }
980 }
OLDNEW
« no previous file with comments | « chrome/common/localized_error.h ('k') | chrome/renderer/resources/neterror.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698