1// Copyright (c) 2006-2008 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#ifndef CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H_
6#define CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H_
7#pragma once
8
9#include "base/basictypes.h"
10#include "ui/gfx/font.h"
11#include "views/controls/link.h"
12#include "views/view.h"
13
14class SkBitmap;
15class TabContents;
16
17///////////////////////////////////////////////////////////////////////////////
18//
19// SadTabView
20//
21//  A views::View subclass used to render the presentation of the crashed
22//  "sad tab" in the browser window when a renderer is destroyed unnaturally.
23//
24///////////////////////////////////////////////////////////////////////////////
25class SadTabView : public views::View,
26                   public views::LinkController {
27 public:
28  enum Kind {
29    CRASHED,  // The tab crashed.  Display the "Aw, Snap!" page.
30    KILLED    // The tab was killed.  Display the killed tab page.
31  };
32
33  explicit SadTabView(TabContents* tab_contents, Kind kind);
34  virtual ~SadTabView();
35
36  // Overridden from views::View:
37  virtual void OnPaint(gfx::Canvas* canvas);
38  virtual void Layout();
39
40  // Overridden from views::LinkController:
41  virtual void LinkActivated(views::Link* source, int event_flags);
42
43 private:
44  static void InitClass(Kind kind);
45
46  // Assorted resources for display.
47  static SkBitmap* sad_tab_bitmap_;
48  static gfx::Font* title_font_;
49  static gfx::Font* message_font_;
50  static std::wstring title_;
51  static std::wstring message_;
52  static int title_width_;
53
54  TabContents* tab_contents_;
55  views::Link* learn_more_link_;
56
57  // Regions within the display for different components, populated by
58  // Layout().
59  gfx::Rect icon_bounds_;
60  gfx::Rect title_bounds_;
61  gfx::Rect message_bounds_;
62  gfx::Rect link_bounds_;
63
64  Kind kind_;
65
66  DISALLOW_COPY_AND_ASSIGN(SadTabView);
67};
68
69#endif  // CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H__
70