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

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: Add finch experiment code Created 5 years, 7 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
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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD); 665 params->suggest_reload = !!(options.suggestions & SUGGEST_RELOAD);
665 } 666 }
666 667
667 base::ListValue* suggestions = NULL; 668 base::ListValue* suggestions = NULL;
668 bool use_default_suggestions = true; 669 bool use_default_suggestions = true;
669 if (!params->override_suggestions) { 670 if (!params->override_suggestions) {
670 suggestions = new base::ListValue(); 671 suggestions = new base::ListValue();
671 } else { 672 } else {
672 suggestions = params->override_suggestions.release(); 673 suggestions = params->override_suggestions.release();
673 use_default_suggestions = false; 674 use_default_suggestions = false;
675
676 std::string fieldTrialExpType = base::FieldTrialList::FindFullName(
felt 2015/05/11 20:46:44 in C++ style this should be field_trial_exp_type
edwardjung 2015/05/12 10:16:50 Done.
felt 2015/05/12 14:15:08 still seems to be field_trial_exp_type in the late
edwardjung 2015/05/13 09:59:56 Should it be field_type_exp_type or fieldTrialExpT
felt 2015/05/13 14:32:11 field_type_exp_type all local variables are done w
edwardjung 2015/05/13 17:34:33 No, my fault, couldn't see the wood for the trees.
677 "EnableGoogleCachedCopyTextExperiment");
678
679 // If the first suggestion is for a Google cache copy. Promote the
680 // suggestion to a separate set of strings for displaying as a button.
681 if (!suggestions->empty() && fieldTrialExpType != "") {
felt 2015/05/11 20:46:43 !field_trial_exp_type.empty()
felt 2015/05/11 20:46:44 Do you also want to support a control group (e.g.,
edwardjung 2015/05/12 10:16:50 Good point, will add a control.
edwardjung 2015/05/12 10:16:50 Done.
682 base::DictionaryValue* suggestion;
683 suggestions->GetDictionary(0, &suggestion);
684 int type = -1;
685 suggestion->GetInteger("type", &type);
686
687 if (type == 0) {
688 base::string16 cache_url;
689 suggestion->GetString("urlCorrection", &cache_url);
690 int cache_tracking_id = -1;
691 suggestion->GetInteger("trackingId", &cache_tracking_id);
692
693 base::DictionaryValue* cache_button = new base::DictionaryValue;
694
695 if (fieldTrialExpType == "copy") {
felt 2015/05/11 20:46:43 I'd recommend setting both "EnableGoogleCachedCopy
edwardjung 2015/05/12 10:16:50 Done.
696 cache_button->SetString(
697 "msg", l10n_util::GetStringUTF16(
felt 2015/05/11 20:46:43 nit: this line wrap (and the one below) looks kind
edwardjung 2015/05/12 10:16:50 I wasn't even aware of that command. Great time sa
felt 2015/05/12 14:15:08 always double check it, sometimes it does weird st
698 IDS_ERRORPAGES_BUTTON_SHOW_CACHED_COPY));
699 } else {
700 cache_button->SetString(
701 "msg", l10n_util::GetStringUTF16(
702 IDS_ERRORPAGES_BUTTON_SHOW_CACHED_PAGE));
703 }
felt 2015/05/11 20:46:43 Is there another condition besides "copy"? How mig
edwardjung 2015/05/12 10:16:50 My thinking is there would be three sets: + "contr
felt 2015/05/12 14:15:07 I think it's clear now in the newest version.
704 cache_button->SetString("cacheUrl", cache_url);
705 cache_button->SetInteger("trackingId", cache_tracking_id);
706 error_strings->Set("cacheButton", cache_button);
707 suggestions->Remove(0, NULL);
708 }
709 }
674 } 710 }
675 711
676 error_strings->Set("suggestions", suggestions); 712 error_strings->Set("suggestions", suggestions);
677 713
678 if (params->search_url.is_valid()) { 714 if (params->search_url.is_valid()) {
679 error_strings->SetString("searchHeader", 715 error_strings->SetString("searchHeader",
680 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH)); 716 l10n_util::GetStringUTF16(IDS_ERRORPAGES_SUGGESTION_GOOGLE_SEARCH));
681 error_strings->SetString("searchUrl", params->search_url.spec()); 717 error_strings->SetString("searchUrl", params->search_url.spec());
682 error_strings->SetString("searchTerms", params->search_terms); 718 error_strings->SetString("searchTerms", params->search_terms);
683 error_strings->SetInteger("searchTrackingId", params->search_tracking_id); 719 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); 956 GURL learn_more_url(kAppWarningLearnMoreUrl);
921 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); 957 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue();
922 suggest_learn_more->SetString("msg", 958 suggest_learn_more->SetString("msg",
923 l10n_util::GetStringUTF16( 959 l10n_util::GetStringUTF16(
924 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); 960 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY));
925 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); 961 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
926 error_strings->Set("suggestionsLearnMore", suggest_learn_more); 962 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
927 #endif // defined(OS_CHROMEOS) 963 #endif // defined(OS_CHROMEOS)
928 } 964 }
929 #endif 965 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698