| 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 #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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 using content::DevToolsManagerImpl; | 115 using content::DevToolsManagerImpl; |
| 116 using content::DownloadItem; | 116 using content::DownloadItem; |
| 117 using content::DownloadManager; | 117 using content::DownloadManager; |
| 118 using content::GlobalRequestID; | 118 using content::GlobalRequestID; |
| 119 using content::InterstitialPage; | 119 using content::InterstitialPage; |
| 120 using content::NavigationController; | 120 using content::NavigationController; |
| 121 using content::NavigationEntry; | 121 using content::NavigationEntry; |
| 122 using content::NavigationEntryImpl; | 122 using content::NavigationEntryImpl; |
| 123 using content::OpenURLParams; | 123 using content::OpenURLParams; |
| 124 using content::RenderViewHostDelegate; | 124 using content::RenderViewHostDelegate; |
| 125 using content::RenderWidgetHostViewPort; |
| 125 using content::SiteInstance; | 126 using content::SiteInstance; |
| 126 using content::SSLStatus; | 127 using content::SSLStatus; |
| 127 using content::UserMetricsAction; | 128 using content::UserMetricsAction; |
| 128 using content::WebContents; | 129 using content::WebContents; |
| 129 using content::WebContentsObserver; | 130 using content::WebContentsObserver; |
| 130 using content::WebUI; | 131 using content::WebUI; |
| 131 using content::WebUIController; | 132 using content::WebUIController; |
| 132 using content::WebUIControllerFactory; | 133 using content::WebUIControllerFactory; |
| 133 | 134 |
| 134 namespace { | 135 namespace { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 content::Source<WebContents>(this), | 286 content::Source<WebContents>(this), |
| 286 content::NotificationService::NoDetails()); | 287 content::NotificationService::NoDetails()); |
| 287 | 288 |
| 288 // TODO(brettw) this should be moved to the view. | 289 // TODO(brettw) this should be moved to the view. |
| 289 #if defined(OS_WIN) && !defined(USE_AURA) | 290 #if defined(OS_WIN) && !defined(USE_AURA) |
| 290 // If we still have a window handle, destroy it. GetNativeView can return | 291 // If we still have a window handle, destroy it. GetNativeView can return |
| 291 // NULL if this contents was part of a window that closed. | 292 // NULL if this contents was part of a window that closed. |
| 292 if (GetNativeView()) { | 293 if (GetNativeView()) { |
| 293 RenderViewHost* host = GetRenderViewHost(); | 294 RenderViewHost* host = GetRenderViewHost(); |
| 294 if (host && host->view()) | 295 if (host && host->view()) |
| 295 RenderWidgetHostViewBase::FromRWHV(host->view())->WillWmDestroy(); | 296 RenderWidgetHostViewPort::FromRWHV(host->view())->WillWmDestroy(); |
| 296 } | 297 } |
| 297 #endif | 298 #endif |
| 298 | 299 |
| 299 // OnCloseStarted isn't called in unit tests. | 300 // OnCloseStarted isn't called in unit tests. |
| 300 if (!tab_close_start_time_.is_null()) { | 301 if (!tab_close_start_time_.is_null()) { |
| 301 UMA_HISTOGRAM_TIMES("Tab.Close", | 302 UMA_HISTOGRAM_TIMES("Tab.Close", |
| 302 base::TimeTicks::Now() - tab_close_start_time_); | 303 base::TimeTicks::Now() - tab_close_start_time_); |
| 303 } | 304 } |
| 304 | 305 |
| 305 FOR_EACH_OBSERVER(WebContentsObserver, observers_, TabContentsDestroyed()); | 306 FOR_EACH_OBSERVER(WebContentsObserver, observers_, TabContentsDestroyed()); |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 return is_being_destroyed_; | 755 return is_being_destroyed_; |
| 755 } | 756 } |
| 756 | 757 |
| 757 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { | 758 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { |
| 758 if (delegate_) | 759 if (delegate_) |
| 759 delegate_->NavigationStateChanged(this, changed_flags); | 760 delegate_->NavigationStateChanged(this, changed_flags); |
| 760 } | 761 } |
| 761 | 762 |
| 762 void TabContents::DidBecomeSelected() { | 763 void TabContents::DidBecomeSelected() { |
| 763 controller_.SetActive(true); | 764 controller_.SetActive(true); |
| 764 RenderWidgetHostViewBase* rwhv = | 765 RenderWidgetHostViewPort* rwhv = |
| 765 RenderWidgetHostViewBase::FromRWHV(GetRenderWidgetHostView()); | 766 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); |
| 766 if (rwhv) { | 767 if (rwhv) { |
| 767 rwhv->DidBecomeSelected(); | 768 rwhv->DidBecomeSelected(); |
| 768 #if defined(OS_MACOSX) | 769 #if defined(OS_MACOSX) |
| 769 rwhv->SetActive(true); | 770 rwhv->SetActive(true); |
| 770 #endif | 771 #endif |
| 771 } | 772 } |
| 772 | 773 |
| 773 last_selected_time_ = base::TimeTicks::Now(); | 774 last_selected_time_ = base::TimeTicks::Now(); |
| 774 | 775 |
| 775 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidBecomeSelected()); | 776 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidBecomeSelected()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 788 } | 789 } |
| 789 | 790 |
| 790 void TabContents::WasHidden() { | 791 void TabContents::WasHidden() { |
| 791 if (!capturing_contents_) { | 792 if (!capturing_contents_) { |
| 792 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to | 793 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to |
| 793 // open a tab in then background, then closes the tab before selecting it. | 794 // open a tab in then background, then closes the tab before selecting it. |
| 794 // This is because closing the tab calls TabContents::Destroy(), which | 795 // This is because closing the tab calls TabContents::Destroy(), which |
| 795 // removes the |GetRenderViewHost()|; then when we actually destroy the | 796 // removes the |GetRenderViewHost()|; then when we actually destroy the |
| 796 // window, OnWindowPosChanged() notices and calls HideContents() (which | 797 // window, OnWindowPosChanged() notices and calls HideContents() (which |
| 797 // calls us). | 798 // calls us). |
| 798 RenderWidgetHostViewBase* rwhv = | 799 RenderWidgetHostViewPort* rwhv = |
| 799 RenderWidgetHostViewBase::FromRWHV(GetRenderWidgetHostView()); | 800 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); |
| 800 if (rwhv) | 801 if (rwhv) |
| 801 rwhv->WasHidden(); | 802 rwhv->WasHidden(); |
| 802 } | 803 } |
| 803 | 804 |
| 804 content::NotificationService::current()->Notify( | 805 content::NotificationService::current()->Notify( |
| 805 content::NOTIFICATION_WEB_CONTENTS_HIDDEN, | 806 content::NOTIFICATION_WEB_CONTENTS_HIDDEN, |
| 806 content::Source<WebContents>(this), | 807 content::Source<WebContents>(this), |
| 807 content::NotificationService::NoDetails()); | 808 content::NotificationService::NoDetails()); |
| 808 } | 809 } |
| 809 | 810 |
| 810 void TabContents::ShowContents() { | 811 void TabContents::ShowContents() { |
| 811 RenderWidgetHostViewBase* rwhv = | 812 RenderWidgetHostViewPort* rwhv = |
| 812 RenderWidgetHostViewBase::FromRWHV(GetRenderWidgetHostView()); | 813 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); |
| 813 if (rwhv) | 814 if (rwhv) |
| 814 rwhv->DidBecomeSelected(); | 815 rwhv->DidBecomeSelected(); |
| 815 } | 816 } |
| 816 | 817 |
| 817 void TabContents::HideContents() { | 818 void TabContents::HideContents() { |
| 818 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call | 819 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call |
| 819 // our superclass HideContents(), because some callers want to be very picky | 820 // our superclass HideContents(), because some callers want to be very picky |
| 820 // about the order in which these get called. In addition to making the code | 821 // about the order in which these get called. In addition to making the code |
| 821 // here practically impossible to understand, this also means we end up | 822 // here practically impossible to understand, this also means we end up |
| 822 // calling TabContents::WasHidden() twice if callers call both versions of | 823 // calling TabContents::WasHidden() twice if callers call both versions of |
| (...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2465 save_info, | 2466 save_info, |
| 2466 this); | 2467 this); |
| 2467 } | 2468 } |
| 2468 | 2469 |
| 2469 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2470 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 2470 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2471 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
| 2471 // Can be NULL during tests. | 2472 // Can be NULL during tests. |
| 2472 if (rwh_view) | 2473 if (rwh_view) |
| 2473 rwh_view->SetSize(GetView()->GetContainerSize()); | 2474 rwh_view->SetSize(GetView()->GetContainerSize()); |
| 2474 } | 2475 } |
| OLD | NEW |