Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1105)

Side by Side Diff: chrome/browser/ui/views/hung_renderer_view.cc

Issue 10540100: TabContentsWrapper -> TabContents, part 48. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/ui/browser_dialogs.h" 5 #include "chrome/browser/ui/browser_dialogs.h"
6 6
7 #if defined(OS_WIN) && !defined(USE_AURA) 7 #if defined(OS_WIN) && !defined(USE_AURA)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/process_util.h" 13 #include "base/process_util.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/favicon/favicon_tab_helper.h" 15 #include "chrome/browser/favicon/favicon_tab_helper.h"
16 #include "chrome/browser/platform_util.h" 16 #include "chrome/browser/platform_util.h"
17 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 17 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" 19 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
20 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/logging_chrome.h" 21 #include "chrome/common/logging_chrome.h"
22 #include "content/public/browser/render_process_host.h" 22 #include "content/public/browser/render_process_host.h"
23 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
24 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 #include "content/public/common/result_codes.h" 25 #include "content/public/common/result_codes.h"
26 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
27 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
28 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 virtual gfx::ImageSkia GetIcon(int row); 91 virtual gfx::ImageSkia GetIcon(int row);
92 virtual void SetObserver(ui::TableModelObserver* observer); 92 virtual void SetObserver(ui::TableModelObserver* observer);
93 virtual void GetGroupRangeForItem(int item, views::GroupRange* range); 93 virtual void GetGroupRangeForItem(int item, views::GroupRange* range);
94 94
95 private: 95 private:
96 // Used to track a single WebContents. If the WebContents is destroyed 96 // Used to track a single WebContents. If the WebContents is destroyed
97 // TabDestroyed() is invoked on the model. 97 // TabDestroyed() is invoked on the model.
98 class WebContentsObserverImpl : public content::WebContentsObserver { 98 class WebContentsObserverImpl : public content::WebContentsObserver {
99 public: 99 public:
100 WebContentsObserverImpl(HungPagesTableModel* model, 100 WebContentsObserverImpl(HungPagesTableModel* model,
101 TabContentsWrapper* tab); 101 TabContents* tab);
102 102
103 WebContents* web_contents() const { 103 WebContents* web_contents() const {
104 return content::WebContentsObserver::web_contents(); 104 return content::WebContentsObserver::web_contents();
105 } 105 }
106 106
107 FaviconTabHelper* favicon_tab_helper() { 107 FaviconTabHelper* favicon_tab_helper() {
108 return tab_->favicon_tab_helper(); 108 return tab_->favicon_tab_helper();
109 } 109 }
110 110
111 // WebContentsObserver overrides: 111 // WebContentsObserver overrides:
112 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 112 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
113 virtual void WebContentsDestroyed(WebContents* tab) OVERRIDE; 113 virtual void WebContentsDestroyed(WebContents* tab) OVERRIDE;
114 114
115 private: 115 private:
116 HungPagesTableModel* model_; 116 HungPagesTableModel* model_;
117 TabContentsWrapper* tab_; 117 TabContents* tab_;
118 118
119 DISALLOW_COPY_AND_ASSIGN(WebContentsObserverImpl); 119 DISALLOW_COPY_AND_ASSIGN(WebContentsObserverImpl);
120 }; 120 };
121 121
122 // Invoked when a WebContents is destroyed. Cleans up |tab_observers_| and 122 // Invoked when a WebContents is destroyed. Cleans up |tab_observers_| and
123 // notifies the observer and delegate. 123 // notifies the observer and delegate.
124 void TabDestroyed(WebContentsObserverImpl* tab); 124 void TabDestroyed(WebContentsObserverImpl* tab);
125 125
126 typedef ScopedVector<WebContentsObserverImpl> TabObservers; 126 typedef ScopedVector<WebContentsObserverImpl> TabObservers;
127 TabObservers tab_observers_; 127 TabObservers tab_observers_;
(...skipping 22 matching lines...) Expand all
150 150
151 RenderViewHost* HungPagesTableModel::GetRenderViewHost() { 151 RenderViewHost* HungPagesTableModel::GetRenderViewHost() {
152 return tab_observers_.empty() ? NULL : 152 return tab_observers_.empty() ? NULL :
153 tab_observers_[0]->web_contents()->GetRenderViewHost(); 153 tab_observers_[0]->web_contents()->GetRenderViewHost();
154 } 154 }
155 155
156 void HungPagesTableModel::InitForWebContents(WebContents* hung_contents) { 156 void HungPagesTableModel::InitForWebContents(WebContents* hung_contents) {
157 tab_observers_.reset(); 157 tab_observers_.reset();
158 if (hung_contents) { 158 if (hung_contents) {
159 // Force hung_contents to be first. 159 // Force hung_contents to be first.
160 TabContentsWrapper* hung_wrapper = 160 TabContents* hung_tab_contents =
161 TabContentsWrapper::GetCurrentWrapperForContents(hung_contents); 161 TabContents::FromWebContents(hung_contents);
162 if (hung_wrapper) 162 if (hung_tab_contents) {
163 tab_observers_.push_back(new WebContentsObserverImpl(this, hung_wrapper)); 163 tab_observers_.push_back(new WebContentsObserverImpl(this,
164 hung_tab_contents));
165 }
164 for (TabContentsIterator it; !it.done(); ++it) { 166 for (TabContentsIterator it; !it.done(); ++it) {
165 if (*it != hung_wrapper && 167 if (*it != hung_tab_contents &&
166 it->web_contents()->GetRenderProcessHost() == 168 it->web_contents()->GetRenderProcessHost() ==
167 hung_contents->GetRenderProcessHost()) 169 hung_contents->GetRenderProcessHost())
168 tab_observers_.push_back(new WebContentsObserverImpl(this, *it)); 170 tab_observers_.push_back(new WebContentsObserverImpl(this, *it));
169 } 171 }
170 } 172 }
171 // The world is different. 173 // The world is different.
172 if (observer_) 174 if (observer_)
173 observer_->OnModelChanged(); 175 observer_->OnModelChanged();
174 } 176 }
175 177
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 if (observer_) 220 if (observer_)
219 observer_->OnItemsRemoved(index, 1); 221 observer_->OnItemsRemoved(index, 1);
220 222
221 // Notify the delegate. 223 // Notify the delegate.
222 delegate_->TabDestroyed(); 224 delegate_->TabDestroyed();
223 // WARNING: we've likely been deleted. 225 // WARNING: we've likely been deleted.
224 } 226 }
225 227
226 HungPagesTableModel::WebContentsObserverImpl::WebContentsObserverImpl( 228 HungPagesTableModel::WebContentsObserverImpl::WebContentsObserverImpl(
227 HungPagesTableModel* model, 229 HungPagesTableModel* model,
228 TabContentsWrapper* tab) 230 TabContents* tab)
229 : content::WebContentsObserver(tab->web_contents()), 231 : content::WebContentsObserver(tab->web_contents()),
230 model_(model), 232 model_(model),
231 tab_(tab) { 233 tab_(tab) {
232 } 234 }
233 235
234 void HungPagesTableModel::WebContentsObserverImpl::RenderViewGone( 236 void HungPagesTableModel::WebContentsObserverImpl::RenderViewGone(
235 base::TerminationStatus status) { 237 base::TerminationStatus status) {
236 model_->TabDestroyed(this); 238 model_->TabDestroyed(this);
237 } 239 }
238 240
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 g_instance->ShowForWebContents(contents); 589 g_instance->ShowForWebContents(contents);
588 } 590 }
589 } 591 }
590 592
591 void HideHungRendererDialog(WebContents* contents) { 593 void HideHungRendererDialog(WebContents* contents) {
592 if (!logging::DialogsAreSuppressed() && g_instance) 594 if (!logging::DialogsAreSuppressed() && g_instance)
593 g_instance->EndForWebContents(contents); 595 g_instance->EndForWebContents(contents);
594 } 596 }
595 597
596 } // namespace browser 598 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/opaque_browser_frame_view.cc ('k') | chrome/browser/ui/views/login_prompt_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698