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

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

Issue 961443002: Three way experiment for "Show saved copy" button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatting fix Created 5 years, 9 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/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
10 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/common/chrome_switches.h"
14 #include "chrome/grit/chromium_strings.h" 16 #include "chrome/grit/chromium_strings.h"
15 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
16 #include "components/error_page/common/error_page_params.h" 18 #include "components/error_page/common/error_page_params.h"
17 #include "components/error_page/common/net_error_info.h" 19 #include "components/error_page/common/net_error_info.h"
18 #include "net/base/escape.h" 20 #include "net/base/escape.h"
19 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
20 #include "net/base/net_util.h" 22 #include "net/base/net_util.h"
21 #include "third_party/WebKit/public/platform/WebURLError.h" 23 #include "third_party/WebKit/public/platform/WebURLError.h"
22 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/webui/web_ui_util.h" 25 #include "ui/base/webui/web_ui_util.h"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 } 503 }
502 504
503 } // namespace 505 } // namespace
504 506
505 const char LocalizedError::kHttpErrorDomain[] = "http"; 507 const char LocalizedError::kHttpErrorDomain[] = "http";
506 508
507 void LocalizedError::GetStrings(int error_code, 509 void LocalizedError::GetStrings(int error_code,
508 const std::string& error_domain, 510 const std::string& error_domain,
509 const GURL& failed_url, 511 const GURL& failed_url,
510 bool is_post, 512 bool is_post,
511 bool show_stale_load_button, 513 bool stale_copy_in_cache,
512 const std::string& locale, 514 const std::string& locale,
513 const std::string& accept_languages, 515 const std::string& accept_languages,
514 scoped_ptr<error_page::ErrorPageParams> params, 516 scoped_ptr<error_page::ErrorPageParams> params,
515 base::DictionaryValue* error_strings) { 517 base::DictionaryValue* error_strings) {
516 webui::SetLoadTimeDataDefaults(locale, error_strings); 518 webui::SetLoadTimeDataDefaults(locale, error_strings);
517 519
518 // Grab the strings and settings that depend on the error type. Init 520 // Grab the strings and settings that depend on the error type. Init
519 // options with default values. 521 // options with default values.
520 LocalizedErrorMap options = { 522 LocalizedErrorMap options = {
521 0, 523 0,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 // Add at the front, so it appears before other suggestions, in the case 683 // Add at the front, so it appears before other suggestions, in the case
682 // suggestions are being overridden by |params|. 684 // suggestions are being overridden by |params|.
683 suggestions->Insert(0, suggest_reload_repost); 685 suggestions->Insert(0, suggest_reload_repost);
684 } 686 }
685 } 687 }
686 688
687 // If not using the default suggestions, nothing else to do. 689 // If not using the default suggestions, nothing else to do.
688 if (!use_default_suggestions) 690 if (!use_default_suggestions)
689 return; 691 return;
690 692
691 if (show_stale_load_button) { 693 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
692 base::DictionaryValue* stale_load_button = new base::DictionaryValue; 694 const std::string& show_saved_copy_value =
693 stale_load_button->SetString( 695 command_line->GetSwitchValueASCII(switches::kShowSavedCopy);
694 "msg", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_LOAD_STALE)); 696 bool show_saved_copy_primary = (show_saved_copy_value ==
695 stale_load_button->SetString( 697 switches::kEnableShowSavedCopyPrimary);
698 bool show_saved_copy_visible =
699 (stale_copy_in_cache && !is_post &&
700 (show_saved_copy_primary ||
701 show_saved_copy_value == switches::kEnableShowSavedCopySecondary));
Lei Zhang 2015/03/02 20:31:03 nit: I would just create a |show_saved_copy_second
megjablon 2015/03/03 01:07:38 Done.
702
703 if (show_saved_copy_visible) {
704 base::DictionaryValue* show_saved_copy_button = new base::DictionaryValue;
705 show_saved_copy_button->SetString(
706 "msg", l10n_util::GetStringUTF16(
707 IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY));
708 show_saved_copy_button->SetString(
696 "title", 709 "title",
697 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_LOAD_STALE_HELP)); 710 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY_HELP));
698 error_strings->Set("staleLoadButton", stale_load_button); 711 if (show_saved_copy_primary)
712 show_saved_copy_button->SetString("primary", "true");
713 error_strings->Set("showSavedCopyButton", show_saved_copy_button);
699 } 714 }
700 715
701 #if defined(OS_CHROMEOS) 716 #if defined(OS_CHROMEOS)
702 error_strings->SetString( 717 error_strings->SetString(
703 "diagnose", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DIAGNOSE)); 718 "diagnose", l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_DIAGNOSE));
704 #endif // defined(OS_CHROMEOS) 719 #endif // defined(OS_CHROMEOS)
705 720
706 if (options.suggestions & SUGGEST_CHECK_CONNECTION) { 721 if (options.suggestions & SUGGEST_CHECK_CONNECTION) {
707 base::DictionaryValue* suggest_check_connection = new base::DictionaryValue; 722 base::DictionaryValue* suggest_check_connection = new base::DictionaryValue;
708 suggest_check_connection->SetString("header", 723 suggest_check_connection->SetString("header",
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 GURL learn_more_url(kAppWarningLearnMoreUrl); 895 GURL learn_more_url(kAppWarningLearnMoreUrl);
881 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue(); 896 base::DictionaryValue* suggest_learn_more = new base::DictionaryValue();
882 suggest_learn_more->SetString("msg", 897 suggest_learn_more->SetString("msg",
883 l10n_util::GetStringUTF16( 898 l10n_util::GetStringUTF16(
884 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY)); 899 IDS_ERRORPAGES_SUGGESTION_LEARNMORE_BODY));
885 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec()); 900 suggest_learn_more->SetString("learnMoreUrl", learn_more_url.spec());
886 error_strings->Set("suggestionsLearnMore", suggest_learn_more); 901 error_strings->Set("suggestionsLearnMore", suggest_learn_more);
887 #endif // defined(OS_CHROMEOS) 902 #endif // defined(OS_CHROMEOS)
888 } 903 }
889 #endif 904 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698