Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / sad_tab_helper.cc
blob8ad27ece6ab4acc5cd3fcd8e29f05fc607a56468
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.
5 #include "chrome/browser/ui/sad_tab_helper.h"
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 #include "content/public/browser/web_contents_view.h"
13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SadTabHelper);
15 SadTabHelper::~SadTabHelper() {
18 SadTabHelper::SadTabHelper(content::WebContents* web_contents)
19 : content::WebContentsObserver(web_contents) {
22 void SadTabHelper::RenderViewReady() {
23 if (sad_tab_) {
24 sad_tab_->Close();
25 sad_tab_.reset();
29 void SadTabHelper::RenderProcessGone(base::TerminationStatus status) {
30 // Only show the sad tab if we're not in browser shutdown, so that WebContents
31 // objects that are not in a browser (e.g., HTML dialogs) and thus are
32 // visible do not flash a sad tab page.
33 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID)
34 return;
36 if (sad_tab_)
37 return;
39 if (chrome::SadTab::ShouldShow(status))
40 InstallSadTab(status);
43 void SadTabHelper::InstallSadTab(base::TerminationStatus status) {
44 chrome::SadTabKind kind =
45 (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) ?
46 chrome::SAD_TAB_KIND_KILLED : chrome::SAD_TAB_KIND_CRASHED;
47 sad_tab_.reset(chrome::SadTab::Create(web_contents(), kind));
48 sad_tab_->Show();