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 "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/browser_shutdown.h" | 9 #include "chrome/browser/browser_shutdown.h" |
10 #include "chrome/browser/ui/sad_tab.h" | 10 #include "chrome/browser/ui/sad_tab.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 SadTabHelper::~SadTabHelper() { | 36 SadTabHelper::~SadTabHelper() { |
37 } | 37 } |
38 | 38 |
39 SadTabHelper::SadTabHelper(content::WebContents* web_contents) | 39 SadTabHelper::SadTabHelper(content::WebContents* web_contents) |
40 : content::WebContentsObserver(web_contents) { | 40 : content::WebContentsObserver(web_contents) { |
41 } | 41 } |
42 | 42 |
43 void SadTabHelper::RenderViewReady() { | 43 void SadTabHelper::RenderViewReady() { |
44 if (sad_tab_) { | 44 sad_tab_.reset(); |
45 sad_tab_->Close(); | |
46 sad_tab_.reset(); | |
47 } | |
48 } | 45 } |
49 | 46 |
50 void SadTabHelper::RenderProcessGone(base::TerminationStatus status) { | 47 void SadTabHelper::RenderProcessGone(base::TerminationStatus status) { |
51 // Only show the sad tab if we're not in browser shutdown, so that WebContents | 48 // Only show the sad tab if we're not in browser shutdown, so that WebContents |
52 // objects that are not in a browser (e.g., HTML dialogs) and thus are | 49 // objects that are not in a browser (e.g., HTML dialogs) and thus are |
53 // visible do not flash a sad tab page. | 50 // visible do not flash a sad tab page. |
54 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) | 51 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) |
55 return; | 52 return; |
56 | 53 |
57 if (sad_tab_) | 54 if (sad_tab_) |
58 return; | 55 return; |
59 | 56 |
60 if (chrome::SadTab::ShouldShow(status)) | 57 if (chrome::SadTab::ShouldShow(status)) |
61 InstallSadTab(status); | 58 InstallSadTab(status); |
62 } | 59 } |
63 | 60 |
64 void SadTabHelper::InstallSadTab(base::TerminationStatus status) { | 61 void SadTabHelper::InstallSadTab(base::TerminationStatus status) { |
65 sad_tab_.reset(chrome::SadTab::Create( | 62 sad_tab_.reset(chrome::SadTab::Create( |
66 web_contents(), SadTabKindFromTerminationStatus(status))); | 63 web_contents(), SadTabKindFromTerminationStatus(status))); |
67 sad_tab_->Show(); | |
68 } | 64 } |
OLD | NEW |