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

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: Patch 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
« no previous file with comments | « chrome/common/localized_error.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (offline_page_status == OfflinePageStatus::HAS_PAGE_COPY) {
772 base::DictionaryValue* show_saved_pages_button = new base::DictionaryValue; 772 base::DictionaryValue* show_offline_copy_button = new base::DictionaryValue;
773 show_saved_pages_button->SetString( 773 base::string16 button_text =
774 "msg", 774 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_COPY);
775 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_PAGES)); 775 show_offline_copy_button->SetString("msg", button_text);
776 show_saved_pages_button->SetString( 776 show_offline_copy_button->SetString("title", button_text);
777 "title", 777 error_strings->Set("showOfflineCopyButton", show_offline_copy_button);
mmenke 2015/11/12 19:55:18 What's the difference between an offline copy and
jianli 2015/11/12 21:16:16 If offline pages feature is on, we're going to sho
778 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_PAGES)); 778 } else if (offline_page_status == OfflinePageStatus::HAS_OTHER_COPIES) {
779 error_strings->Set("showSavedPagesButton", show_saved_pages_button); 779 base::DictionaryValue* show_offline_pages_button =
780 new base::DictionaryValue;
781 base::string16 button_text =
782 l10n_util::GetStringUTF16(IDS_ERRORPAGES_BUTTON_SHOW_OFFLINE_PAGES);
783 show_offline_pages_button->SetString("msg", button_text);
784 show_offline_pages_button->SetString("title", button_text);
785 error_strings->Set("showOfflinePagesButton", show_offline_pages_button);
780 } 786 }
781 #endif 787 #endif
782 788
783 #if defined(OS_CHROMEOS) 789 #if defined(OS_CHROMEOS)
784 // ChromeOS has its own diagnostics extension, which doesn't rely on a 790 // ChromeOS has its own diagnostics extension, which doesn't rely on a
785 // browser-initiated dialog. 791 // browser-initiated dialog.
786 can_show_network_diagnostics_dialog = true; 792 can_show_network_diagnostics_dialog = true;
787 #endif 793 #endif
788 if (can_show_network_diagnostics_dialog && failed_url.is_valid() && 794 if (can_show_network_diagnostics_dialog && failed_url.is_valid() &&
789 failed_url.SchemeIsHTTPOrHTTPS()) { 795 failed_url.SchemeIsHTTPOrHTTPS()) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN); 932 return l10n_util::GetStringUTF16(IDS_ERRORPAGES_DETAILS_UNKNOWN);
927 } 933 }
928 934
929 bool LocalizedError::HasStrings(const std::string& error_domain, 935 bool LocalizedError::HasStrings(const std::string& error_domain,
930 int error_code) { 936 int error_code) {
931 // Whether or not the there are strings for an error does not depend on 937 // 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 938 // whether or not the page was be generated by a POST, so just claim it was
933 // not. 939 // not.
934 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != NULL; 940 return LookupErrorMap(error_domain, error_code, /*is_post=*/false) != NULL;
935 } 941 }
OLDNEW
« no previous file with comments | « chrome/common/localized_error.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698