diff options
author | gspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-13 21:50:16 +0000 |
---|---|---|
committer | gspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-13 21:50:16 +0000 |
commit | a8f02439c64d510855f0efa908152fe970557142 (patch) | |
tree | 7630edd402597eebe0caeb33b34a7b1064a19a08 /chrome | |
parent | 630c1f381c85b69064ce2adfd5999c0f3c136ed3 (diff) | |
download | chromium_src-a8f02439c64d510855f0efa908152fe970557142.zip chromium_src-a8f02439c64d510855f0efa908152fe970557142.tar.gz chromium_src-a8f02439c64d510855f0efa908152fe970557142.tar.bz2 |
This adds a "killed tab" page to be displayed in the case where a tab is killed instead of crashing.
It also adds "about:kill" to simulate kills.
On ChromeOS killed tabs will be reloaded as soon as the user clicks on them unless they are the only tab, or the currently focused tab is killed.
BUG=http://crosbug.com/10043, http://crosbug.com/10711
TEST=Built linux and ChromeOS Chrome and killed a tab, and then did about:crash and made sure that the "Aw, Snap!" page was displayed. Did about:kill and made sure kill page was displayed.
Review URL: http://codereview.chromium.org/6053012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71360 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
31 files changed, 179 insertions, 48 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index a6dc68a..561251a 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6746,6 +6746,16 @@ Keep your key file in a safe place. You will need it to create new versions of y Something went wrong while displaying this webpage. To continue, press Reload or go to another page. </message> + <!-- Killed Tab Strings --> + <!-- TODO(gspencer): These are temporary values until real + values are supplied by UI team. See http://crosbug.com/10711 --> + <message name="IDS_KILLED_TAB_TITLE" desc="The title of the killed tab page that is shown when a tab is killed by the OS. This is intended to be a humorous exclamation of dismay."> + He's Dead, Jim! + </message> + <message name="IDS_KILLED_TAB_MESSAGE" desc="The message displayed on the killed tab page."> + Something caused this webpage to be killed, either because the operating system ran out of memory, or for some other reason. To continue, press Reload or go to another page. + </message> + <!-- Incognito --> <message name="IDS_OFF_THE_RECORD_TOOLTIP" desc="The tooltip for the incognito icon."> You have opened an incognito window. Pages that you open in this window won't appear in your history. diff --git a/chrome/app/theme/killtab.png b/chrome/app/theme/killtab.png Binary files differnew file mode 100644 index 0000000..d9a6eb8 --- /dev/null +++ b/chrome/app/theme/killtab.png diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index 41346d8..8c44540 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -289,6 +289,7 @@ <include name="IDR_RESTORE_BUTTON_MASK" file="restore_button_mask.png" type="BINDATA" /> <include name="IDR_SAD_FAVICON" file="sadfavicon.png" type="BINDATA" /> <include name="IDR_SAD_TAB" file="sadtab.png" type="BINDATA" /> + <include name="IDR_KILLED_TAB" file="killtab.png" type="BINDATA" /> <include name="IDR_SEARCH_ENGINE_DIALOG_TOP" file="search_engine_top.png" type="BINDATA" /> <if expr="pp_ifdef('_google_chrome')"> <include name="IDR_SEARCH_ENGINE_LOGO_ABCSOK" file="google_chrome/search_abcsok.png" type="BINDATA" /> diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index af8b8e0..775f700 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -289,7 +289,8 @@ std::string AboutAbout() { html.append(kAllAboutPaths[i]); html.append("</a>\n"); } - const char *debug[] = { "crash", "hang", "shorthang", "gpucrash", "gpuhang" }; + const char *debug[] = { "crash", "kill", "hang", "shorthang", + "gpucrash", "gpuhang" }; html.append("</ul><h2>For Debug</h2>"); html.append("</ul><p>The following pages are for debugging purposes only. " "Because they crash or hang the renderer, they're not linked " diff --git a/chrome/browser/browser_about_handler_unittest.cc b/chrome/browser/browser_about_handler_unittest.cc index 9b234a2..6b3bd40 100644 --- a/chrome/browser/browser_about_handler_unittest.cc +++ b/chrome/browser/browser_about_handler_unittest.cc @@ -66,6 +66,12 @@ TEST(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { false }, { + GURL(chrome::kAboutKillURL), + GURL(chrome::kAboutKillURL), + true, + false + }, + { GURL(chrome::kAboutHangURL), GURL(chrome::kAboutHangURL), true, diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc index 3ef5f5b..69081da 100644 --- a/chrome/browser/dom_ui/dom_ui_factory.cc +++ b/chrome/browser/dom_ui/dom_ui_factory.cc @@ -251,8 +251,9 @@ bool DOMUIFactory::IsURLAcceptableForDOMUI(Profile* profile, const GURL& url) { // It's possible to load about:blank in a DOM UI renderer. // See http://crbug.com/42547 url.spec() == chrome::kAboutBlankURL || - // about:crash, about:hang, and about:shorthang are allowed. + // about:crash, about:kill, about:hang, and about:shorthang are allowed. url.spec() == chrome::kAboutCrashURL || + url.spec() == chrome::kAboutKillURL || url.spec() == chrome::kAboutHangURL || url.spec() == chrome::kAboutShorthangURL; } diff --git a/chrome/browser/gtk/sad_tab_gtk.cc b/chrome/browser/gtk/sad_tab_gtk.cc index 80612f7..aeae7d8 100644 --- a/chrome/browser/gtk/sad_tab_gtk.cc +++ b/chrome/browser/gtk/sad_tab_gtk.cc @@ -19,8 +19,13 @@ namespace { -// Background color of the content (a grayish blue). -const GdkColor kBackgroundColor = GDK_COLOR_RGB(35, 48, 64); +// Background color of the content (a grayish blue) for a crashed tab. +const GdkColor kCrashedBackgroundColor = GDK_COLOR_RGB(35, 48, 64); + +// Background color of the content (a grayish purple) for a killed +// tab. TODO(gspencer): update this for the "real" color when the UI +// team provides one. See http://crosbug.com/10711 +const GdkColor kKilledBackgroundColor = GDK_COLOR_RGB(57, 48, 88); // Construct a centered GtkLabel with a white foreground. // |format| is a printf-style format containing a %s; @@ -44,13 +49,17 @@ GtkWidget* MakeWhiteMarkupLabel(const char* format, const std::string& str) { } // namespace -SadTabGtk::SadTabGtk(TabContents* tab_contents) - : tab_contents_(tab_contents) { +SadTabGtk::SadTabGtk(TabContents* tab_contents, Kind kind) + : tab_contents_(tab_contents), + kind_(kind) { DCHECK(tab_contents_); // Use an event box to get the background painting correctly. event_box_.Own(gtk_event_box_new()); - gtk_widget_modify_bg(event_box_.get(), GTK_STATE_NORMAL, &kBackgroundColor); + gtk_widget_modify_bg(event_box_.get(), GTK_STATE_NORMAL, + kind == CRASHED ? + &kCrashedBackgroundColor : + &kKilledBackgroundColor); // Allow ourselves to be resized arbitrarily small. gtk_widget_set_size_request(event_box_.get(), 0, 0); @@ -63,7 +72,9 @@ SadTabGtk::SadTabGtk(TabContents* tab_contents) // Add center-aligned image. GtkWidget* image = gtk_image_new_from_pixbuf( - ResourceBundle::GetSharedInstance().GetPixbufNamed(IDR_SAD_TAB)); + ResourceBundle::GetSharedInstance().GetPixbufNamed(kind == CRASHED ? + IDR_SAD_TAB : + IDR_KILLED_TAB)); gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.5); gtk_box_pack_start(GTK_BOX(vbox), image, FALSE, FALSE, 0); @@ -75,7 +86,9 @@ SadTabGtk::SadTabGtk(TabContents* tab_contents) // Add center-aligned title. GtkWidget* title = MakeWhiteMarkupLabel( "<span size=\"larger\" style=\"normal\"><b>%s</b></span>", - l10n_util::GetStringUTF8(IDS_SAD_TAB_TITLE)); + l10n_util::GetStringUTF8(kind == CRASHED ? + IDS_SAD_TAB_TITLE : + IDS_KILLED_TAB_TITLE)); gtk_box_pack_start(GTK_BOX(vbox), title, FALSE, FALSE, 0); // Add spacer between title and message. @@ -83,9 +96,11 @@ SadTabGtk::SadTabGtk(TabContents* tab_contents) gtk_box_pack_start(GTK_BOX(vbox), spacer, FALSE, FALSE, 0); // Add center-aligned message. - GtkWidget* message = - MakeWhiteMarkupLabel("<span style=\"normal\">%s</span>", - l10n_util::GetStringUTF8(IDS_SAD_TAB_MESSAGE)); + GtkWidget* message = MakeWhiteMarkupLabel( + "<span style=\"normal\">%s</span>", + l10n_util::GetStringUTF8(kind == CRASHED ? + IDS_SAD_TAB_MESSAGE : + IDS_KILLED_TAB_MESSAGE)); gtk_label_set_line_wrap(GTK_LABEL(message), TRUE); gtk_box_pack_start(GTK_BOX(vbox), message, FALSE, FALSE, 0); @@ -115,7 +130,10 @@ SadTabGtk::~SadTabGtk() { void SadTabGtk::OnLinkButtonClick(GtkWidget* sender) { if (tab_contents_ != NULL) { GURL help_url = - google_util::AppendGoogleLocaleParam(GURL(chrome::kCrashReasonURL)); + google_util::AppendGoogleLocaleParam(GURL( + kind_ == CRASHED ? + chrome::kCrashReasonURL : + chrome::kKillReasonURL)); tab_contents_->OpenURL(help_url, GURL(), CURRENT_TAB, PageTransition::LINK); } } diff --git a/chrome/browser/gtk/sad_tab_gtk.h b/chrome/browser/gtk/sad_tab_gtk.h index 9c5489b..dafc835 100644 --- a/chrome/browser/gtk/sad_tab_gtk.h +++ b/chrome/browser/gtk/sad_tab_gtk.h @@ -15,7 +15,12 @@ class TabContents; class SadTabGtk { public: - explicit SadTabGtk(TabContents* tab_contents); + enum Kind { + CRASHED, // The tab crashed. Display the "Aw, Snap!" page. + KILLED // The tab was killed. Display the killed tab page. + }; + + explicit SadTabGtk(TabContents* tab_contents, Kind kind); virtual ~SadTabGtk(); GtkWidget* widget() const { return event_box_.get(); } @@ -27,6 +32,7 @@ class SadTabGtk { TabContents* tab_contents_; OwnedWidgetGtk event_box_; + Kind kind_; DISALLOW_COPY_AND_ASSIGN(SadTabGtk); }; diff --git a/chrome/browser/renderer_host/site_instance.cc b/chrome/browser/renderer_host/site_instance.cc index 31f20f5..8850c86 100644 --- a/chrome/browser/renderer_host/site_instance.cc +++ b/chrome/browser/renderer_host/site_instance.cc @@ -19,6 +19,7 @@ static bool IsURLSameAsAnySiteInstance(const GURL& url) { return false; return url.SchemeIs(chrome::kJavaScriptScheme) || url.spec() == chrome::kAboutCrashURL || + url.spec() == chrome::kAboutKillURL || url.spec() == chrome::kAboutHangURL || url.spec() == chrome::kAboutShorthangURL; } diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 4701265..b73ef97 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -2544,7 +2544,7 @@ void TabContents::RenderViewGone(RenderViewHost* rvh, // objects that are not in a browser (e.g., HTML dialogs) and thus are // visible do not flash a sad tab page. if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) - view_->OnTabCrashed(); + view_->OnTabCrashed(status, error_code); // Hide any visible hung renderer warning for this web contents' process. hung_renderer_dialog::HideForTabContents(this); diff --git a/chrome/browser/tab_contents/tab_contents_view.h b/chrome/browser/tab_contents/tab_contents_view.h index c6b9a61..ac37312 100644 --- a/chrome/browser/tab_contents/tab_contents_view.h +++ b/chrome/browser/tab_contents/tab_contents_view.h @@ -80,7 +80,8 @@ class TabContentsView : public RenderViewHostDelegate::View { // Used to notify the view that a tab has crashed so each platform can // prepare the sad tab. - virtual void OnTabCrashed() = 0; + virtual void OnTabCrashed(base::TerminationStatus status, + int error_code) = 0; // TODO(brettw) this is a hack. It's used in two places at the time of this // writing: (1) when render view hosts switch, we need to size the replaced diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc index dbd2797..4563251 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc @@ -203,9 +203,13 @@ void TabContentsViewGtk::SetPageTitle(const std::wstring& title) { gdk_window_set_title(content_view->window, WideToUTF8(title).c_str()); } -void TabContentsViewGtk::OnTabCrashed() { +void TabContentsViewGtk::OnTabCrashed(base::TerminationStatus status, + int error_code) { if (tab_contents() != NULL && !sad_tab_.get()) { - sad_tab_.reset(new SadTabGtk(tab_contents())); + sad_tab_.reset(new SadTabGtk( + tab_contents(), + status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ? + SadTabGtk::KILLED : SadTabGtk::CRASHED)); InsertIntoContentArea(sad_tab_->widget()); gtk_widget_show(sad_tab_->widget()); } diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.h b/chrome/browser/tab_contents/tab_contents_view_gtk.h index 9a016a1..b7f218b 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.h +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.h @@ -53,7 +53,8 @@ class TabContentsViewGtk : public TabContentsView, virtual gfx::NativeWindow GetTopLevelNativeWindow() const; virtual void GetContainerBounds(gfx::Rect* out) const; virtual void SetPageTitle(const std::wstring& title); - virtual void OnTabCrashed(); + virtual void OnTabCrashed(base::TerminationStatus status, + int error_code); virtual void SizeContents(const gfx::Size& size); virtual void Focus(); virtual void SetInitialFocus(); diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.h b/chrome/browser/tab_contents/tab_contents_view_mac.h index 1aab6b84..e1aec6b 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.h +++ b/chrome/browser/tab_contents/tab_contents_view_mac.h @@ -60,7 +60,8 @@ class TabContentsViewMac : public TabContentsView, virtual void GetContainerBounds(gfx::Rect* out) const; virtual void RenderViewCreated(RenderViewHost* host); virtual void SetPageTitle(const std::wstring& title); - virtual void OnTabCrashed(); + virtual void OnTabCrashed(base::TerminationStatus status, + int error_code); virtual void SizeContents(const gfx::Size& size); virtual void Focus(); virtual void SetInitialFocus(); diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index 8d810dd..61cf26b 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -175,7 +175,8 @@ void TabContentsViewMac::SetPageTitle(const std::wstring& title) { // Meaningless on the Mac; widgets don't have a "title" attribute } -void TabContentsViewMac::OnTabCrashed() { +void TabContentsViewMac::OnTabCrashed(base::TerminationStatus /* status */, + int /* error_code */) { if (!sad_tab_.get()) { TabContents* contents = tab_contents(); DCHECK(contents); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 3ba24b0..8334180 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -2626,6 +2626,16 @@ void Browser::TabSelectedAt(TabContentsWrapper* old_contents, bool user_gesture) { DCHECK(old_contents != new_contents); + // On some platforms we want to automatically reload tabs that are + // killed when the user selects them. + if (user_gesture && new_contents->tab_contents()->crashed_status() == + base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { + const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); + if (parsed_command_line.HasSwitch(switches::kReloadKilledTabs)) + Reload(CURRENT_TAB); + return; + } + // If we have any update pending, do it now. if (!chrome_updater_factory_.empty() && old_contents) ProcessPendingUIUpdates(); diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc index 62bbfd0..f0f4639 100644 --- a/chrome/browser/ui/views/sad_tab_view.cc +++ b/chrome/browser/ui/views/sad_tab_view.cc @@ -28,8 +28,12 @@ static const float kMessageSize = 0.65f; static const SkColor kTitleColor = SK_ColorWHITE; static const SkColor kMessageColor = SK_ColorWHITE; static const SkColor kLinkColor = SK_ColorWHITE; -static const SkColor kBackgroundColor = SkColorSetRGB(35, 48, 64); -static const SkColor kBackgroundEndColor = SkColorSetRGB(35, 48, 64); +static const SkColor kCrashBackgroundColor = SkColorSetRGB(35, 48, 64); +static const SkColor kCrashBackgroundEndColor = SkColorSetRGB(35, 48, 64); +// TODO(gspencer): update these colors when the UI team has picked +// official versions. See http://crosbug.com/10711. +static const SkColor kKillBackgroundColor = SkColorSetRGB(57, 48, 88); +static const SkColor kKillBackgroundEndColor = SkColorSetRGB(57, 48, 88); // Font size correction. #if defined(CROS_FONTS_USING_BCI) @@ -48,12 +52,13 @@ std::wstring SadTabView::title_; std::wstring SadTabView::message_; int SadTabView::title_width_; -SadTabView::SadTabView(TabContents* tab_contents) +SadTabView::SadTabView(TabContents* tab_contents, Kind kind) : tab_contents_(tab_contents), - learn_more_link_(NULL) { + learn_more_link_(NULL), + kind_(kind) { DCHECK(tab_contents); - InitClass(); + InitClass(kind); if (tab_contents != NULL) { learn_more_link_ = @@ -67,9 +72,13 @@ SadTabView::SadTabView(TabContents* tab_contents) void SadTabView::Paint(gfx::Canvas* canvas) { SkPaint paint; - SkSafeUnref(paint.setShader(gfx::CreateGradientShader(0, height(), - kBackgroundColor, - kBackgroundEndColor))); + SkSafeUnref(paint.setShader( + gfx::CreateGradientShader( + 0, + height(), + kind_ == CRASHED ? kCrashBackgroundColor : kKillBackgroundColor, + kind_ == CRASHED ? + kCrashBackgroundEndColor : kKillBackgroundEndColor))); paint.setStyle(SkPaint::kFill_Style); canvas->AsCanvasSkia()->drawRectCoords( 0, 0, SkIntToScalar(width()), SkIntToScalar(height()), paint); @@ -124,7 +133,9 @@ void SadTabView::Layout() { void SadTabView::LinkActivated(views::Link* source, int event_flags) { if (tab_contents_ != NULL && source == learn_more_link_) { GURL help_url = - google_util::AppendGoogleLocaleParam(GURL(chrome::kCrashReasonURL)); + google_util::AppendGoogleLocaleParam(GURL(kind_ == CRASHED ? + chrome::kCrashReasonURL : + chrome::kKillReasonURL)); WindowOpenDisposition disposition(CURRENT_TAB); #if defined(OS_CHROMEOS) if (tab_contents_->delegate() && @@ -139,7 +150,7 @@ void SadTabView::LinkActivated(views::Link* source, int event_flags) { } // static -void SadTabView::InitClass() { +void SadTabView::InitClass(Kind kind) { static bool initialized = false; if (!initialized) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); @@ -148,11 +159,14 @@ void SadTabView::InitClass() { gfx::Font::BOLD)); message_font_ = new gfx::Font( rb.GetFont(ResourceBundle::BaseFont).DeriveFont(kMessageFontSizeDelta)); - sad_tab_bitmap_ = rb.GetBitmapNamed(IDR_SAD_TAB); + sad_tab_bitmap_ = rb.GetBitmapNamed( + kind == CRASHED ? IDR_SAD_TAB : IDR_KILLED_TAB); - title_ = UTF16ToWide(l10n_util::GetStringUTF16(IDS_SAD_TAB_TITLE)); + title_ = UTF16ToWide(l10n_util::GetStringUTF16( + kind == CRASHED ? IDS_SAD_TAB_TITLE : IDS_KILLED_TAB_TITLE)); title_width_ = title_font_->GetStringWidth(WideToUTF16Hack(title_)); - message_ = UTF16ToWide(l10n_util::GetStringUTF16(IDS_SAD_TAB_MESSAGE)); + message_ = UTF16ToWide(l10n_util::GetStringUTF16( + kind == CRASHED ? IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE)); initialized = true; } diff --git a/chrome/browser/ui/views/sad_tab_view.h b/chrome/browser/ui/views/sad_tab_view.h index 22c088a..ce5ccbe 100644 --- a/chrome/browser/ui/views/sad_tab_view.h +++ b/chrome/browser/ui/views/sad_tab_view.h @@ -25,7 +25,12 @@ class TabContents; class SadTabView : public views::View, public views::LinkController { public: - explicit SadTabView(TabContents* tab_contents); + enum Kind { + CRASHED, // The tab crashed. Display the "Aw, Snap!" page. + KILLED // The tab was killed. Display the killed tab page. + }; + + explicit SadTabView(TabContents* tab_contents, Kind kind); virtual ~SadTabView() {} // Overridden from views::View: @@ -36,7 +41,7 @@ class SadTabView : public views::View, virtual void LinkActivated(views::Link* source, int event_flags); private: - static void InitClass(); + static void InitClass(Kind kind); // Assorted resources for display. static SkBitmap* sad_tab_bitmap_; @@ -56,6 +61,8 @@ class SadTabView : public views::View, gfx::Rect message_bounds_; gfx::Rect link_bounds_; + Kind kind_; + DISALLOW_COPY_AND_ASSIGN(SadTabView); }; diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc index 4d27e95..490c7a8 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc @@ -239,7 +239,8 @@ void TabContentsViewGtk::SetPageTitle(const std::wstring& title) { gdk_window_set_title(content_view->window, WideToUTF8(title).c_str()); } -void TabContentsViewGtk::OnTabCrashed() { +void TabContentsViewGtk::OnTabCrashed(base::TerminationStatus /* status */, + int /* error_code */) { } void TabContentsViewGtk::SizeContents(const gfx::Size& size) { @@ -394,7 +395,12 @@ gboolean TabContentsViewGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { if (tab_contents()->render_view_host() && !tab_contents()->render_view_host()->IsRenderViewLive()) { if (sad_tab_ == NULL) { - sad_tab_ = new SadTabView(tab_contents()); + base::TerminationStatus status = + tab_contents()->render_view_host()->render_view_termination_status(); + SadTabView::Kind kind = + status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ? + SadTabView::KILLED : SadTabView::CRASHED; + sad_tab_ = new SadTabView(tab_contents(), kind); SetContentsView(sad_tab_); } gfx::Rect bounds; diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.h b/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.h index 5352aaf4..6efe01c 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.h +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.h @@ -56,7 +56,8 @@ class TabContentsViewGtk : public TabContentsView, virtual gfx::NativeWindow GetTopLevelNativeWindow() const; virtual void GetContainerBounds(gfx::Rect* out) const; virtual void SetPageTitle(const std::wstring& title); - virtual void OnTabCrashed(); + virtual void OnTabCrashed(base::TerminationStatus status, + int error_code); virtual void SizeContents(const gfx::Size& size); virtual void Focus(); virtual void SetInitialFocus(); diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc index ec48536..f6c2e97 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc @@ -130,11 +130,15 @@ void TabContentsViewViews::SetPageTitle(const std::wstring& title) { // TODO(anicolao): figure out if there's anything useful to do here } -void TabContentsViewViews::OnTabCrashed() { +void TabContentsViewViews::OnTabCrashed(base::TerminationStatus status, + int /* error_code */) { if (sad_tab_ != NULL) return; - sad_tab_.reset(new SadTabView(tab_contents())); + sad_tab_.reset(new SadTabView( + tab_contents(), + status == TERMINATION_STATUS_PROCESS_WAS_KILLED ? + SadTabView::KILLED : SadTabView::CRASHED)); RemoveAllChildViews(true); AddChildView(sad_tab_.get()); Layout(); diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h index ab0e666..3b716a1 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ -#define CHROME_BROWSER_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ +#ifndef CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ +#define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ #pragma once #include <vector> @@ -52,7 +52,8 @@ class TabContentsViewViews : public TabContentsView, public views::View { virtual gfx::NativeWindow GetTopLevelNativeWindow() const; virtual void GetContainerBounds(gfx::Rect* out) const; virtual void SetPageTitle(const std::wstring& title); - virtual void OnTabCrashed(); + virtual void OnTabCrashed(base::TerminationStatus status, + int error_code); virtual void SizeContents(const gfx::Size& size); virtual void Focus(); virtual void SetInitialFocus(); @@ -128,4 +129,4 @@ class TabContentsViewViews : public TabContentsView, public views::View { DISALLOW_COPY_AND_ASSIGN(TabContentsViewViews); }; -#endif // CHROME_BROWSER_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ +#endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_TAB_CONTENTS_VIEW_VIEWS_H_ diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_win.cc index ca93676..52ad4ba 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_win.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_win.cc @@ -155,7 +155,8 @@ void TabContentsViewWin::SetPageTitle(const std::wstring& title) { } } -void TabContentsViewWin::OnTabCrashed() { +void TabContentsViewWin::OnTabCrashed(base::TerminationStatus /* status */, + int /* error_code */) { // Force an invalidation to render sad tab. We will notice we crashed when we // paint. // Note that it's possible to get this message after the window was destroyed. @@ -398,7 +399,12 @@ void TabContentsViewWin::OnPaint(HDC junk_dc) { if (tab_contents()->render_view_host() && !tab_contents()->render_view_host()->IsRenderViewLive()) { if (sad_tab_ == NULL) { - sad_tab_ = new SadTabView(tab_contents()); + base::TerminationStatus status = + tab_contents()->render_view_host()->render_view_termination_status(); + SadTabView::Kind kind = + status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ? + SadTabView::KILLED : SadTabView::CRASHED; + sad_tab_ = new SadTabView(tab_contents(), kind); SetContentsView(sad_tab_); } CRect cr; diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_win.h b/chrome/browser/ui/views/tab_contents/tab_contents_view_win.h index fcfbfe4..27a1eb4 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_win.h +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_win.h @@ -48,7 +48,8 @@ class TabContentsViewWin : public TabContentsView, virtual gfx::NativeWindow GetTopLevelNativeWindow() const; virtual void GetContainerBounds(gfx::Rect* out) const; virtual void SetPageTitle(const std::wstring& title); - virtual void OnTabCrashed(); + virtual void OnTabCrashed(base::TerminationStatus status, + int error_code); virtual void SizeContents(const gfx::Size& size); virtual void Focus(); virtual void SetInitialFocus(); diff --git a/chrome/common/about_handler.cc b/chrome/common/about_handler.cc index d2121b8..6e3e152 100644 --- a/chrome/common/about_handler.cc +++ b/chrome/common/about_handler.cc @@ -12,6 +12,7 @@ namespace chrome_about_handler { // chrome/renderer/about_handler.cc. const char* const about_urls[] = { chrome::kAboutCrashURL, + chrome::kAboutKillURL, chrome::kAboutHangURL, chrome::kAboutShorthangURL, NULL, diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 9fee02f..9297740 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -992,6 +992,9 @@ const char kRecordMode[] = "record-mode"; // Register pepper plugins that should be loaded into the renderer. const char kRegisterPepperPlugins[] = "register-pepper-plugins"; +// Reload pages that have been killed when they are next focused by the user. +const char kReloadKilledTabs[] = "reload-killed-tabs"; + // Enable remote debug over HTTP on the specified port. const char kRemoteDebuggingPort[] = "remote-debugging-port"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index cae8fcd..1c3e1ea 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -279,6 +279,7 @@ extern const char kProxyServer[]; extern const char kPurgeMemoryButton[]; extern const char kRecordMode[]; extern const char kRegisterPepperPlugins[]; +extern const char kReloadKilledTabs[]; extern const char kRemoteDebuggingPort[]; extern const char kRemoteShellPort[]; extern const char kRendererAssertTest[]; diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index e4c56fc..844cb32 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -51,6 +51,7 @@ const char kAboutBlankURL[] = "about:blank"; const char kAboutCacheURL[] = "about:cache"; const char kAboutConflicts[] = "about:conflicts"; const char kAboutCrashURL[] = "about:crash"; +const char kAboutKillURL[] = "about:kill"; const char kAboutCreditsURL[] = "about:credits"; const char kAboutDNSURL[] = "about:dns"; const char kAboutFlagsURL[] = "about:flags"; @@ -204,6 +205,15 @@ const char kCrashReasonURL[] = "http://www.google.com/support/chrome/bin/answer.py?answer=95669"; #endif +// TODO: These are currently placeholders that point to the crash +// docs. See bug http://crosbug.com/10711 +const char kKillReasonURL[] = +#if defined(OS_CHROMEOS) + "http://www.google.com/support/chromeos/bin/answer.py?answer=1047340"; +#else + "http://www.google.com/support/chrome/bin/answer.py?answer=95669"; +#endif + const char kPrivacyLearnMoreURL[] = #if defined(OS_CHROMEOS) "http://www.google.com/support/chromeos/bin/answer.py?answer=1047334"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 50d1a5c..532f230 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -44,6 +44,7 @@ extern const char kAboutBrowserCrash[]; extern const char kAboutConflicts[]; extern const char kAboutCacheURL[]; extern const char kAboutCrashURL[]; +extern const char kAboutKillURL[]; extern const char kAboutCreditsURL[]; extern const char kAboutDNSURL[]; extern const char kAboutFlagsURL[]; @@ -188,6 +189,9 @@ extern const char kPageInfoHelpCenterURL[]; // "Learn more" URL for "Aw snap" page. extern const char kCrashReasonURL[]; +// "Learn more" URL for killed tab page. +extern const char kKillReasonURL[]; + // "Learn more" URL for the Privacy section under Options. extern const char kPrivacyLearnMoreURL[]; diff --git a/chrome/renderer/about_handler.cc b/chrome/renderer/about_handler.cc index f53302b..e748aa1 100644 --- a/chrome/renderer/about_handler.cc +++ b/chrome/renderer/about_handler.cc @@ -4,6 +4,7 @@ #include "chrome/renderer/about_handler.h" +#include "base/process_util.h" #include "base/threading/platform_thread.h" #include "chrome/common/about_handler.h" #include "googleurl/src/gurl.h" @@ -14,6 +15,7 @@ typedef void (*AboutHandlerFuncPtr)(); // chrome/common/about_handler.cc. static const AboutHandlerFuncPtr about_urls_handlers[] = { AboutHandler::AboutCrash, + AboutHandler::AboutKill, AboutHandler::AboutHang, AboutHandler::AboutShortHang, NULL, @@ -44,6 +46,11 @@ void AboutHandler::AboutCrash() { } // static +void AboutHandler::AboutKill() { + base::KillProcess(base::GetCurrentProcessHandle(), 1, false); +} + +// static void AboutHandler::AboutHang() { for (;;) { base::PlatformThread::Sleep(1000); diff --git a/chrome/renderer/about_handler.h b/chrome/renderer/about_handler.h index ee55f49..dea3c5b 100644 --- a/chrome/renderer/about_handler.h +++ b/chrome/renderer/about_handler.h @@ -24,6 +24,9 @@ class AboutHandler { // Induces a renderer crash. static void AboutCrash(); + // Induces a renderer kill. + static void AboutKill(); + // Induces a renderer hang. static void AboutHang(); |