diff options
30 files changed, 61 insertions, 94 deletions
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc index 402e8d2..4c6f1ee 100644 --- a/chrome/browser/instant/instant_loader.cc +++ b/chrome/browser/instant/instant_loader.cc @@ -1140,7 +1140,9 @@ void InstantLoader::CreatePreviewContents(TabContents* tab_contents) { preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); SetupPreviewContents(tab_contents); - preview_contents_->web_contents()->ShowContents(); + // TODO(beng): investigate if we can avoid this and instead rely on the + // visibility of the WebContentsView + preview_contents_->web_contents()->WasRestored(); } void InstantLoader::LoadInstantURL(const TemplateURL* template_url, @@ -1169,7 +1171,7 @@ void InstantLoader::LoadInstantURL(const TemplateURL* template_url, transition_type, false, std::string(), override_user_agent); RenderViewHost* host = preview_contents_->web_contents()->GetRenderViewHost(); - preview_contents_->web_contents()->HideContents(); + preview_contents_->web_contents()->WasHidden(); // If user_text is empty, this must be a preload of the search homepage. In // that case, send down a SearchBoxResize message, which will switch the page diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc index 2a53f62..2e4763c 100644 --- a/chrome/browser/prerender/prerender_contents.cc +++ b/chrome/browser/prerender/prerender_contents.cc @@ -463,7 +463,7 @@ void PrerenderContents::Observe(int type, // size, is also sets itself to be visible, which would then break the // visibility API. new_render_view_host->WasResized(); - prerender_contents_->web_contents()->HideContents(); + prerender_contents_->web_contents()->WasHidden(); } break; } diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 97c4de8..0992beb 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -953,7 +953,7 @@ WebContents* Browser::AddRestoredTab( // layout with proper view dimensions. TabStripModel::AddTabContents() // contains similar logic. new_tab->GetView()->SizeContents(window_->GetRestoredBounds().size()); - new_tab->HideContents(); + new_tab->WasHidden(); } SessionService* session_service = SessionServiceFactory::GetForProfileIfExisting(profile_); @@ -3572,16 +3572,18 @@ void Browser::OnStateChanged() { void Browser::ShowInstant(TabContents* preview_contents) { window_->ShowInstant(preview_contents); - GetActiveWebContents()->HideContents(); - preview_contents->web_contents()->ShowContents(); + // TODO(beng): investigate if we can avoid this and instead rely on the + // visibility of the WebContentsView + GetActiveWebContents()->WasHidden(); + preview_contents->web_contents()->WasRestored(); } void Browser::HideInstant() { window_->HideInstant(); if (GetActiveWebContents()) - GetActiveWebContents()->ShowContents(); + GetActiveWebContents()->WasRestored(); if (instant_->GetPreviewContents()) - instant_->GetPreviewContents()->web_contents()->HideContents(); + instant_->GetPreviewContents()->web_contents()->WasHidden(); } void Browser::CommitInstant(TabContents* preview_contents) { diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index 4fc681f..acfd111 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -519,7 +519,7 @@ void Navigate(NavigateParams* params) { // By default, content believes it is not hidden. When adding contents // in the background, tell it that it's hidden. if ((params->tabstrip_add_types & TabStripModel::ADD_ACTIVE) == 0) { - // TabStripModel::AddTabContents invokes HideContents if not foreground. + // TabStripModel::AddTabContents invokes WasHidden if not foreground. params->target_contents->web_contents()->WasHidden(); } } else { diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm index d19bbdf..2cf2138 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm @@ -1262,7 +1262,7 @@ private: [self swapInTabAtIndex:modelIndex]; if (newContents) { - newContents->web_contents()->DidBecomeSelected(); + newContents->web_contents()->WasRestored(); newContents->web_contents()->GetView()->RestoreFocus(); if (newContents->find_tab_helper()->find_ui_active()) diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index 335c52e..677da9e2 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -1345,7 +1345,6 @@ void BrowserWindowGtk::ActiveTabChanged(TabContents* old_contents, infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); contents_container_->SetTab(new_contents); - new_contents->web_contents()->DidBecomeSelected(); // TODO(estade): after we manage browser activation, add a check to make sure // we are the active browser before calling RestoreFocus(). if (!browser_->tab_strip_model()->closing_all()) { @@ -1445,7 +1444,7 @@ void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) { // anything other than user selecting a Tab. // See TabContentsViewViews::OnWindowPosChanged for reference on how it // should be implemented. - devtools_contents->web_contents()->ShowContents(); + devtools_contents->web_contents()->WasRestored(); } bool should_show = old_devtools == NULL && devtools_contents != NULL; diff --git a/chrome/browser/ui/gtk/tab_contents_container_gtk.cc b/chrome/browser/ui/gtk/tab_contents_container_gtk.cc index 8e6c1b7..58b4872 100644 --- a/chrome/browser/ui/gtk/tab_contents_container_gtk.cc +++ b/chrome/browser/ui/gtk/tab_contents_container_gtk.cc @@ -146,7 +146,7 @@ void TabContentsContainerGtk::PackTab(TabContents* tab) { gdk_window_lower(content_gdk_window); } - tab->web_contents()->ShowContents(); + tab->web_contents()->WasRestored(); } void TabContentsContainerGtk::HideTab(TabContents* tab) { diff --git a/chrome/browser/ui/tab_contents/core_tab_helper.cc b/chrome/browser/ui/tab_contents/core_tab_helper.cc index 6f8c9e14..531f36c 100644 --- a/chrome/browser/ui/tab_contents/core_tab_helper.cc +++ b/chrome/browser/ui/tab_contents/core_tab_helper.cc @@ -79,7 +79,7 @@ string16 CoreTabHelper::GetStatusText() const { //////////////////////////////////////////////////////////////////////////////// // WebContentsObserver overrides -void CoreTabHelper::DidBecomeSelected() { +void CoreTabHelper::WasRestored() { WebCacheManager::GetInstance()->ObserveActivity( web_contents()->GetRenderProcessHost()->GetID()); } diff --git a/chrome/browser/ui/tab_contents/core_tab_helper.h b/chrome/browser/ui/tab_contents/core_tab_helper.h index b6d6366..5b205a7 100644 --- a/chrome/browser/ui/tab_contents/core_tab_helper.h +++ b/chrome/browser/ui/tab_contents/core_tab_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -27,7 +27,7 @@ class CoreTabHelper : public content::WebContentsObserver { private: // content::WebContentsObserver overrides: - virtual void DidBecomeSelected() OVERRIDE; + virtual void WasRestored() OVERRIDE; // Delegate for notifying our owner about stuff. Not owned by us. CoreTabHelperDelegate* delegate_; diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc index a4c434a..4db7864 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.cc +++ b/chrome/browser/ui/tabs/tab_strip_model.cc @@ -728,7 +728,7 @@ void TabStripModel::AddTabContents(TabContents* contents, // We need to hide the contents or else we get and execute paints for // background tabs. With enough background tabs they will steal the // backing store of the visible tab causing flashing. See bug 20831. - contents->web_contents()->HideContents(); + contents->web_contents()->WasHidden(); } } } diff --git a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc index 4ab5b5e..df9d116 100644 --- a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc @@ -152,7 +152,7 @@ class TabStripModelTest : public ChromeRenderViewHostTestHarness { } void SwitchTabTo(WebContents* contents) { - // contents()->DidBecomeSelected(); + // contents()->WasRestored(); } // Sets the id of the specified contents. diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 313d9cc..3ad865d 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -2409,11 +2409,6 @@ void BrowserView::ProcessTabSelected(TabContents* new_contents) { } UpdateDevToolsForContents(new_contents); - // TODO(beng): This should be called automatically by ChangeWebContents, but I - // am striving for parity now rather than cleanliness. This is - // required to make features like Duplicate Tab, Undo Close Tab, - // etc not result in sad tab. - new_contents->web_contents()->DidBecomeSelected(); if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() && GetWidget()->IsVisible()) { // We only restore focus if our window is visible, to avoid invoking blur diff --git a/content/browser/browser_plugin/old/browser_plugin_host.cc b/content/browser/browser_plugin/old/browser_plugin_host.cc index 8df87c4..bacca9d 100644 --- a/content/browser/browser_plugin/old/browser_plugin_host.cc +++ b/content/browser/browser_plugin/old/browser_plugin_host.cc @@ -223,9 +223,9 @@ void BrowserPluginHost::Observe( it != guests_.end(); ++it) { WebContentsImpl* web_contents = it->first; if (visible) - web_contents->ShowContents(); + web_contents->WasRestored(); else - web_contents->HideContents(); + web_contents->WasHidden(); } break; } diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 083ccef..35bdbbc 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -265,7 +265,7 @@ RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { return host_; } -void RenderWidgetHostViewAura::DidBecomeSelected() { +void RenderWidgetHostViewAura::WasRestored() { host_->WasRestored(); if (!current_surface_ && host_->is_accelerated_compositing_active() && !released_front_lock_.get()) diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index d94a9d5..d4540b6 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -75,7 +75,7 @@ class RenderWidgetHostViewAura const gfx::Rect& pos) OVERRIDE; virtual void InitAsFullscreen( content::RenderWidgetHostView* reference_host_view) OVERRIDE; - virtual void DidBecomeSelected() OVERRIDE; + virtual void WasRestored() OVERRIDE; virtual void WasHidden() OVERRIDE; virtual void MovePluginWindows( const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc index 56a52d5..3cbbb40 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -681,7 +681,7 @@ RenderWidgetHostViewGtk::GetRenderWidgetHost() const { return host_; } -void RenderWidgetHostViewGtk::DidBecomeSelected() { +void RenderWidgetHostViewGtk::WasRestored() { if (!is_hidden_) return; diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.h b/content/browser/renderer_host/render_widget_host_view_gtk.h index 3e7aa7f..d3e4e87 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.h +++ b/content/browser/renderer_host/render_widget_host_view_gtk.h @@ -74,7 +74,7 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk const gfx::Rect& pos) OVERRIDE; virtual void InitAsFullscreen( content::RenderWidgetHostView* reference_host_view) OVERRIDE; - virtual void DidBecomeSelected() OVERRIDE; + virtual void WasRestored() OVERRIDE; virtual void WasHidden() OVERRIDE; virtual void MovePluginWindows( const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h index 914ec14..447c7c7 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h @@ -210,7 +210,7 @@ class RenderWidgetHostViewMac : public content::RenderWidgetHostViewBase { const gfx::Rect& pos) OVERRIDE; virtual void InitAsFullscreen( content::RenderWidgetHostView* reference_host_view) OVERRIDE; - virtual void DidBecomeSelected() OVERRIDE; + virtual void WasRestored() OVERRIDE; virtual void WasHidden() OVERRIDE; virtual void MovePluginWindows( const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index d7f018b..b40c03f 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -397,7 +397,7 @@ RenderWidgetHost* RenderWidgetHostViewMac::GetRenderWidgetHost() const { return render_widget_host_; } -void RenderWidgetHostViewMac::DidBecomeSelected() { +void RenderWidgetHostViewMac::WasRestored() { if (!is_hidden_) return; @@ -577,7 +577,7 @@ bool RenderWidgetHostViewMac::IsSurfaceAvailableForCopy() const { void RenderWidgetHostViewMac::Show() { [cocoa_view_ setHidden:NO]; - DidBecomeSelected(); + WasRestored(); } void RenderWidgetHostViewMac::Hide() { @@ -1940,7 +1940,7 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { doubleValue]; if (newBackingScaleFactor != oldBackingScaleFactor) { // Background tabs check if their scale factor changed when they become - // active, in DidBecomeSelected(). + // active, in WasRestored(). // Allocating a CGLayerRef with the current scale factor immediately from // this handler doesn't work. Schedule the backing store update on the @@ -2871,7 +2871,7 @@ extern NSString *NSTextInputReplacementRangeAttributeName; if (newWindow) { // If we move into a new window, refresh the frame information. We // don't need to do it if it was the same window as it used to be in, - // since that case is covered by DidBecomeSelected. We only want to + // since that case is covered by WasRestored(). We only want to // do this for real browser views, not popups. if (newWindow != lastWindow_) { lastWindow_ = newWindow; diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index ac49ca8..cbce15f 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -658,7 +658,7 @@ RenderWidgetHost* RenderWidgetHostViewWin::GetRenderWidgetHost() const { return render_widget_host_; } -void RenderWidgetHostViewWin::DidBecomeSelected() { +void RenderWidgetHostViewWin::WasRestored() { if (!is_hidden_) return; @@ -941,7 +941,7 @@ void RenderWidgetHostViewWin::Show() { } ShowWindow(SW_SHOW); - DidBecomeSelected(); + WasRestored(); } void RenderWidgetHostViewWin::Hide() { diff --git a/content/browser/renderer_host/render_widget_host_view_win.h b/content/browser/renderer_host/render_widget_host_view_win.h index d7c42e0..240edcd 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.h +++ b/content/browser/renderer_host/render_widget_host_view_win.h @@ -166,7 +166,7 @@ class RenderWidgetHostViewWin const gfx::Rect& pos) OVERRIDE; virtual void InitAsFullscreen( content::RenderWidgetHostView* reference_host_view) OVERRIDE; - virtual void DidBecomeSelected() OVERRIDE; + virtual void WasRestored() OVERRIDE; virtual void WasHidden() OVERRIDE; virtual void MovePluginWindows( const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index 56f474f..7085836 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -78,7 +78,7 @@ class TestRenderWidgetHostView : public RenderWidgetHostViewBase { const gfx::Rect& pos) OVERRIDE {} virtual void InitAsFullscreen( RenderWidgetHostView* reference_host_view) OVERRIDE {} - virtual void DidBecomeSelected() OVERRIDE {} + virtual void WasRestored() OVERRIDE {} virtual void WasHidden() OVERRIDE {} virtual void MovePluginWindows( const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE {} diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 7cdfb2b..6209e3b 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -910,12 +910,16 @@ void WebContentsImpl::NotifyNavigationStateChanged(unsigned changed_flags) { delegate_->NavigationStateChanged(this, changed_flags); } -void WebContentsImpl::DidBecomeSelected() { +base::TimeTicks WebContentsImpl::GetLastSelectedTime() const { + return last_selected_time_; +} + +void WebContentsImpl::WasRestored() { controller_.SetActive(true); RenderWidgetHostViewPort* rwhv = RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); if (rwhv) { - rwhv->DidBecomeSelected(); + rwhv->WasRestored(); #if defined(OS_MACOSX) rwhv->SetActive(true); #endif @@ -923,7 +927,7 @@ void WebContentsImpl::DidBecomeSelected() { last_selected_time_ = base::TimeTicks::Now(); - FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidBecomeSelected()); + FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasRestored()); // The resize rect might have changed while this was inactive -- send the new // one to make sure it's up to date. @@ -932,11 +936,12 @@ void WebContentsImpl::DidBecomeSelected() { if (rvh) { rvh->ResizeRectChanged(GetRootWindowResizerRect()); } -} - -base::TimeTicks WebContentsImpl::GetLastSelectedTime() const { - return last_selected_time_; + bool is_visible = true; + content::NotificationService::current()->Notify( + content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, + content::Source<WebContents>(this), + content::Details<bool>(&is_visible)); } void WebContentsImpl::WasHidden() { @@ -945,7 +950,7 @@ void WebContentsImpl::WasHidden() { // open a tab in then background, then closes the tab before selecting it. // This is because closing the tab calls WebContentsImpl::Destroy(), which // removes the |GetRenderViewHost()|; then when we actually destroy the - // window, OnWindowPosChanged() notices and calls HideContents() (which + // window, OnWindowPosChanged() notices and calls WasHidden() (which // calls us). RenderWidgetHostViewPort* rwhv = RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); @@ -960,32 +965,6 @@ void WebContentsImpl::WasHidden() { content::Details<bool>(&is_visible)); } -void WebContentsImpl::WasRestored() { - bool is_visible = true; - content::NotificationService::current()->Notify( - content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, - content::Source<WebContents>(this), - content::Details<bool>(&is_visible)); -} - -void WebContentsImpl::ShowContents() { - RenderWidgetHostViewPort* rwhv = - RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); - if (rwhv) - rwhv->DidBecomeSelected(); - WasRestored(); -} - -void WebContentsImpl::HideContents() { - // TODO(pkasting): http://b/1239839 Right now we purposefully don't call - // our superclass HideContents(), because some callers want to be very picky - // about the order in which these get called. In addition to making the code - // here practically impossible to understand, this also means we end up - // calling WebContentsImpl::WasHidden() twice if callers call both versions of - // HideContents() on a WebContentsImpl. - WasHidden(); -} - bool WebContentsImpl::NeedToFireBeforeUnload() { // TODO(creis): Should we fire even for interstitial pages? return WillNotifyDisconnection() && diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 4426f1a..df4a3aa 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -192,12 +192,9 @@ class CONTENT_EXPORT WebContentsImpl virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE; virtual bool IsBeingDestroyed() const OVERRIDE; virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE; - virtual void DidBecomeSelected() OVERRIDE; virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE; - virtual void WasHidden() OVERRIDE; virtual void WasRestored() OVERRIDE; - virtual void ShowContents() OVERRIDE; - virtual void HideContents() OVERRIDE; + virtual void WasHidden() OVERRIDE; virtual bool NeedToFireBeforeUnload() OVERRIDE; virtual void Stop() OVERRIDE; virtual content::WebContents* Clone() OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index a484025..9001894 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -565,9 +565,9 @@ void WebContentsViewAura::OnWindowDestroyed() { void WebContentsViewAura::OnWindowVisibilityChanged(bool visible) { if (visible) - web_contents_->ShowContents(); + web_contents_->WasRestored(); else - web_contents_->HideContents(); + web_contents_->WasHidden(); } bool WebContentsViewAura::HasHitTestMask() const { diff --git a/content/browser/web_contents/web_contents_view_win.cc b/content/browser/web_contents/web_contents_view_win.cc index 12a11cb..d63c254 100644 --- a/content/browser/web_contents/web_contents_view_win.cc +++ b/content/browser/web_contents/web_contents_view_win.cc @@ -382,14 +382,14 @@ LRESULT WebContentsViewWin::OnWindowPosChanged( WINDOWPOS* window_pos = reinterpret_cast<WINDOWPOS*>(lparam); if (window_pos->flags & SWP_HIDEWINDOW) { - web_contents_->HideContents(); + web_contents_->WasHidden(); return 0; } // The WebContents was shown by a means other than the user selecting a // Tab, e.g. the window was minimized then restored. if (window_pos->flags & SWP_SHOWWINDOW) - web_contents_->ShowContents(); + web_contents_->WasRestored(); RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); if (rwhv) { diff --git a/content/port/browser/render_widget_host_view_port.h b/content/port/browser/render_widget_host_view_port.h index 3578a96..7cccc94 100644 --- a/content/port/browser/render_widget_host_view_port.h +++ b/content/port/browser/render_widget_host_view_port.h @@ -68,7 +68,7 @@ class CONTENT_EXPORT RenderWidgetHostViewPort : public RenderWidgetHostView { RenderWidgetHostView* reference_host_view) = 0; // Notifies the View that it has become visible. - virtual void DidBecomeSelected() = 0; + virtual void WasRestored() = 0; // Notifies the View that it has been hidden. virtual void WasHidden() = 0; diff --git a/content/public/browser/render_widget_host_view.h b/content/public/browser/render_widget_host_view.h index b0f3732..c49760b 100644 --- a/content/public/browser/render_widget_host_view.h +++ b/content/public/browser/render_widget_host_view.h @@ -118,7 +118,7 @@ class CONTENT_EXPORT RenderWidgetHostView { // TODO(stuartmorgan): This is a temporary plugin-specific workaround for // <http://crbug.com/34266>. Once that is fixed, this (and the corresponding // message and renderer-side handling) can be removed in favor of using - // WasHidden/DidBecomeSelected. + // WasHidden/WasRestored. virtual void SetWindowVisibility(bool visible) = 0; // Informs the view that its containing window's frame changed. diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h index 0136e6a..f9b0430 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -191,20 +191,12 @@ class WebContents : public PageNavigator { // change. See InvalidateType enum. virtual void NotifyNavigationStateChanged(unsigned changed_flags) = 0; - // Invoked when the WebContents becomes selected. If you override, be sure - // and invoke super's implementation. - virtual void DidBecomeSelected() = 0; + // Get the last time that the WebContents was made visible with WasRestored() virtual base::TimeTicks GetLastSelectedTime() const = 0; - // Invoked when the WebContents becomes hidden. - virtual void WasHidden() = 0; - - // Invoked when the WebContents is restored. + // Invoked when the WebContents becomes shown/hidden. virtual void WasRestored() = 0; - - // TODO(brettw) document these. - virtual void ShowContents() = 0; - virtual void HideContents() = 0; + virtual void WasHidden() = 0; // Returns true if the before unload and unload listeners need to be // fired. The value of this changes over time. For example, if true and the diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h index c64d159..1f6c178 100644 --- a/content/public/browser/web_contents_observer.h +++ b/content/public/browser/web_contents_observer.h @@ -81,7 +81,6 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener, const string16& error_description) {} virtual void DidGetUserGesture() {} virtual void DidGetIgnoredUIEvent() {} - virtual void DidBecomeSelected() {} virtual void DidStartLoading() {} virtual void DidStopLoading() {} @@ -99,6 +98,8 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener, PageTransition transition, int64 source_frame_id) {} + virtual void WasRestored() {} + virtual void AppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy) {} |