Chromium Code Reviews| 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 #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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 AddObservers(); | 210 AddObservers(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 TabContents::~TabContents() { | 213 TabContents::~TabContents() { |
| 214 is_being_destroyed_ = true; | 214 is_being_destroyed_ = true; |
| 215 | 215 |
| 216 // We don't want any notifications while we're running our destructor. | 216 // We don't want any notifications while we're running our destructor. |
| 217 registrar_.RemoveAll(); | 217 registrar_.RemoveAll(); |
| 218 | 218 |
| 219 // Clear out any JavaScript state. | 219 // Clear out any JavaScript state. |
| 220 if (delegate_) | 220 if (delegate_) { |
| 221 delegate_->GetJavaScriptDialogCreator()->ResetJavaScriptState(this); | 221 delegate_->GetJavaScriptDialogCreator()->ResetJavaScriptState(this); |
| 222 set_delegate(NULL); | |
|
sky
2011/06/23 18:51:27
You should do this last. It's possible some of the
cbentzel
2011/06/23 19:09:57
Done.
| |
| 223 } | |
| 222 | 224 |
| 223 NotifyDisconnected(); | 225 NotifyDisconnected(); |
| 224 | 226 |
| 225 // First cleanly close all child windows. | 227 // First cleanly close all child windows. |
| 226 // TODO(mpcomplete): handle case if MaybeCloseChildWindows() already asked | 228 // TODO(mpcomplete): handle case if MaybeCloseChildWindows() already asked |
| 227 // some of these to close. CloseWindows is async, so it might get called | 229 // some of these to close. CloseWindows is async, so it might get called |
| 228 // twice before it runs. | 230 // twice before it runs. |
| 229 CloseConstrainedWindows(); | 231 CloseConstrainedWindows(); |
| 230 | 232 |
| 231 // Notify any observer that have a reference on this tab contents. | 233 // Notify any observer that have a reference on this tab contents. |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 616 WindowOpenDisposition disposition, | 618 WindowOpenDisposition disposition, |
| 617 const gfx::Rect& initial_pos, | 619 const gfx::Rect& initial_pos, |
| 618 bool user_gesture) { | 620 bool user_gesture) { |
| 619 if (!delegate_) | 621 if (!delegate_) |
| 620 return; | 622 return; |
| 621 | 623 |
| 622 delegate_->AddNewContents(this, new_contents, disposition, initial_pos, | 624 delegate_->AddNewContents(this, new_contents, disposition, initial_pos, |
| 623 user_gesture); | 625 user_gesture); |
| 624 } | 626 } |
| 625 | 627 |
| 628 void TabContents::set_delegate(TabContentsDelegate* delegate) { | |
|
sky
2011/06/23 18:51:27
Add a TODO about either removing debugging code, o
cbentzel
2011/06/23 19:09:57
Done.
| |
| 629 if (delegate == delegate_) | |
|
cbentzel
2011/06/23 19:09:57
Also, compacted vertical whitespace of set_delegat
| |
| 630 return; | |
| 631 | |
| 632 if (delegate_) | |
| 633 delegate_->Detach(this); | |
| 634 | |
| 635 delegate_ = delegate; | |
| 636 | |
| 637 if (delegate_) | |
| 638 delegate_->Attach(this); | |
| 639 } | |
| 640 | |
| 626 gfx::NativeView TabContents::GetContentNativeView() const { | 641 gfx::NativeView TabContents::GetContentNativeView() const { |
| 627 return view_->GetContentNativeView(); | 642 return view_->GetContentNativeView(); |
| 628 } | 643 } |
| 629 | 644 |
| 630 gfx::NativeView TabContents::GetNativeView() const { | 645 gfx::NativeView TabContents::GetNativeView() const { |
| 631 return view_->GetNativeView(); | 646 return view_->GetNativeView(); |
| 632 } | 647 } |
| 633 | 648 |
| 634 void TabContents::GetContainerBounds(gfx::Rect *out) const { | 649 void TabContents::GetContainerBounds(gfx::Rect *out) const { |
| 635 view_->GetContainerBounds(out); | 650 view_->GetContainerBounds(out); |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1838 | 1853 |
| 1839 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 1854 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 1840 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); | 1855 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); |
| 1841 rwh_view->SetSize(view()->GetContainerSize()); | 1856 rwh_view->SetSize(view()->GetContainerSize()); |
| 1842 } | 1857 } |
| 1843 | 1858 |
| 1844 void TabContents::OnOnlineStateChanged(bool online) { | 1859 void TabContents::OnOnlineStateChanged(bool online) { |
| 1845 render_view_host()->Send(new ViewMsg_NetworkStateChanged( | 1860 render_view_host()->Send(new ViewMsg_NetworkStateChanged( |
| 1846 render_view_host()->routing_id(), online)); | 1861 render_view_host()->routing_id(), online)); |
| 1847 } | 1862 } |
| OLD | NEW |