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

Unified Diff: chrome/browser/ui/sad_tab.cc

Issue 2794763002: New Sad Tab strings. (Closed)
Patch Set: msvc compile fix Created 3 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/browser/ui/sad_tab.h ('k') | chrome/browser/ui/views/sad_tab_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/sad_tab.cc
diff --git a/chrome/browser/ui/sad_tab.cc b/chrome/browser/ui/sad_tab.cc
index b08a44ad1c857bc3ccaded2d095ea13fea618414..bb3fbe781d69c7e9f6f64d1f195df9b3a3729e49 100644
--- a/chrome/browser/ui/sad_tab.cc
+++ b/chrome/browser/ui/sad_tab.cc
@@ -6,8 +6,11 @@
#include "base/metrics/histogram_macros.h"
#include "chrome/browser/net/referrer.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/feedback/feedback_util.h"
@@ -68,6 +71,13 @@ bool ShouldShowFeedbackButton() {
#endif
}
+bool AreOtherTabsOpen() {
+ size_t tab_count = 0;
+ for (auto* browser : *BrowserList::GetInstance())
+ tab_count += browser->tab_strip_model()->count();
+ return (tab_count > 1U);
+}
+
} // namespace
namespace chrome {
@@ -97,7 +107,23 @@ bool SadTab::ShouldShow(base::TerminationStatus status) {
}
int SadTab::GetTitle() {
- return IDS_SAD_TAB_TITLE;
+ if (!show_feedback_button_)
+ return IDS_SAD_TAB_TITLE;
+ switch (kind_) {
+#if defined(OS_CHROMEOS)
+ case chrome::SAD_TAB_KIND_KILLED_BY_OOM:
+ return IDS_SAD_TAB_RELOAD_TITLE;
+#endif
+ case chrome::SAD_TAB_KIND_OOM:
+#if defined(OS_WIN) // Only Windows has OOM sad tab strings.
+ return IDS_SAD_TAB_OOM_TITLE;
+#endif
+ case chrome::SAD_TAB_KIND_CRASHED:
+ case chrome::SAD_TAB_KIND_KILLED:
+ return IDS_SAD_TAB_RELOAD_TITLE;
+ }
+ NOTREACHED();
+ return 0;
}
int SadTab::GetMessage() {
@@ -107,10 +133,14 @@ int SadTab::GetMessage() {
return IDS_KILLED_TAB_BY_OOM_MESSAGE;
#endif
case chrome::SAD_TAB_KIND_OOM:
- return IDS_SAD_TAB_OOM_MESSAGE;
+ if (show_feedback_button_)
+ return AreOtherTabsOpen() ? IDS_SAD_TAB_OOM_MESSAGE_TABS
+ : IDS_SAD_TAB_OOM_MESSAGE_NOTABS;
+ return IDS_SAD_TAB_MESSAGE;
case chrome::SAD_TAB_KIND_CRASHED:
case chrome::SAD_TAB_KIND_KILLED:
- return IDS_SAD_TAB_MESSAGE;
+ return show_feedback_button_ ? IDS_SAD_TAB_RELOAD_TRY
+ : IDS_SAD_TAB_MESSAGE;
}
NOTREACHED();
return 0;
@@ -130,6 +160,39 @@ const char* SadTab::GetHelpLinkURL() {
: chrome::kCrashReasonURL;
}
+int SadTab::GetSubMessage(size_t line_id) {
+ // Note: on macOS, Linux and ChromeOS, the first bullet is either one of
+ // IDS_SAD_TAB_RELOAD_CLOSE_TABS or IDS_SAD_TAB_RELOAD_CLOSE_NOTABS followed
+ // by one of these suggestions.
+ const int kLineIds[] = {IDS_SAD_TAB_RELOAD_INCOGNITO,
+ IDS_SAD_TAB_RELOAD_RESTART_BROWSER,
+ IDS_SAD_TAB_RELOAD_RESTART_DEVICE};
+
+ if (!show_feedback_button_)
+ return 0;
+ switch (kind_) {
+#if defined(OS_CHROMEOS)
+ case chrome::SAD_TAB_KIND_KILLED_BY_OOM:
+ return 0;
+#endif
+ case chrome::SAD_TAB_KIND_OOM:
+ return 0;
+ case chrome::SAD_TAB_KIND_CRASHED:
+ case chrome::SAD_TAB_KIND_KILLED:
+#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_CHROMEOS)
+ if (line_id == 0)
+ return AreOtherTabsOpen() ? IDS_SAD_TAB_RELOAD_CLOSE_TABS
+ : IDS_SAD_TAB_RELOAD_CLOSE_NOTABS;
+ line_id--;
+#endif
+ if (line_id > 2)
+ return 0;
+ return kLineIds[line_id];
+ }
+ NOTREACHED();
+ return 0;
+}
+
void SadTab::RecordFirstPaint() {
DCHECK(!recorded_paint_);
recorded_paint_ = true;
« no previous file with comments | « chrome/browser/ui/sad_tab.h ('k') | chrome/browser/ui/views/sad_tab_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698