| OLD | NEW |
| 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/browser/ui/sad_tab_helper.h" | 5 #include "chrome/browser/ui/sad_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/browser_shutdown.h" | 8 #include "chrome/browser/browser_shutdown.h" |
| 9 #include "chrome/browser/ui/sad_tab.h" | 9 #include "chrome/browser/ui/sad_tab.h" |
| 10 #include "content/public/browser/notification_source.h" | 10 #include "content/public/browser/notification_source.h" |
| 11 #include "content/public/browser/notification_types.h" | 11 #include "content/public/browser/notification_types.h" |
| 12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/browser/web_contents_view.h" | 13 #include "content/public/browser/web_contents_view.h" |
| 14 | 14 |
| 15 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SadTabHelper); | 15 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SadTabHelper); |
| 16 | 16 |
| 17 SadTabHelper::~SadTabHelper() { | 17 SadTabHelper::~SadTabHelper() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 SadTabHelper::SadTabHelper(content::WebContents* web_contents) | 20 SadTabHelper::SadTabHelper(content::WebContents* web_contents) |
| 21 : content::WebContentsObserver(web_contents) { | 21 : content::WebContentsObserver(web_contents) { |
| 22 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | 22 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, |
| 23 content::Source<content::WebContents>(web_contents)); | 23 content::Source<content::WebContents>(web_contents)); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void SadTabHelper::RenderViewGone(base::TerminationStatus status) { | 26 void SadTabHelper::RenderProcessGone(base::TerminationStatus status) { |
| 27 // Only show the sad tab if we're not in browser shutdown, so that WebContents | 27 // Only show the sad tab if we're not in browser shutdown, so that WebContents |
| 28 // objects that are not in a browser (e.g., HTML dialogs) and thus are | 28 // objects that are not in a browser (e.g., HTML dialogs) and thus are |
| 29 // visible do not flash a sad tab page. | 29 // visible do not flash a sad tab page. |
| 30 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) | 30 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) |
| 31 return; | 31 return; |
| 32 | 32 |
| 33 if (sad_tab_) | 33 if (sad_tab_) |
| 34 return; | 34 return; |
| 35 | 35 |
| 36 if (chrome::SadTab::ShouldShow(status)) | 36 if (chrome::SadTab::ShouldShow(status)) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 void SadTabHelper::InstallSadTab(base::TerminationStatus status) { | 50 void SadTabHelper::InstallSadTab(base::TerminationStatus status) { |
| 51 chrome::SadTabKind kind = | 51 chrome::SadTabKind kind = |
| 52 (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) ? | 52 (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) ? |
| 53 chrome::SAD_TAB_KIND_KILLED : chrome::SAD_TAB_KIND_CRASHED; | 53 chrome::SAD_TAB_KIND_KILLED : chrome::SAD_TAB_KIND_CRASHED; |
| 54 sad_tab_.reset(chrome::SadTab::Create(web_contents(), kind)); | 54 sad_tab_.reset(chrome::SadTab::Create(web_contents(), kind)); |
| 55 sad_tab_->Show(); | 55 sad_tab_->Show(); |
| 56 } | 56 } |
| OLD | NEW |