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