diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 20:20:56 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-13 20:20:56 +0000 |
commit | 2db9bd7f4d790d11f25f6f6e4aef9fc731b2424e (patch) | |
tree | 8760ce4a92a006c89d06c5e287d49425367bcbde /content | |
parent | 38d0108dd611a2cb0b34eddcf295a233308821ba (diff) | |
download | chromium_src-2db9bd7f4d790d11f25f6f6e4aef9fc731b2424e.zip chromium_src-2db9bd7f4d790d11f25f6f6e4aef9fc731b2424e.tar.gz chromium_src-2db9bd7f4d790d11f25f6f6e4aef9fc731b2424e.tar.bz2 |
TabContents -> WebContentsImpl, part 12.
"Detab" content/browser/web_contents.
BUG=105875
TEST=no change
Review URL: http://codereview.chromium.org/10038026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132257 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
29 files changed, 334 insertions, 322 deletions
diff --git a/content/browser/ssl/ssl_manager.cc b/content/browser/ssl/ssl_manager.cc index 1b331cc..8a6f500 100644 --- a/content/browser/ssl/ssl_manager.cc +++ b/content/browser/ssl/ssl_manager.cc @@ -86,10 +86,10 @@ SSLManager::SSLManager(NavigationControllerImpl* controller) // Subscribe to various notifications. registrar_.Add( this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED, - content::Source<WebContents>(controller_->tab_contents())); + content::Source<WebContents>(controller_->web_contents())); registrar_.Add( this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, - content::Source<WebContents>(controller_->tab_contents())); + content::Source<WebContents>(controller_->web_contents())); registrar_.Add( this, content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, content::Source<NavigationController>(controller_)); @@ -219,7 +219,7 @@ void SSLManager::UpdateEntry(NavigationEntryImpl* entry) { SSLStatus original_ssl_status = entry->GetSSL(); // Copy! - policy()->UpdateEntry(entry, controller_->tab_contents()); + policy()->UpdateEntry(entry, controller_->web_contents()); if (!entry->GetSSL().Equals(original_ssl_status)) { content::NotificationService::current()->Notify( diff --git a/content/browser/web_contents/interstitial_page_impl.cc b/content/browser/web_contents/interstitial_page_impl.cc index 0091331..8c36f0e 100644 --- a/content/browser/web_contents/interstitial_page_impl.cc +++ b/content/browser/web_contents/interstitial_page_impl.cc @@ -127,13 +127,13 @@ class InterstitialPageImpl::InterstitialPageRVHViewDelegate // We keep a map of the various blocking pages shown as the UI tests need to // be able to retrieve them. typedef std::map<WebContents*, InterstitialPageImpl*> InterstitialPageMap; -static InterstitialPageMap* g_tab_to_interstitial_page; +static InterstitialPageMap* g_web_contents_to_interstitial_page; -// Initializes g_tab_to_interstitial_page in a thread-safe manner. -// Should be called before accessing g_tab_to_interstitial_page. +// Initializes g_web_contents_to_interstitial_page in a thread-safe manner. +// Should be called before accessing g_web_contents_to_interstitial_page. static void InitInterstitialPageMap() { - if (!g_tab_to_interstitial_page) - g_tab_to_interstitial_page = new InterstitialPageMap; + if (!g_web_contents_to_interstitial_page) + g_web_contents_to_interstitial_page = new InterstitialPageMap; } namespace content { @@ -149,8 +149,8 @@ InterstitialPage* InterstitialPage::GetInterstitialPage( WebContents* web_contents) { InitInterstitialPageMap(); InterstitialPageMap::const_iterator iter = - g_tab_to_interstitial_page->find(web_contents); - if (iter == g_tab_to_interstitial_page->end()) + g_web_contents_to_interstitial_page->find(web_contents); + if (iter == g_web_contents_to_interstitial_page->end()) return NULL; return iter->second; @@ -158,11 +158,11 @@ InterstitialPage* InterstitialPage::GetInterstitialPage( } // namespace content -InterstitialPageImpl::InterstitialPageImpl(WebContents* tab, +InterstitialPageImpl::InterstitialPageImpl(WebContents* web_contents, bool new_navigation, const GURL& url, InterstitialPageDelegate* delegate) - : tab_(static_cast<TabContents*>(tab)), + : web_contents_(static_cast<WebContentsImpl*>(web_contents)), url_(url), new_navigation_(new_navigation), should_discard_pending_nav_entry_(new_navigation), @@ -170,10 +170,10 @@ InterstitialPageImpl::InterstitialPageImpl(WebContents* tab, enabled_(true), action_taken_(NO_ACTION), render_view_host_(NULL), - original_child_id_(tab->GetRenderProcessHost()->GetID()), - original_rvh_id_(tab->GetRenderViewHost()->GetRoutingID()), - should_revert_tab_title_(false), - tab_was_loading_(false), + original_child_id_(web_contents->GetRenderProcessHost()->GetID()), + original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()), + should_revert_web_contents_title_(false), + web_contents_was_loading_(false), resource_dispatcher_host_notified_(false), ALLOW_THIS_IN_INITIALIZER_LIST(rvh_view_delegate_( new InterstitialPageRVHViewDelegate(this))), @@ -184,7 +184,7 @@ InterstitialPageImpl::InterstitialPageImpl(WebContents* tab, // (which is the case when the interstitial was triggered by a sub-resource on // a page) when we have a pending entry (in the process of loading a new top // frame). - DCHECK(new_navigation || !tab->GetController().GetPendingEntry()); + DCHECK(new_navigation || !web_contents->GetController().GetPendingEntry()); } InterstitialPageImpl::~InterstitialPageImpl() { @@ -195,8 +195,8 @@ void InterstitialPageImpl::Show() { // showing the new one. // Be careful not to take an action on the old interstitial more than once. InterstitialPageMap::const_iterator iter = - g_tab_to_interstitial_page->find(tab_); - if (iter != g_tab_to_interstitial_page->end()) { + g_web_contents_to_interstitial_page->find(web_contents_); + if (iter != g_web_contents_to_interstitial_page->end()) { InterstitialPageImpl* interstitial = iter->second; if (interstitial->action_taken_ != NO_ACTION) { interstitial->Hide(); @@ -218,16 +218,16 @@ void InterstitialPageImpl::Show() { TakeActionOnResourceDispatcher(BLOCK); // We need to be notified when the RenderViewHost is destroyed so we can // cancel the blocked requests. We cannot do that on - // NOTIFY_TAB_CONTENTS_DESTROYED as at that point the RenderViewHost has + // NOTIFY_WEB_CONTENTS_DESTROYED as at that point the RenderViewHost has // already been destroyed. notification_registrar_.Add( this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, - content::Source<RenderWidgetHost>(tab_->GetRenderViewHost())); + content::Source<RenderWidgetHost>(web_contents_->GetRenderViewHost())); - // Update the g_tab_to_interstitial_page map. - iter = g_tab_to_interstitial_page->find(tab_); - DCHECK(iter == g_tab_to_interstitial_page->end()); - (*g_tab_to_interstitial_page)[tab_] = this; + // Update the g_web_contents_to_interstitial_page map. + iter = g_web_contents_to_interstitial_page->find(web_contents_); + DCHECK(iter == g_web_contents_to_interstitial_page->end()); + (*g_web_contents_to_interstitial_page)[web_contents_] = this; if (new_navigation_) { NavigationEntryImpl* entry = new NavigationEntryImpl; @@ -238,7 +238,7 @@ void InterstitialPageImpl::Show() { // Give delegates a chance to set some states on the navigation entry. delegate_->OverrideEntry(entry); - tab_->GetControllerImpl().AddTransientEntry(entry); + web_contents_->GetControllerImpl().AddTransientEntry(entry); } DCHECK(!render_view_host_); @@ -251,19 +251,20 @@ void InterstitialPageImpl::Show() { notification_registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, - content::Source<WebContents>(tab_)); + content::Source<WebContents>(web_contents_)); notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, - content::Source<NavigationController>(&tab_->GetController())); + content::Source<NavigationController>(&web_contents_->GetController())); notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, - content::Source<NavigationController>(&tab_->GetController())); + content::Source<NavigationController>(&web_contents_->GetController())); notification_registrar_.Add( this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, content::Source<RenderViewHost>(render_view_host_)); } void InterstitialPageImpl::Hide() { - RenderWidgetHostView* old_view = tab_->GetRenderViewHost()->GetView(); - if (tab_->GetInterstitialPage() == this && + RenderWidgetHostView* old_view = + web_contents_->GetRenderViewHost()->GetView(); + if (web_contents_->GetInterstitialPage() == this && old_view && !old_view->IsShowing()) { // Show the original RVH since we're going away. Note it might not exist if // the renderer crashed while the interstitial was showing. @@ -277,31 +278,32 @@ void InterstitialPageImpl::Hide() { // (Note that in unit-tests the RVH may not have a view). if (render_view_host_->GetView() && render_view_host_->GetView()->HasFocus() && - tab_->GetRenderViewHost()->GetView()) { + web_contents_->GetRenderViewHost()->GetView()) { RenderWidgetHostViewPort::FromRWHV( - tab_->GetRenderViewHost()->GetView())->Focus(); + web_contents_->GetRenderViewHost()->GetView())->Focus(); } render_view_host_->Shutdown(); render_view_host_ = NULL; - if (tab_->GetInterstitialPage()) - tab_->remove_interstitial_page(); + if (web_contents_->GetInterstitialPage()) + web_contents_->remove_interstitial_page(); // Let's revert to the original title if necessary. - NavigationEntry* entry = tab_->GetController().GetActiveEntry(); - if (!new_navigation_ && should_revert_tab_title_) { - entry->SetTitle(original_tab_title_); - tab_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); + NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); + if (!new_navigation_ && should_revert_web_contents_title_) { + entry->SetTitle(original_web_contents_title_); + web_contents_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); } content::NotificationService::current()->Notify( content::NOTIFICATION_INTERSTITIAL_DETACHED, - content::Source<WebContents>(tab_), + content::Source<WebContents>(web_contents_), content::NotificationService::NoDetails()); - InterstitialPageMap::iterator iter = g_tab_to_interstitial_page->find(tab_); - DCHECK(iter != g_tab_to_interstitial_page->end()); - if (iter != g_tab_to_interstitial_page->end()) - g_tab_to_interstitial_page->erase(iter); + InterstitialPageMap::iterator iter = + g_web_contents_to_interstitial_page->find(web_contents_); + DCHECK(iter != g_web_contents_to_interstitial_page->end()); + if (iter != g_web_contents_to_interstitial_page->end()) + g_web_contents_to_interstitial_page->erase(iter); } void InterstitialPageImpl::Observe( @@ -395,18 +397,19 @@ void InterstitialPageImpl::DidNavigate( // The RenderViewHost has loaded its contents, we can show it now. render_view_host_->GetView()->Show(); - tab_->set_interstitial_page(this); + web_contents_->set_interstitial_page(this); // This notification hides the bookmark bar. Note that this has to happen - // after the interstitial page was registered with |tab_|, since there will be - // a callback to |tab_| testing if an interstitial page is showing before - // hiding the bookmark bar. + // after the interstitial page was registered with |web_contents_|, since + // there will be a callback to |web_contents_| testing if an interstitial page + // is showing before hiding the bookmark bar. content::NotificationService::current()->Notify( content::NOTIFICATION_INTERSTITIAL_ATTACHED, - content::Source<WebContents>(tab_), + content::Source<WebContents>(web_contents_), content::NotificationService::NoDetails()); - RenderWidgetHostView* rwh_view = tab_->GetRenderViewHost()->GetView(); + RenderWidgetHostView* rwh_view = + web_contents_->GetRenderViewHost()->GetView(); // The RenderViewHost may already have crashed before we even get here. if (rwh_view) { @@ -423,8 +426,8 @@ void InterstitialPageImpl::DidNavigate( // by the UI tests) expects to consider a navigation as complete. Without // this, navigating in a UI test to a URL that triggers an interstitial would // hang. - tab_was_loading_ = tab_->IsLoading(); - tab_->SetIsLoading(false, NULL); + web_contents_was_loading_ = web_contents_->IsLoading(); + web_contents_->SetIsLoading(false, NULL); } void InterstitialPageImpl::UpdateTitle( @@ -433,7 +436,7 @@ void InterstitialPageImpl::UpdateTitle( const string16& title, base::i18n::TextDirection title_direction) { DCHECK(render_view_host == render_view_host_); - NavigationEntry* entry = tab_->GetController().GetActiveEntry(); + NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); if (!entry) { // Crash reports from the field indicate this can be NULL. // This is unexpected as InterstitialPages constructed with the @@ -449,14 +452,14 @@ void InterstitialPageImpl::UpdateTitle( // If this interstitial is shown on an existing navigation entry, we'll need // to remember its title so we can revert to it when hidden. - if (!new_navigation_ && !should_revert_tab_title_) { - original_tab_title_ = entry->GetTitle(); - should_revert_tab_title_ = true; + if (!new_navigation_ && !should_revert_web_contents_title_) { + original_web_contents_title_ = entry->GetTitle(); + should_revert_web_contents_title_ = true; } // TODO(evan): make use of title_direction. // http://code.google.com/p/chromium/issues/detail?id=27094 entry->SetTitle(title); - tab_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); + web_contents_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); } content::RendererPreferences InterstitialPageImpl::GetRendererPrefs( @@ -466,27 +469,27 @@ content::RendererPreferences InterstitialPageImpl::GetRendererPrefs( } WebPreferences InterstitialPageImpl::GetWebkitPrefs() { - return TabContents::GetWebkitPrefs(render_view_host_, url_); + return WebContentsImpl::GetWebkitPrefs(render_view_host_, url_); } bool InterstitialPageImpl::PreHandleKeyboardEvent( const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { - return tab_->PreHandleKeyboardEvent(event, is_keyboard_shortcut); + return web_contents_->PreHandleKeyboardEvent(event, is_keyboard_shortcut); } void InterstitialPageImpl::HandleKeyboardEvent( const NativeWebKeyboardEvent& event) { - return tab_->HandleKeyboardEvent(event); + return web_contents_->HandleKeyboardEvent(event); } -WebContents* InterstitialPageImpl::tab() const { - return tab_; +WebContents* InterstitialPageImpl::web_contents() const { + return web_contents_; } RenderViewHost* InterstitialPageImpl::CreateRenderViewHost() { RenderViewHostImpl* render_view_host = new RenderViewHostImpl( - SiteInstance::Create(tab()->GetBrowserContext()), + SiteInstance::Create(web_contents()->GetBrowserContext()), this, MSG_ROUTING_NONE, dom_storage::kInvalidSessionStorageNamespaceId); return render_view_host; } @@ -494,14 +497,14 @@ RenderViewHost* InterstitialPageImpl::CreateRenderViewHost() { WebContentsView* InterstitialPageImpl::CreateWebContentsView() { if (!create_view_) return NULL; - WebContentsView* web_contents_view = tab()->GetView(); + WebContentsView* web_contents_view = web_contents()->GetView(); RenderWidgetHostView* view = web_contents_view->CreateViewForWidget(render_view_host_); render_view_host_->SetView(view); render_view_host_->AllowBindings(content::BINDINGS_POLICY_DOM_AUTOMATION); - int32 max_page_id = - tab()->GetMaxPageIDForSiteInstance(render_view_host_->GetSiteInstance()); + int32 max_page_id = web_contents()-> + GetMaxPageIDForSiteInstance(render_view_host_->GetSiteInstance()); render_view_host_->CreateRenderView(string16(), max_page_id); view->SetSize(web_contents_view->GetContainerSize()); // Don't show the interstitial until we have navigated to it. @@ -518,8 +521,8 @@ void InterstitialPageImpl::Proceed() { action_taken_ = PROCEED_ACTION; // Resumes the throbber, if applicable. - if (tab_was_loading_) - tab_->SetIsLoading(true, NULL); + if (web_contents_was_loading_) + web_contents_->SetIsLoading(true, NULL); // If this is a new navigation, the old page is going away, so we cancel any // blocked requests for it. If it is not a new navigation, then it means the @@ -563,11 +566,11 @@ void InterstitialPageImpl::DontProceed() { // explicitely. Note that by calling DiscardNonCommittedEntries() we also // discard the pending entry, which is what we want, since the navigation is // cancelled. - tab_->GetController().DiscardNonCommittedEntries(); + web_contents_->GetController().DiscardNonCommittedEntries(); } if (reload_on_dont_proceed_) - tab_->GetController().Reload(true); + web_contents_->GetController().Reload(true); Hide(); delegate_->OnDontProceed(); @@ -735,13 +738,14 @@ void InterstitialPageImpl::InterstitialPageRVHViewDelegate::GotFocus() { void InterstitialPageImpl::InterstitialPageRVHViewDelegate::TakeFocus( bool reverse) { - if (!interstitial_page_->tab()) + if (!interstitial_page_->web_contents()) return; - TabContents* tab = static_cast<TabContents*>(interstitial_page_->tab()); - if (!tab->GetViewDelegate()) + WebContentsImpl* web_contents = + static_cast<WebContentsImpl*>(interstitial_page_->web_contents()); + if (!web_contents->GetViewDelegate()) return; - tab->GetViewDelegate()->TakeFocus(reverse); + web_contents->GetViewDelegate()->TakeFocus(reverse); } void InterstitialPageImpl::InterstitialPageRVHViewDelegate::OnFindReply( diff --git a/content/browser/web_contents/interstitial_page_impl.h b/content/browser/web_contents/interstitial_page_impl.h index 2b6c026..f305f20 100644 --- a/content/browser/web_contents/interstitial_page_impl.h +++ b/content/browser/web_contents/interstitial_page_impl.h @@ -42,7 +42,7 @@ class CONTENT_EXPORT InterstitialPageImpl DONT_PROCEED_ACTION // "Don't proceed" was selected. }; - InterstitialPageImpl(content::WebContents* tab, + InterstitialPageImpl(content::WebContents* web_contents, bool new_navigation, const GURL& url, content::InterstitialPageDelegate* delegate); @@ -104,7 +104,7 @@ class CONTENT_EXPORT InterstitialPageImpl virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; bool enabled() const { return enabled_; } - content::WebContents* tab() const; + content::WebContents* web_contents() const; const GURL& url() const { return url_; } // Creates the RenderViewHost containing the interstitial content. @@ -132,7 +132,7 @@ class CONTENT_EXPORT InterstitialPageImpl void TakeActionOnResourceDispatcher(ResourceRequestAction action); // The contents in which we are displayed. - WebContentsImpl* tab_; + WebContentsImpl* web_contents_; // The URL that is shown when the interstitial is showing. GURL url_; @@ -166,21 +166,21 @@ class CONTENT_EXPORT InterstitialPageImpl int original_child_id_; int original_rvh_id_; - // Whether or not we should change the title of the tab when hidden (to revert - // it to its original value). - bool should_revert_tab_title_; + // Whether or not we should change the title of the contents when hidden (to + // revert it to its original value). + bool should_revert_web_contents_title_; - // Whether or not the tab was loading resources when the interstitial was + // Whether or not the contents was loading resources when the interstitial was // shown. We restore this state if the user proceeds from the interstitial. - bool tab_was_loading_; + bool web_contents_was_loading_; // Whether the ResourceDispatcherHost has been notified to cancel/resume the // resource requests blocked for the RenderViewHost. bool resource_dispatcher_host_notified_; - // The original title of the tab that should be reverted to when the + // The original title of the contents that should be reverted to when the // interstitial is hidden. - string16 original_tab_title_; + string16 original_web_contents_title_; // Our RenderViewHostViewDelegate, necessary for accelerators to work. scoped_ptr<InterstitialPageRVHViewDelegate> rvh_view_delegate_; diff --git a/content/browser/web_contents/navigation_controller_impl.cc b/content/browser/web_contents/navigation_controller_impl.cc index 5a841ee..a89d494 100644 --- a/content/browser/web_contents/navigation_controller_impl.cc +++ b/content/browser/web_contents/navigation_controller_impl.cc @@ -148,7 +148,7 @@ NavigationEntry* NavigationController::CreateNavigationEntry( NavigationEntryImpl* entry = new NavigationEntryImpl( NULL, // The site instance for tabs is sent on navigation - // (TabContents::GetSiteInstance). + // (WebContents::GetSiteInstance). -1, loaded_url, referrer, @@ -170,7 +170,7 @@ void NavigationController::DisablePromptOnRepost() { } // namespace content NavigationControllerImpl::NavigationControllerImpl( - TabContents* contents, + WebContentsImpl* web_contents, BrowserContext* browser_context, SessionStorageNamespaceImpl* session_storage_namespace) : browser_context_(browser_context), @@ -178,7 +178,7 @@ NavigationControllerImpl::NavigationControllerImpl( last_committed_entry_index_(-1), pending_entry_index_(-1), transient_entry_index_(-1), - tab_contents_(contents), + web_contents_(web_contents), max_restored_page_id_(-1), ALLOW_THIS_IN_INITIALIZER_LIST(ssl_manager_(this)), needs_reload_(false), @@ -202,7 +202,7 @@ NavigationControllerImpl::~NavigationControllerImpl() { } WebContents* NavigationControllerImpl::GetWebContents() const { - return tab_contents_; + return web_contents_; } BrowserContext* NavigationControllerImpl::GetBrowserContext() const { @@ -267,8 +267,8 @@ void NavigationControllerImpl::ReloadInternal(bool check_for_repost, content::NotificationService::NoDetails()); pending_reload_ = reload_type; - tab_contents_->Activate(); - tab_contents_->GetDelegate()->ShowRepostFormWarningDialog(tab_contents_); + web_contents_->Activate(); + web_contents_->GetDelegate()->ShowRepostFormWarningDialog(web_contents_); } else { DiscardNonCommittedEntriesInternal(); @@ -405,10 +405,10 @@ NavigationEntry* NavigationControllerImpl::GetLastCommittedEntry() const { bool NavigationControllerImpl::CanViewSource() const { bool is_supported_mime_type = net::IsSupportedNonImageMimeType( - tab_contents_->GetContentsMimeType().c_str()); + web_contents_->GetContentsMimeType().c_str()); NavigationEntry* active_entry = GetActiveEntry(); return active_entry && !active_entry->IsViewSourceMode() && - is_supported_mime_type && !tab_contents_->GetInterstitialPage(); + is_supported_mime_type && !web_contents_->GetInterstitialPage(); } int NavigationControllerImpl::GetLastCommittedEntryIndex() const { @@ -552,7 +552,7 @@ void NavigationControllerImpl::AddTransientEntry(NavigationEntryImpl* entry) { entries_.insert( entries_.begin() + index, linked_ptr<NavigationEntryImpl>(entry)); transient_entry_index_ = index; - tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); + web_contents_->NotifyNavigationStateChanged(kInvalidateAll); } void NavigationControllerImpl::TransferURL( @@ -669,7 +669,7 @@ bool NavigationControllerImpl::RendererDidNavigate( // the caller that nothing has happened. if (pending_entry_) { DiscardNonCommittedEntries(); - tab_contents_->NotifyNavigationStateChanged( + web_contents_->NotifyNavigationStateChanged( content::INVALIDATE_TYPE_URL); } return false; @@ -689,7 +689,7 @@ bool NavigationControllerImpl::RendererDidNavigate( active_entry->set_is_renderer_initiated(false); // The active entry's SiteInstance should match our SiteInstance. - DCHECK(active_entry->site_instance() == tab_contents_->GetSiteInstance()); + DCHECK(active_entry->site_instance() == web_contents_->GetSiteInstance()); // Now prep the rest of the details for the notification and broadcast. details->entry = active_entry; @@ -726,7 +726,7 @@ content::NavigationType NavigationControllerImpl::ClassifyNavigation( return content::NAVIGATION_TYPE_NAV_IGNORE; } - if (params.page_id > tab_contents_->GetMaxPageID()) { + if (params.page_id > web_contents_->GetMaxPageID()) { // Greater page IDs than we've ever seen before are new pages. We may or may // not have a pending entry for the page, and this may or may not be the // main frame. @@ -747,7 +747,7 @@ content::NavigationType NavigationControllerImpl::ClassifyNavigation( // Now we know that the notification is for an existing page. Find that entry. int existing_entry_index = GetEntryIndexWithPageID( - tab_contents_->GetSiteInstance(), + web_contents_->GetSiteInstance(), params.page_id); if (existing_entry_index == -1) { // The page was not found. It could have been pruned because of the limit on @@ -766,7 +766,7 @@ content::NavigationType NavigationControllerImpl::ClassifyNavigation( temp.append("#page"); temp.append(base::IntToString(params.page_id)); temp.append("#max"); - temp.append(base::IntToString(tab_contents_->GetMaxPageID())); + temp.append(base::IntToString(web_contents_->GetMaxPageID())); temp.append("#frame"); temp.append(base::IntToString(params.frame_id)); temp.append("#ids"); @@ -781,13 +781,13 @@ content::NavigationType NavigationControllerImpl::ClassifyNavigation( temp.append(base::IntToString(entries_[i]->site_instance()->GetId())); else temp.append("N"); - if (entries_[i]->site_instance() != tab_contents_->GetSiteInstance()) + if (entries_[i]->site_instance() != web_contents_->GetSiteInstance()) temp.append("x"); temp.append(","); } GURL url(temp); static_cast<RenderViewHostImpl*>( - tab_contents_->GetRenderViewHost())->Send( + web_contents_->GetRenderViewHost())->Send( new ViewMsg_TempCrashWithData(url)); return content::NAVIGATION_TYPE_NAV_IGNORE; } @@ -870,7 +870,7 @@ void NavigationControllerImpl::RendererDidNavigateToNewPage( new_entry->SetPageID(params.page_id); new_entry->SetTransitionType(params.transition); new_entry->set_site_instance( - static_cast<SiteInstanceImpl*>(tab_contents_->GetSiteInstance())); + static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance())); new_entry->SetHasPostData(params.is_post); new_entry->SetPostID(params.post_id); @@ -885,7 +885,7 @@ void NavigationControllerImpl::RendererDidNavigateToExistingPage( // This is a back/forward navigation. The existing page for the ID is // guaranteed to exist by ClassifyNavigation, and we just need to update it // with new information from the renderer. - int entry_index = GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), + int entry_index = GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); DCHECK(entry_index >= 0 && entry_index < static_cast<int>(entries_.size())); @@ -898,9 +898,9 @@ void NavigationControllerImpl::RendererDidNavigateToExistingPage( if (entry->update_virtual_url_with_url()) UpdateVirtualURLToURL(entry, params.url); DCHECK(entry->site_instance() == NULL || - entry->site_instance() == tab_contents_->GetSiteInstance()); + entry->site_instance() == web_contents_->GetSiteInstance()); entry->set_site_instance( - static_cast<SiteInstanceImpl*>(tab_contents_->GetSiteInstance())); + static_cast<SiteInstanceImpl*>(web_contents_->GetSiteInstance())); entry->SetHasPostData(params.is_post); entry->SetPostID(params.post_id); @@ -920,7 +920,7 @@ void NavigationControllerImpl::RendererDidNavigateToExistingPage( // If a transient entry was removed, the indices might have changed, so we // have to query the entry index again. last_committed_entry_index_ = - GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), params.page_id); + GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); } void NavigationControllerImpl::RendererDidNavigateToSamePage( @@ -929,7 +929,7 @@ void NavigationControllerImpl::RendererDidNavigateToSamePage( // entry for this page ID. This entry is guaranteed to exist by // ClassifyNavigation. All we need to do is update the existing entry. NavigationEntryImpl* existing_entry = GetEntryWithPageID( - tab_contents_->GetSiteInstance(), params.page_id); + web_contents_->GetSiteInstance(), params.page_id); // We assign the entry's unique ID to be that of the new one. Since this is // always the result of a user action, we want to dismiss infobars, etc. like @@ -950,7 +950,7 @@ void NavigationControllerImpl::RendererDidNavigateInPage( "WebKit should only tell us about in-page navs for the main frame."; // We're guaranteed to have an entry for this one. NavigationEntryImpl* existing_entry = GetEntryWithPageID( - tab_contents_->GetSiteInstance(), params.page_id); + web_contents_->GetSiteInstance(), params.page_id); // Reference fragment navigation. We're guaranteed to have the last_committed // entry and it will be the same page as the new navigation (minus the @@ -969,7 +969,7 @@ void NavigationControllerImpl::RendererDidNavigateInPage( // If a transient entry was removed, the indices might have changed, so we // have to query the entry index again. last_committed_entry_index_ = - GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), params.page_id); + GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); } void NavigationControllerImpl::RendererDidNavigateNewSubframe( @@ -1002,7 +1002,7 @@ bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( // navigation entry. This is case "2." in NAV_AUTO_SUBFRAME comment in the // header file. In case "1." this will be a NOP. int entry_index = GetEntryIndexWithPageID( - tab_contents_->GetSiteInstance(), + web_contents_->GetSiteInstance(), params.page_id); if (entry_index < 0 || entry_index >= static_cast<int>(entries_.size())) { @@ -1054,7 +1054,7 @@ void NavigationControllerImpl::CopyStateFrom( // Copy the max page id map from the old tab to the new tab. This ensures // that new and existing navigations in the tab's current SiteInstances // are identified properly. - tab_contents_->CopyMaxPageIDsFrom(source.tab_contents()); + web_contents_->CopyMaxPageIDsFrom(source.web_contents()); } void NavigationControllerImpl::CopyStateFromAndPrune( @@ -1071,7 +1071,7 @@ void NavigationControllerImpl::CopyStateFromAndPrune( last_committed ? last_committed->site_instance() : NULL); int32 minimum_page_id = last_committed ? last_committed->GetPageID() : -1; int32 max_page_id = last_committed ? - tab_contents_->GetMaxPageIDForSiteInstance(site_instance.get()) : -1; + web_contents_->GetMaxPageIDForSiteInstance(site_instance.get()) : -1; // This code is intended for use when the last entry is the active entry. DCHECK( @@ -1112,19 +1112,19 @@ void NavigationControllerImpl::CopyStateFromAndPrune( last_committed_entry_index_--; } - tab_contents_->SetHistoryLengthAndPrune(site_instance.get(), + web_contents_->SetHistoryLengthAndPrune(site_instance.get(), max_source_index, minimum_page_id); // Copy the max page id map from the old tab to the new tab. This ensures // that new and existing navigations in the tab's current SiteInstances // are identified properly. - tab_contents_->CopyMaxPageIDsFrom(source->tab_contents()); + web_contents_->CopyMaxPageIDsFrom(source->web_contents()); // If there is a last committed entry, be sure to include it in the new // max page ID map. if (max_page_id > -1) { - tab_contents_->UpdateMaxPageIDForSiteInstance(site_instance.get(), + web_contents_->UpdateMaxPageIDForSiteInstance(site_instance.get(), max_page_id); } } @@ -1159,11 +1159,11 @@ void NavigationControllerImpl::PruneAllButActive() { entries_.clear(); } - if (tab_contents_->GetInterstitialPage()) { + if (web_contents_->GetInterstitialPage()) { // Normally the interstitial page hides itself if the user doesn't proceeed. // This would result in showing a NavigationEntry we just removed. Set this // so the interstitial triggers a reload if the user doesn't proceed. - static_cast<InterstitialPageImpl*>(tab_contents_->GetInterstitialPage())-> + static_cast<InterstitialPageImpl*>(web_contents_->GetInterstitialPage())-> set_reload_on_dont_proceed(true); } } @@ -1203,7 +1203,7 @@ void NavigationControllerImpl::DiscardNonCommittedEntries() { // If there was a transient entry, invalidate everything so the new active // entry state is shown. if (transient) { - tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); + web_contents_->NotifyNavigationStateChanged(kInvalidateAll); } } @@ -1256,7 +1256,7 @@ void NavigationControllerImpl::InsertOrReplaceEntry(NavigationEntryImpl* entry, last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1; // This is a new page ID, so we need everybody to know about it. - tab_contents_->UpdateMaxPageID(entry->GetPageID()); + web_contents_->UpdateMaxPageID(entry->GetPageID()); } void NavigationControllerImpl::PruneOldestEntryIfFull() { @@ -1283,12 +1283,12 @@ void NavigationControllerImpl::NavigateToPendingEntry(ReloadType reload_type) { NavigationEntryImpl::RESTORE_NONE) && (entries_[pending_entry_index_]->GetTransitionType() & content::PAGE_TRANSITION_FORWARD_BACK)) { - tab_contents_->Stop(); + web_contents_->Stop(); // If an interstitial page is showing, we want to close it to get back // to what was showing before. - if (tab_contents_->GetInterstitialPage()) - tab_contents_->GetInterstitialPage()->DontProceed(); + if (web_contents_->GetInterstitialPage()) + web_contents_->GetInterstitialPage()->DontProceed(); DiscardNonCommittedEntries(); return; @@ -1298,8 +1298,8 @@ void NavigationControllerImpl::NavigateToPendingEntry(ReloadType reload_type) { // cannot make new requests. Unblock (and disable) it to allow this // navigation to succeed. The interstitial will stay visible until the // resulting DidNavigate. - if (tab_contents_->GetInterstitialPage()) { - static_cast<InterstitialPageImpl*>(tab_contents_->GetInterstitialPage())-> + if (web_contents_->GetInterstitialPage()) { + static_cast<InterstitialPageImpl*>(web_contents_->GetInterstitialPage())-> CancelForNavigation(); } @@ -1309,17 +1309,17 @@ void NavigationControllerImpl::NavigateToPendingEntry(ReloadType reload_type) { pending_entry_ = entries_[pending_entry_index_].get(); } - if (!tab_contents_->NavigateToPendingEntry(reload_type)) + if (!web_contents_->NavigateToPendingEntry(reload_type)) DiscardNonCommittedEntries(); // If the entry is being restored and doesn't have a SiteInstance yet, fill // it in now that we know. This allows us to find the entry when it commits. // This works for browser-initiated navigations. We handle renderer-initiated - // navigations to restored entries in TabContents::OnGoToEntryAtOffset. + // navigations to restored entries in WebContentsImpl::OnGoToEntryAtOffset. if (pending_entry_ && !pending_entry_->site_instance() && pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) { pending_entry_->set_site_instance(static_cast<SiteInstanceImpl*>( - tab_contents_->GetPendingSiteInstance())); + web_contents_->GetPendingSiteInstance())); pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); } } @@ -1330,7 +1330,7 @@ void NavigationControllerImpl::NotifyNavigationEntryCommitted( content::NotificationDetails notification_details = content::Details<content::LoadCommittedDetails>(details); - // We need to notify the ssl_manager_ before the tab_contents_ so the + // We need to notify the ssl_manager_ before the web_contents_ so the // location bar will have up-to-date information about the security style // when it wants to draw. See http://crbug.com/11157 ssl_manager_.DidCommitProvisionalLoad(notification_details); @@ -1338,7 +1338,7 @@ void NavigationControllerImpl::NotifyNavigationEntryCommitted( // TODO(pkasting): http://b/1113079 Probably these explicit notification paths // should be removed, and interested parties should just listen for the // notification below instead. - tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); + web_contents_->NotifyNavigationStateChanged(kInvalidateAll); content::NotificationService::current()->Notify( content::NOTIFICATION_NAV_ENTRY_COMMITTED, diff --git a/content/browser/web_contents/navigation_controller_impl.h b/content/browser/web_contents/navigation_controller_impl.h index 71f1f52..dfe4dd6 100644 --- a/content/browser/web_contents/navigation_controller_impl.h +++ b/content/browser/web_contents/navigation_controller_impl.h @@ -28,7 +28,7 @@ class CONTENT_EXPORT NavigationControllerImpl : public NON_EXPORTED_BASE(content::NavigationController) { public: NavigationControllerImpl( - WebContentsImpl* tab_contents, + WebContentsImpl* web_contents, content::BrowserContext* browser_context, SessionStorageNamespaceImpl* session_storage_namespace); virtual ~NavigationControllerImpl(); @@ -124,10 +124,8 @@ class CONTENT_EXPORT NavigationControllerImpl // WebContentsImpl ----------------------------------------------------------- - WebContentsImpl* tab_contents() const { - // This currently returns the active tab contents which should be renamed to - // tab_contents. - return tab_contents_; + WebContentsImpl* web_contents() const { + return web_contents_; } // Called when a document has been loaded in a frame. @@ -298,9 +296,9 @@ class CONTENT_EXPORT NavigationControllerImpl // after the transient entry will become invalid if you navigate forward. int transient_entry_index_; - // The tab contents associated with the controller. Possibly NULL during + // The WebContents associated with the controller. Possibly NULL during // setup. - WebContentsImpl* tab_contents_; + WebContentsImpl* web_contents_; // The max restored page ID in this controller, if it was restored. We must // store this so that WebContentsImpl can tell any renderer in charge of one diff --git a/content/browser/web_contents/navigation_controller_impl_unittest.cc b/content/browser/web_contents/navigation_controller_impl_unittest.cc index 3812a38..36e89daf 100644 --- a/content/browser/web_contents/navigation_controller_impl_unittest.cc +++ b/content/browser/web_contents/navigation_controller_impl_unittest.cc @@ -1542,7 +1542,7 @@ TEST_F(NavigationControllerTest, RestoreNavigate) { entry->SetTitle(ASCIIToUTF16("Title")); entry->SetContentState("state"); entries.push_back(entry); - TabContents our_contents( + WebContentsImpl our_contents( browser_context(), NULL, MSG_ROUTING_NONE, NULL, NULL); NavigationControllerImpl& our_controller = our_contents.GetControllerImpl(); our_controller.Restore(0, true, &entries); @@ -1609,7 +1609,7 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { entry->SetTitle(ASCIIToUTF16("Title")); entry->SetContentState("state"); entries.push_back(entry); - TabContents our_contents( + WebContentsImpl our_contents( browser_context(), NULL, MSG_ROUTING_NONE, NULL, NULL); NavigationControllerImpl& our_controller = our_contents.GetControllerImpl(); our_controller.Restore(0, true, &entries); @@ -1990,7 +1990,8 @@ TEST_F(NavigationControllerTest, SameSubframe) { EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); } -// Make sure that on cloning a tabcontents and going back needs_reload is false. +// Make sure that on cloning a WebContentsImpl and going back needs_reload is +// false. TEST_F(NavigationControllerTest, CloneAndGoBack) { NavigationControllerImpl& controller = controller_impl(); const GURL url1("http://foo1"); @@ -2008,7 +2009,7 @@ TEST_F(NavigationControllerTest, CloneAndGoBack) { EXPECT_FALSE(clone->GetController().NeedsReload()); } -// Make sure that cloning a tabcontents doesn't copy interstitials. +// Make sure that cloning a WebContentsImpl doesn't copy interstitials. TEST_F(NavigationControllerTest, CloneOmitsInterstitials) { NavigationControllerImpl& controller = controller_impl(); const GURL url1("http://foo1"); diff --git a/content/browser/web_contents/render_view_host_manager.cc b/content/browser/web_contents/render_view_host_manager.cc index 0984a81..e4c5bff 100644 --- a/content/browser/web_contents/render_view_host_manager.cc +++ b/content/browser/web_contents/render_view_host_manager.cc @@ -241,7 +241,7 @@ void RenderViewHostManager::RendererAbortedProvisionalLoad( RenderViewHost* render_view_host) { // We used to cancel the pending renderer here for cross-site downloads. // However, it's not safe to do that because the download logic repeatedly - // looks for this TabContents based on a render view ID. Instead, we just + // looks for this WebContents based on a render view ID. Instead, we just // leave the pending renderer around until the next navigation event // (Navigate, DidNavigate, etc), which will clean it up properly. // TODO(creis): All of this will go away when we move the cross-site logic diff --git a/content/browser/web_contents/render_view_host_manager.h b/content/browser/web_contents/render_view_host_manager.h index d0c9232..04825c5 100644 --- a/content/browser/web_contents/render_view_host_manager.h +++ b/content/browser/web_contents/render_view_host_manager.h @@ -29,7 +29,7 @@ class RenderWidgetHostView; class TestWebContents; } -// Manages RenderViewHosts for a TabContents. Normally there is only one and +// Manages RenderViewHosts for a WebContentsImpl. Normally there is only one and // it is easy to do. But we can also have transitions of processes (and hence // RenderViewHosts) that can get complex. class CONTENT_EXPORT RenderViewHostManager @@ -38,18 +38,18 @@ class CONTENT_EXPORT RenderViewHostManager public: // Functions implemented by our owner that we need. // - // TODO(brettw) Clean this up! These are all the functions in TabContents that - // are required to run this class. The design should probably be better such - // that these are more clear. + // TODO(brettw) Clean this up! These are all the functions in WebContentsImpl + // that are required to run this class. The design should probably be better + // such that these are more clear. // // There is additional complexity that some of the functions we need in - // TabContents are inherited and non-virtual. These are named with + // WebContentsImpl are inherited and non-virtual. These are named with // "RenderManager" so that the duplicate implementation of them will be clear. class CONTENT_EXPORT Delegate { public: // Initializes the given renderer if necessary and creates the view ID // corresponding to this view host. If this method is not called and the - // process is not shared, then the TabContents will act as though the + // process is not shared, then the WebContentsImpl will act as though the // renderer is not running (i.e., it will render "sad tab"). This method is // automatically called from LoadURL. // @@ -101,7 +101,7 @@ class CONTENT_EXPORT RenderViewHostManager Delegate* delegate); virtual ~RenderViewHostManager(); - // For arguments, see TabContents constructor. + // For arguments, see WebContentsImpl constructor. void Init(content::BrowserContext* browser_context, content::SiteInstance* site_instance, int routing_id); diff --git a/content/browser/web_contents/render_view_host_manager_unittest.cc b/content/browser/web_contents/render_view_host_manager_unittest.cc index fc10594c..8a33f49 100644 --- a/content/browser/web_contents/render_view_host_manager_unittest.cc +++ b/content/browser/web_contents/render_view_host_manager_unittest.cc @@ -364,7 +364,7 @@ TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) { EXPECT_TRUE(kUrl == controller().GetLastCommittedEntry()->GetURL()); EXPECT_FALSE(controller().GetPendingEntry()); // Because we're using TestWebContents and TestRenderViewHost in this - // unittest, no one calls TabContents::RenderViewCreated(). So, we see no + // unittest, no one calls WebContentsImpl::RenderViewCreated(). So, we see no // EnableViewSourceMode message, here. // Clear queued messages before load. diff --git a/content/browser/web_contents/test_web_contents.cc b/content/browser/web_contents/test_web_contents.cc index 36292b7..32f0e71 100644 --- a/content/browser/web_contents/test_web_contents.cc +++ b/content/browser/web_contents/test_web_contents.cc @@ -21,7 +21,7 @@ namespace content { TestWebContents::TestWebContents(BrowserContext* browser_context, SiteInstance* instance) - : TabContents(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), + : WebContentsImpl(browser_context, instance, MSG_ROUTING_NONE, NULL, NULL), transition_cross_site(false), delegate_view_override_(NULL), expect_set_history_length_and_prune_(false), @@ -91,11 +91,11 @@ bool TestWebContents::CreateRenderViewForRenderManager( } WebContents* TestWebContents::Clone() { - TabContents* tc = new TestWebContents( + WebContentsImpl* contents = new TestWebContents( GetBrowserContext(), SiteInstance::Create(GetBrowserContext())); - tc->GetControllerImpl().CopyStateFrom(controller_); - return tc; + contents->GetControllerImpl().CopyStateFrom(controller_); + return contents; } void TestWebContents::NavigateAndCommit(const GURL& url) { @@ -153,7 +153,7 @@ void TestWebContents::ProceedWithCrossSiteNavigation() { RenderViewHostDelegate::View* TestWebContents::GetViewDelegate() { if (delegate_view_override_) return delegate_view_override_; - return TabContents::GetViewDelegate(); + return WebContentsImpl::GetViewDelegate(); } void TestWebContents::ExpectSetHistoryLengthAndPrune( diff --git a/content/browser/web_contents/test_web_contents.h b/content/browser/web_contents/test_web_contents.h index fb0ef7a..7267cab 100644 --- a/content/browser/web_contents/test_web_contents.h +++ b/content/browser/web_contents/test_web_contents.h @@ -19,9 +19,9 @@ class RenderViewHost; class TestRenderViewHost; class WebContentsTester; -// Subclass TabContents to ensure it creates TestRenderViewHosts +// Subclass WebContentsImpl to ensure it creates TestRenderViewHosts // and does not do anything involving views. -class TestWebContents : public TabContents, public WebContentsTester { +class TestWebContents : public WebContentsImpl, public WebContentsTester { public: TestWebContents(BrowserContext* browser_context, SiteInstance* instance); virtual ~TestWebContents(); @@ -50,8 +50,8 @@ class TestWebContents : public TabContents, public WebContentsTester { return render_manager_.cross_navigation_pending_; } - // Overrides TabContents::ShouldTransitionCrossSite so that we can test both - // alternatives without using command-line switches. + // Overrides WebContentsImpl::ShouldTransitionCrossSite so that we can test + // both alternatives without using command-line switches. bool ShouldTransitionCrossSite() { return transition_cross_site; } // Prevent interaction with views. diff --git a/content/browser/web_contents/web_contents_delegate_unittest.cc b/content/browser/web_contents/web_contents_delegate_unittest.cc index df71ae9..a4b1d8a 100644 --- a/content/browser/web_contents/web_contents_delegate_unittest.cc +++ b/content/browser/web_contents/web_contents_delegate_unittest.cc @@ -21,10 +21,16 @@ TEST(WebContentsDelegateTest, UnregisterInDestructor) { MessageLoop loop(MessageLoop::TYPE_UI); TestBrowserContext browser_context; - scoped_ptr<TabContents> contents_a( - new TabContents(&browser_context, NULL, MSG_ROUTING_NONE, NULL, NULL)); - scoped_ptr<TabContents> contents_b( - new TabContents(&browser_context, NULL, MSG_ROUTING_NONE, NULL, NULL)); + scoped_ptr<WebContentsImpl> contents_a(new WebContentsImpl(&browser_context, + NULL, + MSG_ROUTING_NONE, + NULL, + NULL)); + scoped_ptr<WebContentsImpl> contents_b(new WebContentsImpl(&browser_context, + NULL, + MSG_ROUTING_NONE, + NULL, + NULL)); EXPECT_TRUE(contents_a->GetDelegate() == NULL); EXPECT_TRUE(contents_b->GetDelegate() == NULL); @@ -35,7 +41,7 @@ TEST(WebContentsDelegateTest, UnregisterInDestructor) { EXPECT_EQ(delegate.get(), contents_a->GetDelegate()); EXPECT_TRUE(contents_b->GetDelegate() == NULL); - // A delegate can be a delegate to multiple TabContents. + // A delegate can be a delegate to multiple WebContentsImpl. contents_b->SetDelegate(delegate.get()); EXPECT_EQ(delegate.get(), contents_a->GetDelegate()); EXPECT_EQ(delegate.get(), contents_b->GetDelegate()); @@ -51,7 +57,7 @@ TEST(WebContentsDelegateTest, UnregisterInDestructor) { EXPECT_TRUE(contents_b->GetDelegate() == NULL); // Destroying the delegate while it is still the delegate - // for a TabContents should unregister it. + // for a WebContentsImpl should unregister it. contents_b->SetDelegate(delegate.get()); EXPECT_EQ(delegate.get(), contents_a->GetDelegate()); EXPECT_EQ(delegate.get(), contents_b->GetDelegate()); diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index fa1907c..4fb699e 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -350,7 +350,9 @@ WebContentsImpl::~WebContentsImpl() { base::TimeTicks::Now() - tab_close_start_time_); } - FOR_EACH_OBSERVER(WebContentsObserver, observers_, TabContentsDestroyed()); + FOR_EACH_OBSERVER(WebContentsObserver, + observers_, + WebContentsImplDestroyed()); SetDelegate(NULL); } diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index d37dc44..85e600d 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -376,9 +376,10 @@ class CONTENT_EXPORT WebContentsImpl private: friend class NavigationControllerImpl; - FRIEND_TEST_ALL_PREFIXES(TabContentsTest, NoJSMessageOnInterstitials); - FRIEND_TEST_ALL_PREFIXES(TabContentsTest, UpdateTitle); - FRIEND_TEST_ALL_PREFIXES(TabContentsTest, CrossSiteCantPreemptAfterUnload); + FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials); + FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle); + FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, + CrossSiteCantPreemptAfterUnload); FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles); FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate); FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, PageDoesBackAndReload); diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc index 5d0f73d..5e9a02b 100644 --- a/content/browser/web_contents/web_contents_impl_unittest.cc +++ b/content/browser/web_contents/web_contents_impl_unittest.cc @@ -218,7 +218,7 @@ class TestInterstitialPage : public InterstitialPageImpl { protected: virtual content::RenderViewHost* CreateRenderViewHost() OVERRIDE { return new TestRenderViewHost( - SiteInstance::Create(tab()->GetBrowserContext()), + SiteInstance::Create(web_contents()->GetBrowserContext()), this, MSG_ROUTING_NONE); } diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index 421e563..0d1ee8b 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -34,7 +34,7 @@ namespace { // the renderer. class WebDragSourceAura : public MessageLoopForUI::Observer { public: - explicit WebDragSourceAura(TabContents* contents) + explicit WebDragSourceAura(WebContentsImpl* contents) : contents_(contents) { MessageLoopForUI::current()->AddObserver(this); } @@ -71,7 +71,7 @@ class WebDragSourceAura : public MessageLoopForUI::Observer { private: - TabContents* contents_; + WebContentsImpl* contents_; DISALLOW_COPY_AND_ASSIGN(WebDragSourceAura); }; @@ -163,9 +163,9 @@ WebKit::WebDragOperationsMask ConvertToWeb(int drag_op) { // WebContentsViewAura, public: WebContentsViewAura::WebContentsViewAura( - TabContents* tab_contents, + WebContentsImpl* web_contents, content::WebContentsViewDelegate* delegate) - : tab_contents_(tab_contents), + : web_contents_(web_contents), view_(NULL), delegate_(delegate), current_drag_op_(WebKit::WebDragOperationNone), @@ -179,10 +179,10 @@ WebContentsViewAura::~WebContentsViewAura() { // WebContentsViewAura, private: void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { - if (tab_contents_->GetInterstitialPage()) - tab_contents_->GetInterstitialPage()->SetSize(size); + if (web_contents_->GetInterstitialPage()) + web_contents_->GetInterstitialPage()->SetSize(size); content::RenderWidgetHostView* rwhv = - tab_contents_->GetRenderWidgetHostView(); + web_contents_->GetRenderWidgetHostView(); if (rwhv) rwhv->SetSize(size); } @@ -191,7 +191,7 @@ void WebContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); gfx::Point screen_loc = root_window->last_mouse_location(); gfx::Point client_loc = screen_loc; - content::RenderViewHost* rvh = tab_contents_->GetRenderViewHost(); + content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); aura::Window* window = rvh->GetView()->GetNativeView(); aura::Window::ConvertPointToWindow(root_window, window, &client_loc); rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(), @@ -285,8 +285,8 @@ void WebContentsViewAura::RenderViewCreated(content::RenderViewHost* host) { } void WebContentsViewAura::Focus() { - if (tab_contents_->GetInterstitialPage()) { - tab_contents_->GetInterstitialPage()->Focus(); + if (web_contents_->GetInterstitialPage()) { + web_contents_->GetInterstitialPage()->Focus(); return; } @@ -294,14 +294,14 @@ void WebContentsViewAura::Focus() { return; content::RenderWidgetHostView* rwhv = - tab_contents_->GetRenderWidgetHostView(); + web_contents_->GetRenderWidgetHostView(); if (rwhv) rwhv->Focus(); } void WebContentsViewAura::SetInitialFocus() { - if (tab_contents_->FocusLocationBarByDefault()) - tab_contents_->SetFocusToLocationBar(false); + if (web_contents_->FocusLocationBarByDefault()) + web_contents_->SetFocusToLocationBar(false); else Focus(); } @@ -352,19 +352,19 @@ void WebContentsViewAura::GetViewBounds(gfx::Rect* out) const { void WebContentsViewAura::CreateNewWindow( int route_id, const ViewHostMsg_CreateWindow_Params& params) { - web_contents_view_helper_.CreateNewWindow(tab_contents_, route_id, params); + web_contents_view_helper_.CreateNewWindow(web_contents_, route_id, params); } void WebContentsViewAura::CreateNewWidget(int route_id, WebKit::WebPopupType popup_type) { - web_contents_view_helper_.CreateNewWidget(tab_contents_, + web_contents_view_helper_.CreateNewWidget(web_contents_, route_id, false, popup_type); } void WebContentsViewAura::CreateNewFullscreenWidget(int route_id) { - web_contents_view_helper_.CreateNewWidget(tab_contents_, + web_contents_view_helper_.CreateNewWidget(web_contents_, route_id, true, WebKit::WebPopupTypeNone); @@ -375,19 +375,19 @@ void WebContentsViewAura::ShowCreatedWindow(int route_id, const gfx::Rect& initial_pos, bool user_gesture) { web_contents_view_helper_.ShowCreatedWindow( - tab_contents_, route_id, disposition, initial_pos, user_gesture); + web_contents_, route_id, disposition, initial_pos, user_gesture); } void WebContentsViewAura::ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos) { - web_contents_view_helper_.ShowCreatedWidget(tab_contents_, + web_contents_view_helper_.ShowCreatedWidget(web_contents_, route_id, false, initial_pos); } void WebContentsViewAura::ShowCreatedFullscreenWidget(int route_id) { - web_contents_view_helper_.ShowCreatedWidget(tab_contents_, + web_contents_view_helper_.ShowCreatedWidget(web_contents_, route_id, true, gfx::Rect()); @@ -396,8 +396,8 @@ void WebContentsViewAura::ShowCreatedFullscreenWidget(int route_id) { void WebContentsViewAura::ShowContextMenu( const content::ContextMenuParams& params) { // Allow WebContentsDelegates to handle the context menu operation first. - if (tab_contents_->GetDelegate() && - tab_contents_->GetDelegate()->HandleContextMenu(params)) { + if (web_contents_->GetDelegate() && + web_contents_->GetDelegate()->HandleContextMenu(params)) { return; } @@ -431,7 +431,7 @@ void WebContentsViewAura::StartDragging( ui::OSExchangeData data(provider); // takes ownership of |provider|. scoped_ptr<WebDragSourceAura> drag_source( - new WebDragSourceAura(tab_contents_)); + new WebDragSourceAura(web_contents_)); // We need to enable recursive tasks on the message loop so we can get // updates while in the system DoDragDrop loop. @@ -449,20 +449,20 @@ void WebContentsViewAura::StartDragging( } EndDrag(ConvertToWeb(result_op)); - tab_contents_->GetRenderViewHost()->DragSourceSystemDragEnded();} + web_contents_->GetRenderViewHost()->DragSourceSystemDragEnded();} void WebContentsViewAura::UpdateDragCursor(WebKit::WebDragOperation operation) { current_drag_op_ = operation; } void WebContentsViewAura::GotFocus() { - if (tab_contents_->GetDelegate()) - tab_contents_->GetDelegate()->WebContentsFocused(tab_contents_); + if (web_contents_->GetDelegate()) + web_contents_->GetDelegate()->WebContentsFocused(web_contents_); } void WebContentsViewAura::TakeFocus(bool reverse) { - if (tab_contents_->GetDelegate() && - !tab_contents_->GetDelegate()->TakeFocus(reverse) && + if (web_contents_->GetDelegate() && + !web_contents_->GetDelegate()->TakeFocus(reverse) && delegate_.get()) { delegate_->TakeFocus(reverse); } @@ -501,16 +501,16 @@ int WebContentsViewAura::GetNonClientComponent(const gfx::Point& point) const { } bool WebContentsViewAura::OnMouseEvent(aura::MouseEvent* event) { - if (!tab_contents_->GetDelegate()) + if (!web_contents_->GetDelegate()) return false; switch (event->type()) { case ui::ET_MOUSE_PRESSED: - tab_contents_->GetDelegate()->ActivateContents(tab_contents_); + web_contents_->GetDelegate()->ActivateContents(web_contents_); break; case ui::ET_MOUSE_MOVED: - tab_contents_->GetDelegate()->ContentsMouseEvent( - tab_contents_, gfx::Screen::GetCursorScreenPoint(), true); + web_contents_->GetDelegate()->ContentsMouseEvent( + web_contents_, gfx::Screen::GetCursorScreenPoint(), true); break; default: break; @@ -545,16 +545,16 @@ void WebContentsViewAura::OnWindowDestroyed() { void WebContentsViewAura::OnWindowVisibilityChanged(bool visible) { if (visible) - tab_contents_->ShowContents(); + web_contents_->ShowContents(); else - tab_contents_->HideContents(); + web_contents_->HideContents(); } //////////////////////////////////////////////////////////////////////////////// // WebContentsViewAura, aura::client::DragDropDelegate implementation: void WebContentsViewAura::OnDragEntered(const aura::DropTargetEvent& event) { if (GetDragDestDelegate()) - GetDragDestDelegate()->DragInitialize(tab_contents_); + GetDragDestDelegate()->DragInitialize(web_contents_); WebDropData drop_data; PrepareWebDropData(&drop_data, event.data()); @@ -562,7 +562,7 @@ void WebContentsViewAura::OnDragEntered(const aura::DropTargetEvent& event) { gfx::Point screen_pt = GetNativeView()->GetRootWindow()->last_mouse_location(); - tab_contents_->GetRenderViewHost()->DragTargetDragEnter( + web_contents_->GetRenderViewHost()->DragTargetDragEnter( drop_data, event.location(), screen_pt, op); if (GetDragDestDelegate()) { @@ -575,7 +575,7 @@ int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) { WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); gfx::Point screen_pt = GetNativeView()->GetRootWindow()->last_mouse_location(); - tab_contents_->GetRenderViewHost()->DragTargetDragOver( + web_contents_->GetRenderViewHost()->DragTargetDragOver( event.location(), screen_pt, op); if (GetDragDestDelegate()) @@ -585,13 +585,13 @@ int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) { } void WebContentsViewAura::OnDragExited() { - tab_contents_->GetRenderViewHost()->DragTargetDragLeave(); + web_contents_->GetRenderViewHost()->DragTargetDragLeave(); if (GetDragDestDelegate()) GetDragDestDelegate()->OnDragLeave(); } int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) { - tab_contents_->GetRenderViewHost()->DragTargetDrop( + web_contents_->GetRenderViewHost()->DragTargetDrop( event.location(), GetNativeView()->GetRootWindow()->last_mouse_location()); if (GetDragDestDelegate()) diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h index 360006a..b2d239c 100644 --- a/content/browser/web_contents/web_contents_view_aura.h +++ b/content/browser/web_contents/web_contents_view_aura.h @@ -122,7 +122,7 @@ class CONTENT_EXPORT WebContentsViewAura scoped_ptr<aura::Window> window_; // The WebContentsImpl whose contents we display. - WebContentsImpl* tab_contents_; + WebContentsImpl* web_contents_; content::RenderWidgetHostView* view_; diff --git a/content/browser/web_contents/web_contents_view_gtk.cc b/content/browser/web_contents/web_contents_view_gtk.cc index e880362..ac1021f 100644 --- a/content/browser/web_contents/web_contents_view_gtk.cc +++ b/content/browser/web_contents/web_contents_view_gtk.cc @@ -37,31 +37,31 @@ namespace { // Called when the mouse leaves the widget. We notify our delegate. gboolean OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event, - TabContents* tab_contents) { - if (tab_contents->GetDelegate()) - tab_contents->GetDelegate()->ContentsMouseEvent( - tab_contents, gfx::Point(event->x_root, event->y_root), false); + WebContentsImpl* web_contents) { + if (web_contents->GetDelegate()) + web_contents->GetDelegate()->ContentsMouseEvent( + web_contents, gfx::Point(event->x_root, event->y_root), false); return FALSE; } // Called when the mouse moves within the widget. We notify our delegate. gboolean OnMouseMove(GtkWidget* widget, GdkEventMotion* event, - TabContents* tab_contents) { - if (tab_contents->GetDelegate()) - tab_contents->GetDelegate()->ContentsMouseEvent( - tab_contents, gfx::Point(event->x_root, event->y_root), true); + WebContentsImpl* web_contents) { + if (web_contents->GetDelegate()) + web_contents->GetDelegate()->ContentsMouseEvent( + web_contents, gfx::Point(event->x_root, event->y_root), true); return FALSE; } // See tab_contents_view_views.cc for discussion of mouse scroll zooming. gboolean OnMouseScroll(GtkWidget* widget, GdkEventScroll* event, - TabContents* tab_contents) { + WebContentsImpl* web_contents) { if ((event->state & gtk_accelerator_get_default_mod_mask()) != GDK_CONTROL_MASK) { return FALSE; } - content::WebContentsDelegate* delegate = tab_contents->GetDelegate(); + content::WebContentsDelegate* delegate = web_contents->GetDelegate(); if (!delegate) return FALSE; @@ -79,9 +79,9 @@ gboolean OnMouseScroll(GtkWidget* widget, GdkEventScroll* event, namespace content { WebContentsViewGtk::WebContentsViewGtk( - TabContents* tab_contents, + WebContentsImpl* web_contents, content::WebContentsViewDelegate* delegate) - : tab_contents_(tab_contents), + : web_contents_(web_contents), expanded_(gtk_expanded_container_new()), delegate_(delegate) { gtk_widget_set_name(expanded_.get(), "chrome-tab-contents-view"); @@ -91,7 +91,7 @@ WebContentsViewGtk::WebContentsViewGtk( G_CALLBACK(OnChildSizeRequestThunk), this); gtk_widget_show(expanded_.get()); - drag_source_.reset(new content::WebDragSourceGtk(tab_contents)); + drag_source_.reset(new content::WebDragSourceGtk(web_contents)); if (delegate_.get()) delegate_->Initialize(expanded_.get(), &focus_store_); @@ -123,17 +123,17 @@ RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget( gfx::NativeView content_view = view->GetNativeView(); g_signal_connect(content_view, "focus", G_CALLBACK(OnFocusThunk), this); g_signal_connect(content_view, "leave-notify-event", - G_CALLBACK(OnLeaveNotify), tab_contents_); + G_CALLBACK(OnLeaveNotify), web_contents_); g_signal_connect(content_view, "motion-notify-event", - G_CALLBACK(OnMouseMove), tab_contents_); + G_CALLBACK(OnMouseMove), web_contents_); g_signal_connect(content_view, "scroll-event", - G_CALLBACK(OnMouseScroll), tab_contents_); + G_CALLBACK(OnMouseScroll), web_contents_); gtk_widget_add_events(content_view, GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK); InsertIntoContentArea(content_view); // Renderer target DnD. - drag_dest_.reset(new content::WebDragDestGtk(tab_contents_, content_view)); + drag_dest_.reset(new content::WebDragDestGtk(web_contents_, content_view)); if (delegate_.get()) drag_dest_->set_delegate(delegate_->GetDragDestDelegate()); @@ -149,7 +149,7 @@ gfx::NativeView WebContentsViewGtk::GetNativeView() const { } gfx::NativeView WebContentsViewGtk::GetContentNativeView() const { - RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); + RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); if (!rwhv) return NULL; return rwhv->GetNativeView(); @@ -198,7 +198,7 @@ void WebContentsViewGtk::SizeContents(const gfx::Size& size) { // need to pass the sizing information on to the RWHV which will pass the // sizing information on to the renderer. requested_size_ = size; - RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); + RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); if (rwhv) rwhv->SetSize(size); } @@ -207,16 +207,16 @@ void WebContentsViewGtk::RenderViewCreated(content::RenderViewHost* host) { } void WebContentsViewGtk::Focus() { - if (tab_contents_->ShowingInterstitialPage()) { - tab_contents_->GetInterstitialPage()->Focus(); + if (web_contents_->ShowingInterstitialPage()) { + web_contents_->GetInterstitialPage()->Focus(); } else if (delegate_.get()) { delegate_->Focus(); } } void WebContentsViewGtk::SetInitialFocus() { - if (tab_contents_->FocusLocationBarByDefault()) - tab_contents_->SetFocusToLocationBar(false); + if (web_contents_->FocusLocationBarByDefault()) + web_contents_->SetFocusToLocationBar(false); else Focus(); } @@ -258,7 +258,7 @@ void WebContentsViewGtk::GetViewBounds(gfx::Rect* out) const { } WebContents* WebContentsViewGtk::web_contents() { - return tab_contents_; + return web_contents_; } void WebContentsViewGtk::UpdateDragCursor(WebDragOperation operation) { @@ -273,9 +273,9 @@ void WebContentsViewGtk::GotFocus() { // This is called when the renderer asks us to take focus back (i.e., it has // iterated past the last focusable element on the page). void WebContentsViewGtk::TakeFocus(bool reverse) { - if (!tab_contents_->GetDelegate()) + if (!web_contents_->GetDelegate()) return; - if (!tab_contents_->GetDelegate()->TakeFocus(reverse)) { + if (!web_contents_->GetDelegate()->TakeFocus(reverse)) { gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); } @@ -307,26 +307,26 @@ gboolean WebContentsViewGtk::OnFocus(GtkWidget* widget, gtk_widget_grab_focus(widget); bool reverse = focus == GTK_DIR_TAB_BACKWARD; - tab_contents_->FocusThroughTabTraversal(reverse); + web_contents_->FocusThroughTabTraversal(reverse); return TRUE; } void WebContentsViewGtk::CreateNewWindow( int route_id, const ViewHostMsg_CreateWindow_Params& params) { - web_contents_view_helper_.CreateNewWindow(tab_contents_, route_id, params); + web_contents_view_helper_.CreateNewWindow(web_contents_, route_id, params); } void WebContentsViewGtk::CreateNewWidget( int route_id, WebKit::WebPopupType popup_type) { - web_contents_view_helper_.CreateNewWidget(tab_contents_, + web_contents_view_helper_.CreateNewWidget(web_contents_, route_id, false, popup_type); } void WebContentsViewGtk::CreateNewFullscreenWidget(int route_id) { - web_contents_view_helper_.CreateNewWidget(tab_contents_, + web_contents_view_helper_.CreateNewWidget(web_contents_, route_id, true, WebKit::WebPopupTypeNone); @@ -337,19 +337,19 @@ void WebContentsViewGtk::ShowCreatedWindow(int route_id, const gfx::Rect& initial_pos, bool user_gesture) { web_contents_view_helper_.ShowCreatedWindow( - tab_contents_, route_id, disposition, initial_pos, user_gesture); + web_contents_, route_id, disposition, initial_pos, user_gesture); } void WebContentsViewGtk::ShowCreatedWidget( int route_id, const gfx::Rect& initial_pos) { - web_contents_view_helper_.ShowCreatedWidget(tab_contents_, + web_contents_view_helper_.ShowCreatedWidget(web_contents_, route_id, false, initial_pos); } void WebContentsViewGtk::ShowCreatedFullscreenWidget(int route_id) { - web_contents_view_helper_.ShowCreatedWidget(tab_contents_, + web_contents_view_helper_.ShowCreatedWidget(web_contents_, route_id, true, gfx::Rect()); @@ -389,7 +389,7 @@ void WebContentsViewGtk::StartDragging(const WebDropData& drop_data, DCHECK(GetContentNativeView()); RenderWidgetHostViewGtk* view_gtk = static_cast<RenderWidgetHostViewGtk*>( - tab_contents_->GetRenderWidgetHostView()); + web_contents_->GetRenderWidgetHostView()); if (!view_gtk || !view_gtk->GetLastMouseDown()) return; @@ -402,9 +402,9 @@ void WebContentsViewGtk::StartDragging(const WebDropData& drop_data, void WebContentsViewGtk::OnChildSizeRequest(GtkWidget* widget, GtkWidget* child, GtkRequisition* requisition) { - if (tab_contents_->GetDelegate()) { + if (web_contents_->GetDelegate()) { requisition->height += - tab_contents_->GetDelegate()->GetExtraRenderViewHeight(); + web_contents_->GetDelegate()->GetExtraRenderViewHeight(); } } @@ -413,18 +413,18 @@ void WebContentsViewGtk::OnSizeAllocate(GtkWidget* widget, int width = allocation->width; int height = allocation->height; // |delegate()| can be NULL here during browser teardown. - if (tab_contents_->GetDelegate()) - height += tab_contents_->GetDelegate()->GetExtraRenderViewHeight(); + if (web_contents_->GetDelegate()) + height += web_contents_->GetDelegate()->GetExtraRenderViewHeight(); gfx::Size size(width, height); requested_size_ = size; // We manually tell our RWHV to resize the renderer content. This avoids // spurious resizes from GTK+. - RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); + RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); if (rwhv) rwhv->SetSize(size); - if (tab_contents_->GetInterstitialPage()) - tab_contents_->GetInterstitialPage()->SetSize(size); + if (web_contents_->GetInterstitialPage()) + web_contents_->GetInterstitialPage()->SetSize(size); } } // namespace content diff --git a/content/browser/web_contents/web_contents_view_gtk.h b/content/browser/web_contents/web_contents_view_gtk.h index 88c4a7a..3aa1b2b 100644 --- a/content/browser/web_contents/web_contents_view_gtk.h +++ b/content/browser/web_contents/web_contents_view_gtk.h @@ -27,7 +27,7 @@ class WebDragSourceGtk; class CONTENT_EXPORT WebContentsViewGtk : public WebContentsView { public: - // The corresponding TabContents is passed in the constructor, and manages + // The corresponding WebContentsImpl is passed in the constructor, and manages // our lifetime. This doesn't need to be the case, but is this way currently // because that's what was easiest when they were split. We optionally take // |wrapper| which creates an intermediary widget layer for features from the @@ -116,7 +116,7 @@ class CONTENT_EXPORT WebContentsViewGtk : public WebContentsView { GtkAllocation*); // The WebContentsImpl whose contents we display. - WebContentsImpl* tab_contents_; + WebContentsImpl* web_contents_; // Common implementations of some WebContentsView methods. WebContentsViewHelper web_contents_view_helper_; diff --git a/content/browser/web_contents/web_contents_view_helper.cc b/content/browser/web_contents/web_contents_view_helper.cc index bb8d8c1..49c05c3 100644 --- a/content/browser/web_contents/web_contents_view_helper.cc +++ b/content/browser/web_contents/web_contents_view_helper.cc @@ -46,7 +46,7 @@ void WebContentsViewHelper::Observe( } } -TabContents* WebContentsViewHelper::CreateNewWindow( +WebContentsImpl* WebContentsViewHelper::CreateNewWindow( WebContents* web_contents, int route_id, const ViewHostMsg_CreateWindow_Params& params) { @@ -74,12 +74,12 @@ TabContents* WebContentsViewHelper::CreateNewWindow( // Create the new web contents. This will automatically create the new // WebContentsView. In the future, we may want to create the view separately. - TabContents* new_contents = - new TabContents(web_contents->GetBrowserContext(), - site_instance, - route_id, - static_cast<TabContents*>(web_contents), - NULL); + WebContentsImpl* new_contents = + new WebContentsImpl(web_contents->GetBrowserContext(), + site_instance, + route_id, + static_cast<WebContentsImpl*>(web_contents), + NULL); new_contents->set_opener_web_ui_type( web_contents->GetWebUITypeForCurrentState()); new_contents->set_has_opener(!params.opener_url.is_empty()); @@ -141,7 +141,7 @@ RenderWidgetHostView* WebContentsViewHelper::CreateNewWidget( return widget_view; } -TabContents* WebContentsViewHelper::GetCreatedWindow(int route_id) { +WebContentsImpl* WebContentsViewHelper::GetCreatedWindow(int route_id) { PendingContents::iterator iter = pending_contents_.find(route_id); // Certain systems can block the creation of new windows. If we didn't succeed @@ -150,7 +150,7 @@ TabContents* WebContentsViewHelper::GetCreatedWindow(int route_id) { return NULL; } - TabContents* new_contents = iter->second; + WebContentsImpl* new_contents = iter->second; pending_contents_.erase(route_id); if (!new_contents->GetRenderProcessHost()->HasConnection() || @@ -181,13 +181,13 @@ RenderWidgetHostView* WebContentsViewHelper::GetCreatedWidget(int route_id) { return widget_host_view; } -TabContents* WebContentsViewHelper::ShowCreatedWindow( +WebContentsImpl* WebContentsViewHelper::ShowCreatedWindow( WebContents* web_contents, int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture) { - TabContents* contents = GetCreatedWindow(route_id); + WebContentsImpl* contents = GetCreatedWindow(route_id); if (contents) { web_contents->AddNewContents(contents, disposition, diff --git a/content/browser/web_contents/web_contents_view_helper.h b/content/browser/web_contents/web_contents_view_helper.h index b36bb0c..291f124 100644 --- a/content/browser/web_contents/web_contents_view_helper.h +++ b/content/browser/web_contents/web_contents_view_helper.h @@ -28,7 +28,7 @@ namespace gfx { class Rect; } -// TODO(avi): Once all the TabContentsViews implementations are in content (I'm +// TODO(avi): Once all the WebContentsViews implementations are in content (I'm // looking at you, TabContentsViewViews...) then change the parameters to take // WebContentsImpl rather than WebContents. diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm index 237cdef..7cd4a95 100644 --- a/content/browser/web_contents/web_contents_view_mac.mm +++ b/content/browser/web_contents/web_contents_view_mac.mm @@ -51,16 +51,16 @@ COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery); image:(NSImage*)image offset:(NSPoint)offset; - (void)cancelDeferredClose; -- (void)clearTabContentsView; +- (void)clearWebContentsView; - (void)closeTabAfterEvent; - (void)viewDidBecomeFirstResponder:(NSNotification*)notification; @end namespace web_contents_view_mac { content::WebContentsView* CreateWebContentsView( - TabContents* tab_contents, + WebContentsImpl* web_contents, content::WebContentsViewDelegate* delegate) { - return new WebContentsViewMac(tab_contents, delegate); + return new WebContentsViewMac(web_contents, delegate); } } @@ -77,7 +77,7 @@ WebContentsViewMac::~WebContentsViewMac() { // close. In that case, the Cocoa view outlives the // WebContentsViewMac instance due to Cocoa retain count. [cocoa_view_ cancelDeferredClose]; - [cocoa_view_ clearTabContentsView]; + [cocoa_view_ clearWebContentsView]; } void WebContentsViewMac::CreateView(const gfx::Size& initial_size) { @@ -557,7 +557,7 @@ void WebContentsViewMac::CloseTab() { object:nil]; } -- (void)clearTabContentsView { +- (void)clearWebContentsView { webContentsView_ = NULL; } diff --git a/content/browser/web_contents/web_contents_view_win.cc b/content/browser/web_contents/web_contents_view_win.cc index 0b21935..3070972 100644 --- a/content/browser/web_contents/web_contents_view_win.cc +++ b/content/browser/web_contents/web_contents_view_win.cc @@ -62,9 +62,9 @@ class TempParent : public ui::WindowImpl { } // namespace namespace -WebContentsViewWin::WebContentsViewWin(TabContents* tab_contents, +WebContentsViewWin::WebContentsViewWin(WebContentsImpl* web_contents, WebContentsViewDelegate* delegate) - : tab_contents_(tab_contents), + : web_contents_(web_contents), view_(NULL), delegate_(delegate), close_tab_after_drag_ends_(false) { @@ -84,7 +84,7 @@ void WebContentsViewWin::CreateView(const gfx::Size& initial_size) { // Remove the root view drop target so we can register our own. RevokeDragDrop(GetNativeView()); - drag_dest_ = new WebDragDest(hwnd(), tab_contents_); + drag_dest_ = new WebDragDest(hwnd(), web_contents_); if (delegate_.get()) { content::WebDragDestDelegate* delegate = delegate_->GetDragDestDelegate(); if (delegate) @@ -117,7 +117,7 @@ gfx::NativeView WebContentsViewWin::GetNativeView() const { } gfx::NativeView WebContentsViewWin::GetContentNativeView() const { - RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); + RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); return rwhv ? rwhv->GetNativeView() : NULL; } @@ -156,9 +156,9 @@ void WebContentsViewWin::SizeContents(const gfx::Size& size) { } else { // Our size matches what we want but the renderers size may not match. // Pretend we were resized so that the renderers size is updated too. - if (tab_contents_->GetInterstitialPage()) - tab_contents_->GetInterstitialPage()->SetSize(size); - RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); + if (web_contents_->GetInterstitialPage()) + web_contents_->GetInterstitialPage()->SetSize(size); + RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); if (rwhv) rwhv->SetSize(size); } @@ -168,22 +168,22 @@ void WebContentsViewWin::RenderViewCreated(RenderViewHost* host) { } void WebContentsViewWin::Focus() { - if (tab_contents_->GetInterstitialPage()) { - tab_contents_->GetInterstitialPage()->Focus(); + if (web_contents_->GetInterstitialPage()) { + web_contents_->GetInterstitialPage()->Focus(); return; } if (delegate_.get() && delegate_->Focus()) return; - RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); + RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); if (rwhv) rwhv->Focus(); } void WebContentsViewWin::SetInitialFocus() { - if (tab_contents_->FocusLocationBarByDefault()) - tab_contents_->SetFocusToLocationBar(false); + if (web_contents_->FocusLocationBarByDefault()) + web_contents_->SetFocusToLocationBar(false); else Focus(); } @@ -227,19 +227,19 @@ void WebContentsViewWin::GetViewBounds(gfx::Rect* out) const { void WebContentsViewWin::CreateNewWindow( int route_id, const ViewHostMsg_CreateWindow_Params& params) { - web_contents_view_helper_.CreateNewWindow(tab_contents_, route_id, params); + web_contents_view_helper_.CreateNewWindow(web_contents_, route_id, params); } void WebContentsViewWin::CreateNewWidget(int route_id, WebKit::WebPopupType popup_type) { - web_contents_view_helper_.CreateNewWidget(tab_contents_, + web_contents_view_helper_.CreateNewWidget(web_contents_, route_id, false, popup_type); } void WebContentsViewWin::CreateNewFullscreenWidget(int route_id) { - web_contents_view_helper_.CreateNewWidget(tab_contents_, + web_contents_view_helper_.CreateNewWidget(web_contents_, route_id, true, WebKit::WebPopupTypeNone); @@ -250,19 +250,19 @@ void WebContentsViewWin::ShowCreatedWindow(int route_id, const gfx::Rect& initial_pos, bool user_gesture) { web_contents_view_helper_.ShowCreatedWindow( - tab_contents_, route_id, disposition, initial_pos, user_gesture); + web_contents_, route_id, disposition, initial_pos, user_gesture); } void WebContentsViewWin::ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos) { - web_contents_view_helper_.ShowCreatedWidget(tab_contents_, + web_contents_view_helper_.ShowCreatedWidget(web_contents_, route_id, false, initial_pos); } void WebContentsViewWin::ShowCreatedFullscreenWidget(int route_id) { - web_contents_view_helper_.ShowCreatedWidget(tab_contents_, + web_contents_view_helper_.ShowCreatedWidget(web_contents_, route_id, true, gfx::Rect()); @@ -271,8 +271,8 @@ void WebContentsViewWin::ShowCreatedFullscreenWidget(int route_id) { void WebContentsViewWin::ShowContextMenu( const content::ContextMenuParams& params) { // Allow WebContentsDelegates to handle the context menu operation first. - if (tab_contents_->GetDelegate() && - tab_contents_->GetDelegate()->HandleContextMenu(params)) { + if (web_contents_->GetDelegate() && + web_contents_->GetDelegate()->HandleContextMenu(params)) { return; } @@ -296,7 +296,7 @@ void WebContentsViewWin::StartDragging(const WebDropData& drop_data, const gfx::Point& image_offset) { drag_handler_ = new WebContentsDragWin( GetNativeView(), - tab_contents_, + web_contents_, drag_dest_, base::Bind(&WebContentsViewWin::EndDragging, base::Unretained(this))); drag_handler_->StartDragging(drop_data, operations, image, image_offset); @@ -307,13 +307,13 @@ void WebContentsViewWin::UpdateDragCursor(WebKit::WebDragOperation operation) { } void WebContentsViewWin::GotFocus() { - if (tab_contents_->GetDelegate()) - tab_contents_->GetDelegate()->WebContentsFocused(tab_contents_); + if (web_contents_->GetDelegate()) + web_contents_->GetDelegate()->WebContentsFocused(web_contents_); } void WebContentsViewWin::TakeFocus(bool reverse) { - if (tab_contents_->GetDelegate() && - !tab_contents_->GetDelegate()->TakeFocus(reverse) && + if (web_contents_->GetDelegate() && + !web_contents_->GetDelegate()->TakeFocus(reverse) && delegate_.get()) { delegate_->TakeFocus(reverse); } @@ -325,11 +325,11 @@ void WebContentsViewWin::EndDragging() { close_tab_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(0), this, &WebContentsViewWin::CloseTab); } - tab_contents_->SystemDragEnded(); + web_contents_->SystemDragEnded(); } void WebContentsViewWin::CloseTab() { - RenderViewHost* rvh = tab_contents_->GetRenderViewHost(); + RenderViewHost* rvh = web_contents_->GetRenderViewHost(); rvh->GetDelegate()->Close(rvh); } @@ -346,14 +346,14 @@ LRESULT WebContentsViewWin::OnWindowPosChanged( UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { WINDOWPOS* window_pos = reinterpret_cast<WINDOWPOS*>(lparam); if (window_pos->flags & SWP_HIDEWINDOW) { - tab_contents_->HideContents(); + web_contents_->HideContents(); return 0; } - // The TabContents was shown by a means other than the user selecting a + // 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) - tab_contents_->ShowContents(); + web_contents_->ShowContents(); // Unless we were specifically told not to size, cause the renderer to be // sized to the new bounds, which forces a repaint. Not required for the @@ -363,9 +363,9 @@ LRESULT WebContentsViewWin::OnWindowPosChanged( return 0; gfx::Size size(window_pos->cx, window_pos->cy); - if (tab_contents_->GetInterstitialPage()) - tab_contents_->GetInterstitialPage()->SetSize(size); - RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); + if (web_contents_->GetInterstitialPage()) + web_contents_->GetInterstitialPage()->SetSize(size); + RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); if (rwhv) rwhv->SetSize(size); @@ -377,9 +377,9 @@ LRESULT WebContentsViewWin::OnWindowPosChanged( LRESULT WebContentsViewWin::OnMouseDown( UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { - // Make sure this TabContents is activated when it is clicked on. - if (tab_contents_->GetDelegate()) - tab_contents_->GetDelegate()->ActivateContents(tab_contents_); + // Make sure this WebContents is activated when it is clicked on. + if (web_contents_->GetDelegate()) + web_contents_->GetDelegate()->ActivateContents(web_contents_); return 0; } @@ -387,9 +387,9 @@ LRESULT WebContentsViewWin::OnMouseMove( UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { // Let our delegate know that the mouse moved (useful for resetting status // bubble state). - if (tab_contents_->GetDelegate()) { - tab_contents_->GetDelegate()->ContentsMouseEvent( - tab_contents_, gfx::Screen::GetCursorScreenPoint(), true); + if (web_contents_->GetDelegate()) { + web_contents_->GetDelegate()->ContentsMouseEvent( + web_contents_, gfx::Screen::GetCursorScreenPoint(), true); } return 0; } @@ -401,7 +401,7 @@ LRESULT WebContentsViewWin::OnReflectedMessage( case WM_MOUSEWHEEL: // This message is reflected from the view() to this window. if (GET_KEYSTATE_WPARAM(message->wParam) & MK_CONTROL) { - tab_contents_->GetDelegate()->ContentsZoomChange( + web_contents_->GetDelegate()->ContentsZoomChange( GET_WHEEL_DELTA_WPARAM(message->wParam) > 0); return 1; } @@ -449,7 +449,7 @@ LRESULT WebContentsViewWin::OnScroll( break; } - tab_contents_->GetDelegate()->ContentsZoomChange(distance > 0); + web_contents_->GetDelegate()->ContentsZoomChange(distance > 0); return 0; } diff --git a/content/browser/web_contents/web_contents_view_win.h b/content/browser/web_contents/web_contents_view_win.h index e5b9cba..7b0e6c0 100644 --- a/content/browser/web_contents/web_contents_view_win.h +++ b/content/browser/web_contents/web_contents_view_win.h @@ -99,7 +99,7 @@ class CONTENT_EXPORT WebContentsViewWin : public content::WebContentsView, virtual void GotFocus() OVERRIDE; virtual void TakeFocus(bool reverse) OVERRIDE; - WebContentsImpl* tab_contents() const { return tab_contents_; } + WebContentsImpl* web_contents() const { return web_contents_; } private: void EndDragging(); @@ -125,7 +125,7 @@ class CONTENT_EXPORT WebContentsViewWin : public content::WebContentsView, gfx::Size initial_size_; // The WebContentsImpl whose contents we display. - WebContentsImpl* tab_contents_; + WebContentsImpl* web_contents_; RenderWidgetHostViewWin* view_; diff --git a/content/browser/web_contents/web_drag_dest_win.h b/content/browser/web_contents/web_drag_dest_win.h index bb27f66..ffa53c7 100644 --- a/content/browser/web_contents/web_drag_dest_win.h +++ b/content/browser/web_contents/web_drag_dest_win.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. @@ -19,7 +19,7 @@ class WebContents; class WebDragDestDelegate; } -// A helper object that provides drop capabilities to a TabContents. The +// A helper object that provides drop capabilities to a WebContentsImpl. The // DropTarget handles drags that enter the region of the WebContents by // passing on the events to the renderer. class CONTENT_EXPORT WebDragDest : public ui::DropTarget { diff --git a/content/browser/web_contents/web_drag_source_mac.mm b/content/browser/web_contents/web_drag_source_mac.mm index 3d67b8e..a899330 100644 --- a/content/browser/web_contents/web_drag_source_mac.mm +++ b/content/browser/web_contents/web_drag_source_mac.mm @@ -98,7 +98,7 @@ void PromiseWriterHelper(const WebDropData& drop_data, @implementation WebDragSource -- (id)initWithContents:(TabContents*)contents +- (id)initWithContents:(WebContentsImpl*)contents view:(NSView*)contentsView dropData:(const WebDropData*)dropData image:(NSImage*)image diff --git a/content/browser/web_contents/web_drag_source_win.h b/content/browser/web_contents/web_drag_source_win.h index 64a0c51..248ed82 100644 --- a/content/browser/web_contents/web_drag_source_win.h +++ b/content/browser/web_contents/web_drag_source_win.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. @@ -18,10 +18,10 @@ class RenderViewHost; class WebContents; } -// An IDropSource implementation for a TabContents. Handles notifications sent -// by an active drag-drop operation as the user mouses over other drop targets -// on their system. This object tells Windows whether or not the drag should -// continue, and supplies the appropriate cursors. +// An IDropSource implementation for a WebContentsImpl. Handles notifications +// sent by an active drag-drop operation as the user mouses over other drop +// targets on their system. This object tells Windows whether or not the drag +// should continue, and supplies the appropriate cursors. class WebDragSource : public ui::DragSource, public content::NotificationObserver { public: diff --git a/content/public/browser/web_contents_observer.cc b/content/public/browser/web_contents_observer.cc index 36854fc..3029256 100644 --- a/content/public/browser/web_contents_observer.cc +++ b/content/public/browser/web_contents_observer.cc @@ -58,7 +58,7 @@ int WebContentsObserver::routing_id() const { return web_contents_->GetRenderViewHost()->GetRoutingID(); } -void WebContentsObserver::TabContentsDestroyed() { +void WebContentsObserver::WebContentsImplDestroyed() { // Do cleanup so that 'this' can safely be deleted from WebContentsDestroyed. web_contents_->RemoveObserver(this); WebContentsImpl* contents = web_contents_; diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h index f67b2a5..47b9468 100644 --- a/content/public/browser/web_contents_observer.h +++ b/content/public/browser/web_contents_observer.h @@ -125,9 +125,9 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Channel::Listener, private: friend class ::WebContentsImpl; - // Invoked from WebContentsImpl. Invokes TabContentsDestroyed and NULL out - // |tab_contents_|. - void TabContentsDestroyed(); + // Invoked from WebContentsImpl. Invokes WebContentsDestroyed and NULL out + // |web_contents_|. + void WebContentsImplDestroyed(); WebContentsImpl* web_contents_; |