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 | 7 |
8 #include "base/compiler_specific.h" | |
9 #include "base/macros.h" | |
10 #include "chrome/browser/ui/sad_tab.h" | 8 #include "chrome/browser/ui/sad_tab.h" |
11 #include "ui/views/controls/button/button.h" | 9 #include "ui/views/controls/button/button.h" |
12 #include "ui/views/controls/link_listener.h" | 10 #include "ui/views/controls/link_listener.h" |
13 #include "ui/views/controls/styled_label.h" | 11 #include "ui/views/controls/styled_label.h" |
14 #include "ui/views/controls/styled_label_listener.h" | 12 #include "ui/views/controls/styled_label_listener.h" |
15 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
16 | 14 |
17 namespace content { | 15 namespace content { |
18 class WebContents; | 16 class WebContents; |
19 } | 17 } |
20 | 18 |
21 namespace views { | 19 namespace views { |
22 class Label; | 20 class Label; |
23 class LabelButton; | 21 class LabelButton; |
24 } | 22 } |
25 | 23 |
26 /////////////////////////////////////////////////////////////////////////////// | 24 /////////////////////////////////////////////////////////////////////////////// |
27 // | 25 // |
28 // SadTabView | 26 // SadTabView |
29 // | 27 // |
30 // A views::View subclass used to render the presentation of the crashed | 28 // 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. | 29 // "sad tab" in the browser window when a renderer is destroyed unnaturally. |
32 // | 30 // |
33 /////////////////////////////////////////////////////////////////////////////// | 31 /////////////////////////////////////////////////////////////////////////////// |
34 class SadTabView : public chrome::SadTab, | 32 class SadTabView : public chrome::SadTab, |
35 public views::View, | 33 public views::View, |
36 public views::LinkListener, | 34 public views::LinkListener, |
37 public views::ButtonListener { | 35 public views::ButtonListener { |
38 public: | 36 public: |
39 // Tag to denote which type of action button is displayed. | |
40 enum ButtonTag { | |
41 SAD_TAB_BUTTON_FEEDBACK, | |
42 SAD_TAB_BUTTON_RELOAD, | |
43 }; | |
44 | |
45 SadTabView(content::WebContents* web_contents, chrome::SadTabKind kind); | 37 SadTabView(content::WebContents* web_contents, chrome::SadTabKind kind); |
46 ~SadTabView() override; | 38 ~SadTabView() override; |
47 | 39 |
48 // Overridden from views::View: | 40 // Overridden from views::View: |
49 void Layout() override; | 41 void Layout() override; |
50 | 42 |
51 // Overridden from views::LinkListener: | 43 // Overridden from views::LinkListener: |
52 void LinkClicked(views::Link* source, int event_flags) override; | 44 void LinkClicked(views::Link* source, int event_flags) override; |
53 | 45 |
54 // Overridden from views::ButtonListener: | 46 // Overridden from views::ButtonListener: |
55 void ButtonPressed(views::Button* source, const ui::Event& event) override; | 47 void ButtonPressed(views::Button* source, const ui::Event& event) override; |
56 | 48 |
57 protected: | 49 protected: |
58 // Overridden from views::View: | 50 // Overridden from views::View: |
59 void OnPaint(gfx::Canvas* canvas) override; | 51 void OnPaint(gfx::Canvas* canvas) override; |
60 | 52 |
61 private: | 53 private: |
62 // Overridden from chrome::SadTab: | |
63 void Show() override; | |
64 void Close() override; | |
65 | 54 |
66 views::Label* CreateLabel(const base::string16& text); | 55 views::Label* CreateLabel(const base::string16& text); |
67 views::Link* CreateLink(const base::string16& text, const SkColor& color); | 56 views::Link* CreateLink(const base::string16& text, const SkColor& color); |
68 | 57 |
69 content::WebContents* web_contents_; | 58 bool painted_ = false; |
70 chrome::SadTabKind kind_; | |
71 bool painted_; | |
72 views::Label* message_; | 59 views::Label* message_; |
73 views::Link* help_link_; | 60 views::Link* help_link_; |
74 views::LabelButton* action_button_; | 61 views::LabelButton* action_button_; |
75 views::Label* title_; | 62 views::Label* title_; |
76 views::StyledLabel* help_message_; | |
77 static int total_crashes_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(SadTabView); | |
80 }; | 63 }; |
81 | 64 |
82 #endif // CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H__ | 65 #endif // CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H__ |
OLD | NEW |