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/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "chrome/browser/favicon/favicon_tab_helper.h" | 9 #include "chrome/browser/favicon/favicon_tab_helper.h" |
10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // is destroyed. | 29 // is destroyed. |
30 class Delegate { | 30 class Delegate { |
31 public: | 31 public: |
32 virtual void TabDestroyed() = 0; | 32 virtual void TabDestroyed() = 0; |
33 | 33 |
34 protected: | 34 protected: |
35 virtual ~Delegate() {} | 35 virtual ~Delegate() {} |
36 }; | 36 }; |
37 | 37 |
38 explicit HungPagesTableModel(Delegate* delegate); | 38 explicit HungPagesTableModel(Delegate* delegate); |
39 virtual ~HungPagesTableModel(); | 39 ~HungPagesTableModel() override; |
40 | 40 |
41 void InitForWebContents(content::WebContents* hung_contents); | 41 void InitForWebContents(content::WebContents* hung_contents); |
42 | 42 |
43 // Returns the first RenderProcessHost, or NULL if there aren't any | 43 // Returns the first RenderProcessHost, or NULL if there aren't any |
44 // WebContents. | 44 // WebContents. |
45 content::RenderProcessHost* GetRenderProcessHost(); | 45 content::RenderProcessHost* GetRenderProcessHost(); |
46 | 46 |
47 // Returns the first RenderViewHost, or NULL if there aren't any WebContents. | 47 // Returns the first RenderViewHost, or NULL if there aren't any WebContents. |
48 content::RenderViewHost* GetRenderViewHost(); | 48 content::RenderViewHost* GetRenderViewHost(); |
49 | 49 |
50 // Overridden from ui::TableModel: | 50 // Overridden from ui::TableModel: |
51 virtual int RowCount() override; | 51 int RowCount() override; |
52 virtual base::string16 GetText(int row, int column_id) override; | 52 base::string16 GetText(int row, int column_id) override; |
53 virtual gfx::ImageSkia GetIcon(int row) override; | 53 gfx::ImageSkia GetIcon(int row) override; |
54 virtual void SetObserver(ui::TableModelObserver* observer) override; | 54 void SetObserver(ui::TableModelObserver* observer) override; |
55 | 55 |
56 // Overridden from views::TableGrouper: | 56 // Overridden from views::TableGrouper: |
57 virtual void GetGroupRange(int model_index, | 57 void GetGroupRange(int model_index, views::GroupRange* range) override; |
58 views::GroupRange* range) override; | |
59 | 58 |
60 private: | 59 private: |
61 // Used to track a single WebContents. If the WebContents is destroyed | 60 // Used to track a single WebContents. If the WebContents is destroyed |
62 // TabDestroyed() is invoked on the model. | 61 // TabDestroyed() is invoked on the model. |
63 class WebContentsObserverImpl : public content::WebContentsObserver { | 62 class WebContentsObserverImpl : public content::WebContentsObserver { |
64 public: | 63 public: |
65 WebContentsObserverImpl(HungPagesTableModel* model, | 64 WebContentsObserverImpl(HungPagesTableModel* model, |
66 content::WebContents* tab); | 65 content::WebContents* tab); |
67 | 66 |
68 FaviconTabHelper* favicon_tab_helper() { | 67 FaviconTabHelper* favicon_tab_helper() { |
69 return FaviconTabHelper::FromWebContents(web_contents()); | 68 return FaviconTabHelper::FromWebContents(web_contents()); |
70 } | 69 } |
71 | 70 |
72 // WebContentsObserver overrides: | 71 // WebContentsObserver overrides: |
73 virtual void RenderProcessGone(base::TerminationStatus status) override; | 72 void RenderProcessGone(base::TerminationStatus status) override; |
74 virtual void WebContentsDestroyed() override; | 73 void WebContentsDestroyed() override; |
75 | 74 |
76 private: | 75 private: |
77 HungPagesTableModel* model_; | 76 HungPagesTableModel* model_; |
78 | 77 |
79 DISALLOW_COPY_AND_ASSIGN(WebContentsObserverImpl); | 78 DISALLOW_COPY_AND_ASSIGN(WebContentsObserverImpl); |
80 }; | 79 }; |
81 | 80 |
82 // Invoked when a WebContents is destroyed. Cleans up |tab_observers_| and | 81 // Invoked when a WebContents is destroyed. Cleans up |tab_observers_| and |
83 // notifies the observer and delegate. | 82 // notifies the observer and delegate. |
84 void TabDestroyed(WebContentsObserverImpl* tab); | 83 void TabDestroyed(WebContentsObserverImpl* tab); |
(...skipping 24 matching lines...) Expand all Loading... |
109 // handle passed in. | 108 // handle passed in. |
110 static void KillRendererProcess(base::ProcessHandle process_handle); | 109 static void KillRendererProcess(base::ProcessHandle process_handle); |
111 | 110 |
112 // Returns true if the frame is in the foreground. | 111 // Returns true if the frame is in the foreground. |
113 static bool IsFrameActive(content::WebContents* contents); | 112 static bool IsFrameActive(content::WebContents* contents); |
114 | 113 |
115 virtual void ShowForWebContents(content::WebContents* contents); | 114 virtual void ShowForWebContents(content::WebContents* contents); |
116 virtual void EndForWebContents(content::WebContents* contents); | 115 virtual void EndForWebContents(content::WebContents* contents); |
117 | 116 |
118 // views::DialogDelegateView overrides: | 117 // views::DialogDelegateView overrides: |
119 virtual base::string16 GetWindowTitle() const override; | 118 base::string16 GetWindowTitle() const override; |
120 virtual void WindowClosing() override; | 119 void WindowClosing() override; |
121 virtual int GetDialogButtons() const override; | 120 int GetDialogButtons() const override; |
122 virtual base::string16 GetDialogButtonLabel( | 121 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
123 ui::DialogButton button) const override; | 122 views::View* CreateExtraView() override; |
124 virtual views::View* CreateExtraView() override; | 123 bool Accept(bool window_closing) override; |
125 virtual bool Accept(bool window_closing) override; | 124 bool UseNewStyleForThisDialog() const override; |
126 virtual bool UseNewStyleForThisDialog() const override; | |
127 | 125 |
128 // views::ButtonListener overrides: | 126 // views::ButtonListener overrides: |
129 virtual void ButtonPressed(views::Button* sender, | 127 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
130 const ui::Event& event) override; | |
131 | 128 |
132 // HungPagesTableModel::Delegate overrides: | 129 // HungPagesTableModel::Delegate overrides: |
133 virtual void TabDestroyed() override; | 130 void TabDestroyed() override; |
134 | 131 |
135 protected: | 132 protected: |
136 HungRendererDialogView(); | 133 HungRendererDialogView(); |
137 virtual ~HungRendererDialogView(); | 134 ~HungRendererDialogView() override; |
138 | 135 |
139 // views::View overrides: | 136 // views::View overrides: |
140 virtual void ViewHierarchyChanged( | 137 void ViewHierarchyChanged( |
141 const ViewHierarchyChangedDetails& details) override; | 138 const ViewHierarchyChangedDetails& details) override; |
142 | 139 |
143 static HungRendererDialogView* g_instance_; | 140 static HungRendererDialogView* g_instance_; |
144 | 141 |
145 private: | 142 private: |
146 // Initialize the controls in this dialog. | 143 // Initialize the controls in this dialog. |
147 void Init(); | 144 void Init(); |
148 | 145 |
149 static void InitClass(); | 146 static void InitClass(); |
150 | 147 |
(...skipping 10 matching lines...) Expand all Loading... |
161 // Whether or not we've created controls for ourself. | 158 // Whether or not we've created controls for ourself. |
162 bool initialized_; | 159 bool initialized_; |
163 | 160 |
164 // An amusing icon image. | 161 // An amusing icon image. |
165 static gfx::ImageSkia* frozen_icon_; | 162 static gfx::ImageSkia* frozen_icon_; |
166 | 163 |
167 DISALLOW_COPY_AND_ASSIGN(HungRendererDialogView); | 164 DISALLOW_COPY_AND_ASSIGN(HungRendererDialogView); |
168 }; | 165 }; |
169 | 166 |
170 #endif // CHROME_BROWSER_UI_VIEWS_HUNG_RENDERER_VIEW_H_ | 167 #endif // CHROME_BROWSER_UI_VIEWS_HUNG_RENDERER_VIEW_H_ |
OLD | NEW |