| 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_HUNG_RENDERER_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_HUNG_RENDERER_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_HUNG_RENDERER_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_HUNG_RENDERER_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/favicon/content/content_favicon_driver.h" | 9 #include "components/favicon/content/content_favicon_driver.h" |
| 10 #include "content/public/browser/web_contents_delegate.h" | 10 #include "content/public/browser/web_contents_delegate.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "content/public/browser/web_contents_unresponsive_state.h" | 12 #include "content/public/browser/web_contents_unresponsive_state.h" |
| 13 #include "ui/base/models/table_model.h" | 13 #include "ui/base/models/table_model.h" |
| 14 #include "ui/views/controls/button/button.h" | 14 #include "ui/views/controls/button/button.h" |
| 15 #include "ui/views/controls/table/table_grouper.h" | 15 #include "ui/views/controls/table/table_grouper.h" |
| 16 #include "ui/views/controls/table/table_view.h" | 16 #include "ui/views/controls/table/table_view.h" |
| 17 #include "ui/views/window/dialog_delegate.h" | 17 #include "ui/views/window/dialog_delegate.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class WebContents; | 20 class WebContents; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace views { | 23 namespace views { |
| 24 class Label; | 24 class Label; |
| 25 class LabelButton; | |
| 26 } | 25 } |
| 27 | 26 |
| 28 // Provides functionality to display information about a hung renderer. | 27 // Provides functionality to display information about a hung renderer. |
| 29 class HungPagesTableModel : public ui::TableModel, public views::TableGrouper { | 28 class HungPagesTableModel : public ui::TableModel, public views::TableGrouper { |
| 30 public: | 29 public: |
| 31 // The Delegate is notified any time a WebContents the model is listening to | 30 // The Delegate is notified any time a WebContents the model is listening to |
| 32 // is destroyed. | 31 // is destroyed. |
| 33 class Delegate { | 32 class Delegate { |
| 34 public: | 33 public: |
| 35 virtual void TabDestroyed() = 0; | 34 virtual void TabDestroyed() = 0; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 88 |
| 90 ui::TableModelObserver* observer_; | 89 ui::TableModelObserver* observer_; |
| 91 Delegate* delegate_; | 90 Delegate* delegate_; |
| 92 | 91 |
| 93 DISALLOW_COPY_AND_ASSIGN(HungPagesTableModel); | 92 DISALLOW_COPY_AND_ASSIGN(HungPagesTableModel); |
| 94 }; | 93 }; |
| 95 | 94 |
| 96 // This class displays a dialog which contains information about a hung | 95 // This class displays a dialog which contains information about a hung |
| 97 // renderer process. | 96 // renderer process. |
| 98 class HungRendererDialogView : public views::DialogDelegateView, | 97 class HungRendererDialogView : public views::DialogDelegateView, |
| 99 public views::ButtonListener, | |
| 100 public HungPagesTableModel::Delegate { | 98 public HungPagesTableModel::Delegate { |
| 101 public: | 99 public: |
| 102 // Factory function for creating an instance of the HungRendererDialogView | 100 // Factory function for creating an instance of the HungRendererDialogView |
| 103 // class. At any given point only one instance can be active. | 101 // class. At any given point only one instance can be active. |
| 104 static HungRendererDialogView* Create(gfx::NativeWindow context); | 102 static HungRendererDialogView* Create(gfx::NativeWindow context); |
| 105 | 103 |
| 106 // Returns a pointer to the singleton instance if any. | 104 // Returns a pointer to the singleton instance if any. |
| 107 static HungRendererDialogView* GetInstance(); | 105 static HungRendererDialogView* GetInstance(); |
| 108 | 106 |
| 109 // Shows or hides the hung renderer dialog for the given WebContents. | 107 // Shows or hides the hung renderer dialog for the given WebContents. |
| 110 static void Show( | 108 static void Show( |
| 111 content::WebContents* contents, | 109 content::WebContents* contents, |
| 112 const content::WebContentsUnresponsiveState& unresponsive_state); | 110 const content::WebContentsUnresponsiveState& unresponsive_state); |
| 113 static void Hide(content::WebContents* contents); | 111 static void Hide(content::WebContents* contents); |
| 114 | 112 |
| 115 // Returns true if the frame is in the foreground. | 113 // Returns true if the frame is in the foreground. |
| 116 static bool IsFrameActive(content::WebContents* contents); | 114 static bool IsFrameActive(content::WebContents* contents); |
| 117 | 115 |
| 118 virtual void ShowForWebContents( | 116 virtual void ShowForWebContents( |
| 119 content::WebContents* contents, | 117 content::WebContents* contents, |
| 120 const content::WebContentsUnresponsiveState& unresponsive_state); | 118 const content::WebContentsUnresponsiveState& unresponsive_state); |
| 121 virtual void EndForWebContents(content::WebContents* contents); | 119 virtual void EndForWebContents(content::WebContents* contents); |
| 122 | 120 |
| 123 // views::DialogDelegateView overrides: | 121 // views::DialogDelegateView overrides: |
| 124 base::string16 GetWindowTitle() const override; | 122 base::string16 GetWindowTitle() const override; |
| 125 void WindowClosing() override; | 123 void WindowClosing() override; |
| 126 int GetDialogButtons() const override; | 124 int GetDialogButtons() const override; |
| 127 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; | 125 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
| 128 views::View* CreateExtraView() override; | |
| 129 bool Cancel() override; | 126 bool Cancel() override; |
| 127 bool Accept() override; |
| 128 bool Close() override; |
| 130 bool ShouldUseCustomFrame() const override; | 129 bool ShouldUseCustomFrame() const override; |
| 131 | 130 |
| 132 // views::ButtonListener overrides: | |
| 133 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
| 134 | |
| 135 // HungPagesTableModel::Delegate overrides: | 131 // HungPagesTableModel::Delegate overrides: |
| 136 void TabDestroyed() override; | 132 void TabDestroyed() override; |
| 137 | 133 |
| 138 protected: | 134 protected: |
| 139 HungRendererDialogView(); | 135 HungRendererDialogView(); |
| 140 ~HungRendererDialogView() override; | 136 ~HungRendererDialogView() override; |
| 141 | 137 |
| 142 // views::View overrides: | 138 // views::View overrides: |
| 143 void ViewHierarchyChanged( | 139 void ViewHierarchyChanged( |
| 144 const ViewHierarchyChangedDetails& details) override; | 140 const ViewHierarchyChangedDetails& details) override; |
| 145 | 141 |
| 146 static HungRendererDialogView* g_instance_; | 142 static HungRendererDialogView* g_instance_; |
| 147 | 143 |
| 148 private: | 144 private: |
| 149 // Initialize the controls in this dialog. | 145 // Initialize the controls in this dialog. |
| 150 void Init(); | 146 void Init(); |
| 151 | 147 |
| 152 static void InitClass(); | 148 static void InitClass(); |
| 153 | 149 |
| 154 // An amusing icon image. | 150 // An amusing icon image. |
| 155 static gfx::ImageSkia* frozen_icon_; | 151 static gfx::ImageSkia* frozen_icon_; |
| 156 | 152 |
| 157 // The label describing the list. | 153 // The label describing the list. |
| 158 views::Label* info_label_; | 154 views::Label* info_label_; |
| 159 | 155 |
| 160 // Controls within the dialog box. | 156 // Controls within the dialog box. |
| 161 views::TableView* hung_pages_table_; | 157 views::TableView* hung_pages_table_; |
| 162 | 158 |
| 163 // The extra button inserted into the ClientView to kill the errant process. | |
| 164 views::LabelButton* kill_button_; | |
| 165 | |
| 166 // The model that provides the contents of the table that shows a list of | 159 // The model that provides the contents of the table that shows a list of |
| 167 // pages affected by the hang. | 160 // pages affected by the hang. |
| 168 std::unique_ptr<HungPagesTableModel> hung_pages_table_model_; | 161 std::unique_ptr<HungPagesTableModel> hung_pages_table_model_; |
| 169 | 162 |
| 170 // Whether or not we've created controls for ourself. | 163 // Whether or not we've created controls for ourself. |
| 171 bool initialized_; | 164 bool initialized_; |
| 172 | 165 |
| 173 bool kill_button_clicked_; | |
| 174 | |
| 175 // A copy of the unresponsive state which ShowForWebContents was | 166 // A copy of the unresponsive state which ShowForWebContents was |
| 176 // called with. | 167 // called with. |
| 177 content::WebContentsUnresponsiveState unresponsive_state_; | 168 content::WebContentsUnresponsiveState unresponsive_state_; |
| 178 | 169 |
| 179 DISALLOW_COPY_AND_ASSIGN(HungRendererDialogView); | 170 DISALLOW_COPY_AND_ASSIGN(HungRendererDialogView); |
| 180 }; | 171 }; |
| 181 | 172 |
| 182 #endif // CHROME_BROWSER_UI_VIEWS_HUNG_RENDERER_VIEW_H_ | 173 #endif // CHROME_BROWSER_UI_VIEWS_HUNG_RENDERER_VIEW_H_ |
| OLD | NEW |