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

Side by Side Diff: content/browser/tab_contents/tab_contents.cc

Issue 7259004: Convert ViewMsg_NetworkStateChanged from routed -> control, allowing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix linux build Created 9 years, 5 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
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "content/browser/tab_contents/tab_contents.h" 5 #include "content/browser/tab_contents/tab_contents.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 render_manager_.Init(profile, site_instance, routing_id); 196 render_manager_.Init(profile, site_instance, routing_id);
197 197
198 // We have the initial size of the view be based on the size of the passed in 198 // We have the initial size of the view be based on the size of the passed in
199 // tab contents (normally a tab from the same window). 199 // tab contents (normally a tab from the same window).
200 view_->CreateView(base_tab_contents ? 200 view_->CreateView(base_tab_contents ?
201 base_tab_contents->view()->GetContainerSize() : gfx::Size()); 201 base_tab_contents->view()->GetContainerSize() : gfx::Size());
202 202
203 registrar_.Add(this, NotificationType::RENDER_WIDGET_HOST_DESTROYED, 203 registrar_.Add(this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
204 NotificationService::AllSources()); 204 NotificationService::AllSources());
205
206 // Can only add observers after render_manager_.Init() is called, since that's
207 // what sets up the render_view_host which TabContentObserver's constructor
208 // uses to get the routing_id.
209 AddObservers();
210 } 205 }
211 206
212 TabContents::~TabContents() { 207 TabContents::~TabContents() {
213 is_being_destroyed_ = true; 208 is_being_destroyed_ = true;
214 209
215 // We don't want any notifications while we're running our destructor. 210 // We don't want any notifications while we're running our destructor.
216 registrar_.RemoveAll(); 211 registrar_.RemoveAll();
217 212
218 // Clear out any JavaScript state. 213 // Clear out any JavaScript state.
219 if (delegate_) 214 if (delegate_)
(...skipping 25 matching lines...) Expand all
245 #endif 240 #endif
246 241
247 // OnCloseStarted isn't called in unit tests. 242 // OnCloseStarted isn't called in unit tests.
248 if (!tab_close_start_time_.is_null()) { 243 if (!tab_close_start_time_.is_null()) {
249 UMA_HISTOGRAM_TIMES("Tab.Close", 244 UMA_HISTOGRAM_TIMES("Tab.Close",
250 base::TimeTicks::Now() - tab_close_start_time_); 245 base::TimeTicks::Now() - tab_close_start_time_);
251 } 246 }
252 247
253 FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed()); 248 FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed());
254 249
255 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this);
256
257 set_delegate(NULL); 250 set_delegate(NULL);
258 } 251 }
259 252
260 // TODO(cbentzel): Either remove the debugging code, or rename to SetDelegate. 253 // TODO(cbentzel): Either remove the debugging code, or rename to SetDelegate.
261 void TabContents::set_delegate(TabContentsDelegate* delegate) { 254 void TabContents::set_delegate(TabContentsDelegate* delegate) {
262 if (delegate == delegate_) 255 if (delegate == delegate_)
263 return; 256 return;
264 if (delegate_) 257 if (delegate_)
265 delegate_->Detach(this); 258 delegate_->Detach(this);
266 delegate_ = delegate; 259 delegate_ = delegate;
267 if (delegate_) 260 if (delegate_)
268 delegate_->Attach(this); 261 delegate_->Attach(this);
269 } 262 }
270 263
271 void TabContents::AddObservers() {
272 net::NetworkChangeNotifier::AddOnlineStateObserver(this);
273 }
274
275 bool TabContents::OnMessageReceived(const IPC::Message& message) { 264 bool TabContents::OnMessageReceived(const IPC::Message& message) {
276 if (web_ui() && web_ui()->OnMessageReceived(message)) 265 if (web_ui() && web_ui()->OnMessageReceived(message))
277 return true; 266 return true;
278 267
279 ObserverListBase<TabContentsObserver>::Iterator it(observers_); 268 ObserverListBase<TabContentsObserver>::Iterator it(observers_);
280 TabContentsObserver* observer; 269 TabContentsObserver* observer;
281 while ((observer = it.GetNext()) != NULL) 270 while ((observer = it.GetNext()) != NULL)
282 if (observer->OnMessageReceived(message)) 271 if (observer->OnMessageReceived(message))
283 return true; 272 return true;
284 273
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 } 1833 }
1845 1834
1846 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { 1835 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) {
1847 render_manager_.SwapInRenderViewHost(rvh); 1836 render_manager_.SwapInRenderViewHost(rvh);
1848 } 1837 }
1849 1838
1850 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 1839 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
1851 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); 1840 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh);
1852 rwh_view->SetSize(view()->GetContainerSize()); 1841 rwh_view->SetSize(view()->GetContainerSize());
1853 } 1842 }
1854
1855 void TabContents::OnOnlineStateChanged(bool online) {
1856 render_view_host()->Send(new ViewMsg_NetworkStateChanged(
1857 render_view_host()->routing_id(), online));
1858 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698