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

Unified 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: Address review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/renderer/resources/neterror.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/renderer/resources/neterror.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698