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

Side by Side Diff: chrome/browser/ui/sad_tab_helper.cc

Issue 543663002: Componentize sad_tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix url_constants.cc Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/sad_tab_helper.h ('k') | chrome/browser/ui/sad_tab_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/sad_tab_helper.h"
6
7 #include "base/logging.h"
8 #include "chrome/browser/browser_shutdown.h"
9 #include "chrome/browser/ui/sad_tab.h"
10 #include "content/public/browser/web_contents.h"
11
12 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SadTabHelper);
13
14 SadTabHelper::~SadTabHelper() {
15 }
16
17 SadTabHelper::SadTabHelper(content::WebContents* web_contents)
18 : content::WebContentsObserver(web_contents) {
19 }
20
21 void SadTabHelper::RenderViewReady() {
22 if (sad_tab_) {
23 sad_tab_->Close();
24 sad_tab_.reset();
25 }
26 }
27
28 void SadTabHelper::RenderProcessGone(base::TerminationStatus status) {
29 // Only show the sad tab if we're not in browser shutdown, so that WebContents
30 // objects that are not in a browser (e.g., HTML dialogs) and thus are
31 // visible do not flash a sad tab page.
32 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID)
33 return;
34
35 if (sad_tab_)
36 return;
37
38 if (chrome::SadTab::ShouldShow(status))
39 InstallSadTab(status);
40 }
41
42 void SadTabHelper::InstallSadTab(base::TerminationStatus status) {
43 chrome::SadTabKind kind =
44 (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) ?
45 chrome::SAD_TAB_KIND_KILLED : chrome::SAD_TAB_KIND_CRASHED;
46 sad_tab_.reset(chrome::SadTab::Create(web_contents(), kind));
47 sad_tab_->Show();
48 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sad_tab_helper.h ('k') | chrome/browser/ui/sad_tab_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698