| 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/string16.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "ui/gfx/rect.h" | |
| 12 #include "views/controls/link_listener.h" | 11 #include "views/controls/link_listener.h" |
| 13 #include "views/view.h" | 12 #include "views/view.h" |
| 14 | 13 |
| 15 class SkBitmap; | |
| 16 class TabContents; | 14 class TabContents; |
| 17 | 15 |
| 18 namespace gfx { | 16 namespace gfx { |
| 19 class Font; | 17 class Font; |
| 20 } | 18 } |
| 21 | 19 |
| 20 namespace views { |
| 21 class ImageView; |
| 22 class Label; |
| 23 } |
| 24 |
| 22 /////////////////////////////////////////////////////////////////////////////// | 25 /////////////////////////////////////////////////////////////////////////////// |
| 23 // | 26 // |
| 24 // SadTabView | 27 // SadTabView |
| 25 // | 28 // |
| 26 // A views::View subclass used to render the presentation of the crashed | 29 // A views::View subclass used to render the presentation of the crashed |
| 27 // "sad tab" in the browser window when a renderer is destroyed unnaturally. | 30 // "sad tab" in the browser window when a renderer is destroyed unnaturally. |
| 28 // | 31 // |
| 29 /////////////////////////////////////////////////////////////////////////////// | 32 /////////////////////////////////////////////////////////////////////////////// |
| 30 class SadTabView : public views::View, | 33 class SadTabView : public views::View, |
| 31 public views::LinkListener { | 34 public views::LinkListener { |
| 32 public: | 35 public: |
| 33 // NOTE: Do not remove or reorder the elements in this enum, and only add new | 36 // NOTE: Do not remove or reorder the elements in this enum, and only add new |
| 34 // items at the end. We depend on these specific values in a histogram. | 37 // items at the end. We depend on these specific values in a histogram. |
| 35 enum Kind { | 38 enum Kind { |
| 36 CRASHED = 0, // Tab crashed. Display the "Aw, Snap!" page. | 39 CRASHED = 0, // Tab crashed. Display the "Aw, Snap!" page. |
| 37 KILLED // Tab killed. Display the "He's dead, Jim!" tab page. | 40 KILLED // Tab killed. Display the "He's dead, Jim!" tab page. |
| 38 }; | 41 }; |
| 39 | 42 |
| 40 SadTabView(TabContents* tab_contents, Kind kind); | 43 SadTabView(TabContents* tab_contents, Kind kind); |
| 41 virtual ~SadTabView(); | 44 virtual ~SadTabView(); |
| 42 | 45 |
| 43 // Overridden from views::View: | 46 // Overridden from views::View: |
| 44 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
| 45 virtual void Layout() OVERRIDE; | 47 virtual void Layout() OVERRIDE; |
| 46 | 48 |
| 47 // Overridden from views::LinkListener: | 49 // Overridden from views::LinkListener: |
| 48 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 50 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| 49 | 51 |
| 52 protected: |
| 53 // Overridden from views::View: |
| 54 virtual void ViewHierarchyChanged(bool is_add, |
| 55 views::View* parent, |
| 56 views::View* child) OVERRIDE; |
| 57 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 58 |
| 50 private: | 59 private: |
| 51 // Assorted resources for display. | |
| 52 SkBitmap* sad_tab_bitmap_; | |
| 53 gfx::Font* title_font_; | |
| 54 gfx::Font* message_font_; | |
| 55 string16 title_; | |
| 56 string16 message_; | |
| 57 int title_width_; | |
| 58 | |
| 59 TabContents* tab_contents_; | 60 TabContents* tab_contents_; |
| 60 views::Link* learn_more_link_; | |
| 61 views::Link* feedback_link_; | |
| 62 | |
| 63 // Regions within the display for different components, populated by | |
| 64 // Layout(). | |
| 65 gfx::Rect icon_bounds_; | |
| 66 gfx::Rect title_bounds_; | |
| 67 gfx::Rect message_bounds_; | |
| 68 gfx::Rect learn_more_bounds_; | |
| 69 gfx::Rect feedback_bounds_; | |
| 70 | |
| 71 Kind kind_; | 61 Kind kind_; |
| 72 bool painted_; | 62 bool painted_; |
| 63 views::Label* message_; |
| 64 views::Link* help_link_; |
| 65 views::Link* feedback_link_; |
| 73 | 66 |
| 74 DISALLOW_COPY_AND_ASSIGN(SadTabView); | 67 DISALLOW_COPY_AND_ASSIGN(SadTabView); |
| 75 }; | 68 }; |
| 76 | 69 |
| 77 #endif // CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H__ | 70 #endif // CHROME_BROWSER_UI_VIEWS_SAD_TAB_VIEW_H__ |
| OLD | NEW |