Index: chrome/common/localized_error.cc |
diff --git a/chrome/common/localized_error.cc b/chrome/common/localized_error.cc |
index 0c4ad4361e590adf71d4784a78846863e490b287..500ae2b21704c2c10b56709ac529d5c94f96df61 100644 |
--- a/chrome/common/localized_error.cc |
+++ b/chrome/common/localized_error.cc |
@@ -7,6 +7,7 @@ |
#include "base/command_line.h" |
#include "base/i18n/rtl.h" |
#include "base/logging.h" |
+#include "base/metrics/field_trial.h" |
#include "base/strings/string16.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_util.h" |
@@ -56,6 +57,11 @@ static const char kAppWarningLearnMoreUrl[] = |
"chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html" |
"?answer=1721911"; |
#endif // defined(OS_CHROMEOS) |
+static const char kCachedCopyButtonFieldTrial[] = |
+ "enable_google_cached_copy_text_experiment"; |
+static const char kCachedCopyButtonExpTypeControl[] = "control"; |
+static const char kCachedCopyButtonExpTypeCopy[] = "copy"; |
+static const char kCachedCopyButtonExpTypePage[] = "page"; |
enum NAV_SUGGESTIONS { |
SUGGEST_NONE = 0, |
@@ -671,6 +677,42 @@ void LocalizedError::GetStrings(int error_code, |
} else { |
suggestions = params->override_suggestions.release(); |
use_default_suggestions = false; |
+ |
+ std::string fieldTrialExpType = |
+ base::FieldTrialList::FindFullName(kCachedCopyButtonFieldTrial); |
+ |
+ // If the first suggestion is for a Google cache copy. Promote the |
+ // suggestion to a separate set of strings for displaying as a button. |
+ if (!suggestions->empty() && !fieldTrialExpType.empty() && |
+ fieldTrialExpType != kCachedCopyButtonExpTypeControl) { |
+ base::DictionaryValue* suggestion; |
+ suggestions->GetDictionary(0, &suggestion); |
+ int type = -1; |
+ suggestion->GetInteger("type", &type); |
+ |
+ if (type == 0) { |
+ base::string16 cache_url; |
+ suggestion->GetString("urlCorrection", &cache_url); |
+ int cache_tracking_id = -1; |
+ suggestion->GetInteger("trackingId", &cache_tracking_id); |
+ |
+ base::DictionaryValue* cache_button = new base::DictionaryValue; |
+ |
+ if (fieldTrialExpType == kCachedCopyButtonExpTypeCopy) { |
+ cache_button->SetString("msg", |
+ l10n_util::GetStringUTF16( |
+ IDS_ERRORPAGES_BUTTON_SHOW_CACHED_COPY)); |
+ } 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
|
+ cache_button->SetString("msg", |
+ l10n_util::GetStringUTF16( |
+ IDS_ERRORPAGES_BUTTON_SHOW_CACHED_PAGE)); |
+ } |
+ cache_button->SetString("cacheUrl", cache_url); |
+ cache_button->SetInteger("trackingId", cache_tracking_id); |
+ error_strings->Set("cacheButton", cache_button); |
+ suggestions->Remove(0, NULL); |
+ } |
+ } |
} |
error_strings->Set("suggestions", suggestions); |