OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
12 #include "ui/views/controls/link_listener.h" | 12 #include "ui/views/controls/link_listener.h" |
13 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
14 | 14 |
15 class TabContents; | 15 namespace content { |
| 16 class WebContents; |
| 17 } |
16 | 18 |
17 namespace gfx { | 19 namespace gfx { |
18 class Font; | 20 class Font; |
19 } | 21 } |
20 | 22 |
21 namespace views { | 23 namespace views { |
22 class Label; | 24 class Label; |
23 class TextButton; | 25 class TextButton; |
24 } | 26 } |
25 | 27 |
26 /////////////////////////////////////////////////////////////////////////////// | 28 /////////////////////////////////////////////////////////////////////////////// |
27 // | 29 // |
28 // SadTabView | 30 // SadTabView |
29 // | 31 // |
30 // A views::View subclass used to render the presentation of the crashed | 32 // A views::View subclass used to render the presentation of the crashed |
31 // "sad tab" in the browser window when a renderer is destroyed unnaturally. | 33 // "sad tab" in the browser window when a renderer is destroyed unnaturally. |
32 // | 34 // |
33 /////////////////////////////////////////////////////////////////////////////// | 35 /////////////////////////////////////////////////////////////////////////////// |
34 class SadTabView : public views::View, | 36 class SadTabView : public views::View, |
35 public views::LinkListener, | 37 public views::LinkListener, |
36 public views::ButtonListener { | 38 public views::ButtonListener { |
37 public: | 39 public: |
38 // NOTE: Do not remove or reorder the elements in this enum, and only add new | 40 // NOTE: Do not remove or reorder the elements in this enum, and only add new |
39 // items at the end. We depend on these specific values in a histogram. | 41 // items at the end. We depend on these specific values in a histogram. |
40 enum Kind { | 42 enum Kind { |
41 CRASHED = 0, // Tab crashed. Display the "Aw, Snap!" page. | 43 CRASHED = 0, // Tab crashed. Display the "Aw, Snap!" page. |
42 KILLED // Tab killed. Display the "He's dead, Jim!" tab page. | 44 KILLED // Tab killed. Display the "He's dead, Jim!" tab page. |
43 }; | 45 }; |
44 | 46 |
45 SadTabView(TabContents* tab_contents, Kind kind); | 47 SadTabView(content::WebContents* web_contents, Kind kind); |
46 virtual ~SadTabView(); | 48 virtual ~SadTabView(); |
47 | 49 |
48 // Overridden from views::View: | 50 // Overridden from views::View: |
49 virtual void Layout() OVERRIDE; | 51 virtual void Layout() OVERRIDE; |
50 | 52 |
51 // Overridden from views::LinkListener: | 53 // Overridden from views::LinkListener: |
52 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 54 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
53 | 55 |
54 // Overridden from views::ButtonListener: | 56 // Overridden from views::ButtonListener: |
55 virtual void ButtonPressed(views::Button* source, | 57 virtual void ButtonPressed(views::Button* source, |
56 const views::Event& event) OVERRIDE; | 58 const views::Event& event) OVERRIDE; |
57 | 59 |
58 protected: | 60 protected: |
59 // Overridden from views::View: | 61 // Overridden from views::View: |
60 virtual void ViewHierarchyChanged(bool is_add, | 62 virtual void ViewHierarchyChanged(bool is_add, |
61 views::View* parent, | 63 views::View* parent, |
62 views::View* child) OVERRIDE; | 64 views::View* child) OVERRIDE; |
63 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 65 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
64 | 66 |
65 private: | 67 private: |
66 views::Label* CreateLabel(const string16& text); | 68 views::Label* CreateLabel(const string16& text); |
67 views::Link* CreateLink(const string16& text); | 69 views::Link* CreateLink(const string16& text); |
68 | 70 |
69 TabContents* tab_contents_; | 71 content::WebContents* web_contents_; |
70 Kind kind_; | 72 Kind kind_; |
71 bool painted_; | 73 bool painted_; |
72 const gfx::Font& base_font_; | 74 const gfx::Font& base_font_; |
73 views::Label* message_; | 75 views::Label* message_; |
74 views::Link* help_link_; | 76 views::Link* help_link_; |
75 views::Link* feedback_link_; | 77 views::Link* feedback_link_; |
76 views::TextButton* reload_button_; | 78 views::TextButton* reload_button_; |
77 | 79 |
78 DISALLOW_COPY_AND_ASSIGN(SadTabView); | 80 DISALLOW_COPY_AND_ASSIGN(SadTabView); |
79 }; | 81 }; |
80 | 82 |
81 #endif // CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H__ | 83 #endif // CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H__ |
OLD | NEW |