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

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

Issue 1442433003: Add "Show saved copy" button in dino page when there's offline copy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some minor fixes Created 5 years, 1 month 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/metrics/field_trial.h"
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 } // namespace 547 } // namespace
548 548
549 const char LocalizedError::kHttpErrorDomain[] = "http"; 549 const char LocalizedError::kHttpErrorDomain[] = "http";
550 550
551 void LocalizedError::GetStrings(int error_code, 551 void LocalizedError::GetStrings(int error_code,
552 const std::string& error_domain, 552 const std::string& error_domain,
553 const GURL& failed_url, 553 const GURL& failed_url,
554 bool is_post, 554 bool is_post,
555 bool stale_copy_in_cache, 555 bool stale_copy_in_cache,
556 bool can_show_network_diagnostics_dialog, 556 bool can_show_network_diagnostics_dialog,
557 bool has_offline_pages, 557 OfflinePageStatus offline_page_status,
558 const std::string& locale, 558 const std::string& locale,
559 const std::string& accept_languages, 559 const std::string& accept_languages,
560 scoped_ptr<error_page::ErrorPageParams> params, 560 scoped_ptr<error_page::ErrorPageParams> params,
561 base::DictionaryValue* error_strings) { 561 base::DictionaryValue* error_strings) {
562 webui::SetLoadTimeDataDefaults(locale, error_strings); 562 webui::SetLoadTimeDataDefaults(locale, error_strings);
563 563
564 // Grab the strings and settings that depend on the error type. Init 564 // Grab the strings and settings that depend on the error type. Init
565 // options with default values. 565 // options with default values.
566 LocalizedErrorMap options = { 566 LocalizedErrorMap options = {
567 0, 567 0,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY)); 761 IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY));
762 show_saved_copy_button->SetString( 762 show_saved_copy_button->SetString(
763 "title", 763 "title",
764 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY_HELP)); 764 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY_HELP));
765 if (show_saved_copy_primary) 765 if (show_saved_copy_primary)
766 show_saved_copy_button->SetString("primary", "true"); 766 show_saved_copy_button->SetString("primary", "true");
767 error_strings->Set("showSavedCopyButton", show_saved_copy_button); 767 error_strings->Set("showSavedCopyButton", show_saved_copy_button);
768 } 768 }
769 769
770 #if defined(OS_ANDROID) 770 #if defined(OS_ANDROID)
771 if (has_offline_pages) { 771 // Offline button will not be provided when we want to show something in the
772 base::DictionaryValue* show_saved_pages_button = new base::DictionaryValue; 772 // cache.
773 show_saved_pages_button->SetString( 773 if (!show_saved_copy_visible) {
774 "msg", 774 if (offline_page_status == OfflinePageStatus::HAS_PAGE_COPY) {
775 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_PAGES)); 775 base::DictionaryValue* show_offline_copy_button =
776 show_saved_pages_button->SetString( 776 new base::DictionaryValue;
777 "title", 777 base::string16 button_text =
778 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_PAGES)); 778 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_COPY);
779 error_strings->Set("showSavedPagesButton", show_saved_pages_button); 779 show_offline_copy_button->SetString("msg", button_text);
780 show_offline_copy_button->SetString("title", button_text);
781 error_strings->Set("showOfflineCopyButton", show_offline_copy_button);
782 } else if (offline_page_status == OfflinePageStatus::HAS_OTHER_COPIES) {
783 base::DictionaryValue* show_offline_pages_button =
784 new base::DictionaryValue;
785 base::string16 button_text =
786 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_PAGES);
787 show_offline_pages_button->SetString("msg", button_text);
788 show_offline_pages_button->SetString("title", button_text);
789 error_strings->Set("showOfflinePagesButton", show_offline_pages_button);
790 }
780 } 791 }
781 #endif 792 #endif
782 793
783 #if defined(OS_CHROMEOS) 794 #if defined(OS_CHROMEOS)
784 // ChromeOS has its own diagnostics extension, which doesn't rely on a 795 // ChromeOS has its own diagnostics extension, which doesn't rely on a
785 // browser-initiated dialog. 796 // browser-initiated dialog.
786 can_show_network_diagnostics_dialog = true; 797 can_show_network_diagnostics_dialog = true;
787 #endif 798 #endif
788 if (can_show_network_diagnostics_dialog && failed_url.is_valid() && 799 if (can_show_network_diagnostics_dialog && failed_url.is_valid() &&
789 failed_url.SchemeIsHTTPOrHTTPS()) { 800 failed_url.SchemeIsHTTPOrHTTPS()) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN); 937 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN);
927 } 938 }
928 939
929 bool LocalizedError::HasStrings(const std::string& error_domain, 940 bool LocalizedError::HasStrings(const std::string& error_domain,
930 int error_code) { 941 int error_code) {
931 // Whether or not the there are strings for an error does not depend on 942 // Whether or not the there are strings for an error does not depend on
932 // whether or not the page was be generated by a POST, so just claim it was 943 // whether or not the page was be generated by a POST, so just claim it was
933 // not. 944 // not.
934 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != NULL; 945 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != NULL;
935 } 946 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698