diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-02 06:08:32 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-02 06:08:32 +0000 |
commit | fbc5e5f97c0bd570130471c85c207aee528eef4c (patch) | |
tree | 6988a8d7eb9f6995da952e08c3e806b66a394f6f | |
parent | d270ff2dbac86886aa6a30b7fca6391b10498649 (diff) | |
download | chromium_src-fbc5e5f97c0bd570130471c85c207aee528eef4c.zip chromium_src-fbc5e5f97c0bd570130471c85c207aee528eef4c.tar.gz chromium_src-fbc5e5f97c0bd570130471c85c207aee528eef4c.tar.bz2 |
Convert chrome users of NavigationController::tab_contents() to use GetWebContents() instead.
BUG=98716
TBR=joi
Review URL: http://codereview.chromium.org/8986009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116086 0039d316-1c4b-4281-b951-d872f2087c98
59 files changed, 417 insertions, 358 deletions
diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index 04a2c4e..3676a4d 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -12,9 +12,9 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" #include "content/public/common/url_fetcher.h" +#include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources_standard.h" #include "net/base/registry_controlled_domain.h" @@ -137,7 +137,7 @@ void AlternateNavURLFetcher::Observe( // See above. NavigationController* controller = &content::Source<TabContentsWrapper>(source)-> - tab_contents()->GetController(); + web_contents()->GetController(); if (controller_ == controller) { delete this; } else if (!controller_) { @@ -225,7 +225,7 @@ void AlternateNavURLFetcher::ShowInfobarIfPossible() { InfoBarTabHelper* infobar_helper = TabContentsWrapper::GetCurrentWrapperForContents( - controller_->tab_contents())->infobar_tab_helper(); + controller_->GetWebContents())->infobar_tab_helper(); infobar_helper->AddInfoBar( new AlternateNavInfoBarDelegate(infobar_helper, alternate_nav_url_)); delete this; diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index cb0e2dd..9622c94 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -546,9 +546,9 @@ void AutomationProvider::HandleFindRequest( } NavigationController* nav = tab_tracker_->GetResource(handle); - TabContents* tab_contents = nav->tab_contents(); + WebContents* web_contents = nav->GetWebContents(); - SendFindRequest(tab_contents, + SendFindRequest(web_contents, false, params.search_string, params.forward, @@ -558,7 +558,7 @@ void AutomationProvider::HandleFindRequest( } void AutomationProvider::SendFindRequest( - TabContents* tab_contents, + WebContents* web_contents, bool with_json, const string16& search_string, bool forward, @@ -568,14 +568,14 @@ void AutomationProvider::SendFindRequest( int request_id = FindInPageNotificationObserver::kFindInPageRequestId; FindInPageNotificationObserver* observer = new FindInPageNotificationObserver(this, - tab_contents, + web_contents, with_json, reply_message); if (!with_json) { find_in_page_observer_.reset(observer); } TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents); if (wrapper) wrapper->find_tab_helper()->set_current_find_request_id(request_id); @@ -583,7 +583,7 @@ void AutomationProvider::SendFindRequest( options.forward = forward; options.matchCase = match_case; options.findNext = find_next; - tab_contents->GetRenderViewHost()->Find( + web_contents->GetRenderViewHost()->Find( FindInPageNotificationObserver::kFindInPageRequestId, search_string, options); } @@ -605,7 +605,7 @@ WebContents* AutomationProvider::GetWebContentsForHandle( NavigationController* nav_controller = tab_tracker_->GetResource(handle); if (tab) *tab = nav_controller; - return nav_controller->tab_contents(); + return nav_controller->GetWebContents(); } return NULL; } @@ -634,7 +634,7 @@ void AutomationProvider::OverrideEncoding(int tab_handle, } else { // There is no UI, Chrome probably runs as Chrome-Frame mode. // Try to get TabContents and call its override_encoding method. - TabContents* contents = nav->tab_contents(); + WebContents* contents = nav->GetWebContents(); if (!contents) return; const std::string selected_encoding = @@ -726,10 +726,10 @@ void AutomationProvider::OnSetPageFontSize(int tab_handle, if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* tab = tab_tracker_->GetResource(tab_handle); DCHECK(tab != NULL); - if (tab && tab->tab_contents()) { - DCHECK(tab->tab_contents()->GetBrowserContext() != NULL); - Profile* profile = - Profile::FromBrowserContext(tab->tab_contents()->GetBrowserContext()); + if (tab && tab->GetWebContents()) { + DCHECK(tab->GetWebContents()->GetBrowserContext() != NULL); + Profile* profile = Profile::FromBrowserContext( + tab->GetWebContents()->GetBrowserContext()); profile->GetPrefs()->SetInteger( prefs::kWebKitGlobalDefaultFontSize, font_size); } @@ -801,13 +801,13 @@ RenderViewHost* AutomationProvider::GetViewForTab(int tab_handle) { return NULL; } - TabContents* tab_contents = tab->tab_contents(); - if (!tab_contents) { + WebContents* web_contents = tab->GetWebContents(); + if (!web_contents) { NOTREACHED(); return NULL; } - RenderViewHost* view_host = tab_contents->GetRenderViewHost(); + RenderViewHost* view_host = web_contents->GetRenderViewHost(); return view_host; } diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index c52df34..faee18d 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -207,7 +207,7 @@ class AutomationProvider // Sends a find request for a given query. void SendFindRequest( - TabContents* tab_contents, + content::WebContents* web_contents, bool with_json, const string16& search_string, bool forward, diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 26e050c..cc31ca7 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -260,7 +260,7 @@ void NavigationControllerRestoredObserver::Observe( bool NavigationControllerRestoredObserver::FinishedRestoring() { return (!controller_->NeedsReload() && !controller_->GetPendingEntry() && - !controller_->tab_contents()->IsLoading()); + !controller_->GetWebContents()->IsLoading()); } void NavigationControllerRestoredObserver::SendDone() { @@ -300,7 +300,7 @@ NavigationNotificationObserver::NavigationNotificationObserver( registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, content::NotificationService::AllSources()); - if (include_current_navigation && controller->tab_contents()->IsLoading()) + if (include_current_navigation && controller->GetWebContents()->IsLoading()) navigation_started_ = true; } @@ -888,7 +888,7 @@ void BrowserOpenedNotificationObserver::Observe( NavigationController* controller = content::Source<NavigationController>(source).ptr(); TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( - controller->tab_contents()); + controller->GetWebContents()); int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; if (window_id == new_window_id_) { if (for_browser_command_) { @@ -1143,7 +1143,7 @@ bool ExecuteBrowserCommandObserver::Getint( } FindInPageNotificationObserver::FindInPageNotificationObserver( - AutomationProvider* automation, TabContents* parent_tab, + AutomationProvider* automation, WebContents* parent_tab, bool reply_with_json, IPC::Message* reply_message) : automation_(automation->AsWeakPtr()), active_match_ordinal_(-1), @@ -1396,13 +1396,13 @@ void PageTranslatedObserver::Observe( TabLanguageDeterminedObserver::TabLanguageDeterminedObserver( AutomationProvider* automation, IPC::Message* reply_message, - TabContents* tab_contents, TranslateInfoBarDelegate* translate_bar) + WebContents* web_contents, TranslateInfoBarDelegate* translate_bar) : automation_(automation->AsWeakPtr()), reply_message_(reply_message), - tab_contents_(tab_contents), + web_contents_(web_contents), translate_bar_(translate_bar) { registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, - content::Source<WebContents>(tab_contents)); + content::Source<WebContents>(web_contents_)); } TabLanguageDeterminedObserver::~TabLanguageDeterminedObserver() {} @@ -1418,7 +1418,7 @@ void TabLanguageDeterminedObserver::Observe( } TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( - tab_contents_)->translate_tab_helper(); + web_contents_)->translate_tab_helper(); scoped_ptr<DictionaryValue> return_value(new DictionaryValue); return_value->SetBoolean("page_translated", helper->language_state().IsPageTranslated()); @@ -1426,7 +1426,7 @@ void TabLanguageDeterminedObserver::Observe( "can_translate_page", TranslatePrefs::CanTranslate( automation_->profile()->GetPrefs(), helper->language_state().original_language(), - tab_contents_->GetURL())); + web_contents_->GetURL())); return_value->SetString("original_language", helper->language_state().original_language()); if (translate_bar_) { @@ -2240,7 +2240,7 @@ void AppLaunchObserver::Observe(int type, content::Source<NavigationController>(source).ptr(); TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( - controller->tab_contents()); + controller->GetWebContents()); int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; if (window_id == new_window_id_) { if (automation_) { @@ -2974,7 +2974,7 @@ void BrowserOpenedWithNewProfileNotificationObserver::Observe( NavigationController* controller = content::Source<NavigationController>(source).ptr(); TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( - controller->tab_contents()); + controller->GetWebContents()); int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; if (window_id == new_window_id_) { if (automation_) { diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index 991abb5..30a8d00ff 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -574,7 +574,7 @@ class ExecuteBrowserCommandObserver : public content::NotificationObserver { class FindInPageNotificationObserver : public content::NotificationObserver { public: FindInPageNotificationObserver(AutomationProvider* automation, - TabContents* parent_tab, + content::WebContents* parent_tab, bool reply_with_json, IPC::Message* reply_message); virtual ~FindInPageNotificationObserver(); @@ -710,7 +710,7 @@ class TabLanguageDeterminedObserver : public content::NotificationObserver { public: TabLanguageDeterminedObserver(AutomationProvider* automation, IPC::Message* reply_message, - TabContents* tab_contents, + content::WebContents* web_contents, TranslateInfoBarDelegate* translate_bar); virtual ~TabLanguageDeterminedObserver(); @@ -723,7 +723,7 @@ class TabLanguageDeterminedObserver : public content::NotificationObserver { content::NotificationRegistrar registrar_; base::WeakPtr<AutomationProvider> automation_; scoped_ptr<IPC::Message> reply_message_; - TabContents* tab_contents_; + content::WebContents* web_contents_; TranslateInfoBarDelegate* translate_bar_; DISALLOW_COPY_AND_ASSIGN(TabLanguageDeterminedObserver); diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index dd250da..693c5ec 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -24,7 +24,7 @@ #include "chrome/common/automation_messages.h" #include "chrome/common/render_messages.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/tab_contents/tab_contents.h" +#include "content/browser/tab_contents/navigation_controller.h" #include "content/public/browser/web_contents.h" #include "content/public/common/page_zoom.h" #include "ui/base/keycodes/keyboard_codes.h" @@ -251,7 +251,7 @@ ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); return ExternalTabContainer::GetContainerForTab( - tab->tab_contents()->GetNativeView()); + tab->GetWebContents()->GetNativeView()); } return NULL; @@ -297,13 +297,13 @@ void AutomationProvider::OnForwardContextMenuCommandToChrome(int tab_handle, return; } - TabContents* tab_contents = tab->tab_contents(); - if (!tab_contents || !tab_contents->GetDelegate()) { + WebContents* web_contents = tab->GetWebContents(); + if (!web_contents || !web_contents->GetDelegate()) { NOTREACHED(); return; } - tab_contents->GetDelegate()->ExecuteContextMenuCommand(command); + web_contents->GetDelegate()->ExecuteContextMenuCommand(command); } void AutomationProvider::ConnectExternalTab( @@ -332,7 +332,7 @@ void AutomationProvider::ConnectExternalTab( external_tab_container->Reinitialize(this, automation_resource_message_filter_, parent_window); - TabContents* tab_contents = external_tab_container->tab_contents(); + WebContents* tab_contents = external_tab_container->web_contents(); *tab_handle = external_tab_container->tab_handle(); *tab_container_window = external_tab_container->GetNativeView(); *tab_window = tab_contents->GetNativeView(); @@ -403,8 +403,8 @@ void AutomationProvider::OnRunUnloadHandlers( void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - if (tab->tab_contents() && tab->tab_contents()->GetRenderViewHost()) { - RenderViewHost* host = tab->tab_contents()->GetRenderViewHost(); + if (tab->GetWebContents() && tab->GetWebContents()->GetRenderViewHost()) { + RenderViewHost* host = tab->GetWebContents()->GetRenderViewHost(); content::PageZoom zoom = static_cast<content::PageZoom>(zoom_level); host->Zoom(zoom); } diff --git a/chrome/browser/automation/automation_util.cc b/chrome/browser/automation/automation_util.cc index a5f6a5e..d077088 100644 --- a/chrome/browser/automation/automation_util.cc +++ b/chrome/browser/automation/automation_util.cc @@ -37,6 +37,7 @@ #include "net/url_request/url_request_context_getter.h" using content::BrowserThread; +using content::WebContents; namespace { @@ -157,7 +158,7 @@ Browser* GetBrowserForTab(TabContents* tab) { return NULL; } -net::URLRequestContextGetter* GetRequestContext(TabContents* contents) { +net::URLRequestContextGetter* GetRequestContext(WebContents* contents) { // Since we may be on the UI thread don't call GetURLRequestContext(). // Get the request context specific to the current TabContents and app. return contents->GetBrowserContext()->GetRequestContextForRenderProcess( @@ -165,7 +166,7 @@ net::URLRequestContextGetter* GetRequestContext(TabContents* contents) { } void GetCookies(const GURL& url, - TabContents* contents, + WebContents* contents, int* value_size, std::string* value) { *value_size = -1; @@ -185,7 +186,7 @@ void GetCookies(const GURL& url, void SetCookie(const GURL& url, const std::string& value, - TabContents* contents, + WebContents* contents, int* response_value) { *response_value = -1; @@ -207,7 +208,7 @@ void SetCookie(const GURL& url, void DeleteCookie(const GURL& url, const std::string& cookie_name, - TabContents* contents, + WebContents* contents, bool* success) { *success = false; if (url.is_valid() && contents) { diff --git a/chrome/browser/automation/automation_util.h b/chrome/browser/automation/automation_util.h index 6a7bfe5..5143201 100644 --- a/chrome/browser/automation/automation_util.h +++ b/chrome/browser/automation/automation_util.h @@ -21,6 +21,10 @@ class RenderViewHost; class TabContents; class TabContentsWrapper; +namespace content { +class WebContents; +} + namespace base { class DictionaryValue; } @@ -47,20 +51,20 @@ Browser* GetBrowserForTab(TabContents* tab); // Gets the size and value of the cookie string for |url| in the given tab. // Can be called from any thread. void GetCookies(const GURL& url, - TabContents* contents, + content::WebContents* contents, int* value_size, std::string* value); // Sets a cookie for |url| in the given tab. Can be called from any thread. void SetCookie(const GURL& url, const std::string& value, - TabContents* contents, + content::WebContents* contents, int* response_value); // Deletes a cookie for |url| in the given tab. Can be called from any thread. void DeleteCookie(const GURL& url, const std::string& cookie_name, - TabContents* contents, + content::WebContents* contents, bool* success); // Gets the cookies for the given URL. Uses the JSON interface. diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 9afdcae..8650080 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -576,7 +576,7 @@ void TestingAutomationProvider::CloseTab(int tab_handle, Browser* browser = Browser::GetBrowserForController(controller, &index); DCHECK(browser); new TabClosedNotificationObserver(this, wait_until_closed, reply_message); - browser->CloseTabContents(controller->tab_contents()); + browser->CloseTabContents(controller->GetWebContents()); return; } @@ -587,8 +587,8 @@ void TestingAutomationProvider::CloseTab(int tab_handle, void TestingAutomationProvider::GetCookies(const GURL& url, int handle, int* value_size, std::string* value) { - TabContents *contents = tab_tracker_->ContainsHandle(handle) ? - tab_tracker_->GetResource(handle)->tab_contents() : NULL; + WebContents* contents = tab_tracker_->ContainsHandle(handle) ? + tab_tracker_->GetResource(handle)->GetWebContents() : NULL; automation_util::GetCookies(url, contents, value_size, value); } @@ -596,16 +596,16 @@ void TestingAutomationProvider::SetCookie(const GURL& url, const std::string& value, int handle, int* response_value) { - TabContents *contents = tab_tracker_->ContainsHandle(handle) ? - tab_tracker_->GetResource(handle)->tab_contents() : NULL; + WebContents* contents = tab_tracker_->ContainsHandle(handle) ? + tab_tracker_->GetResource(handle)->GetWebContents() : NULL; automation_util::SetCookie(url, value, contents, response_value); } void TestingAutomationProvider::DeleteCookie(const GURL& url, const std::string& cookie_name, int handle, bool* success) { - TabContents *contents = tab_tracker_->ContainsHandle(handle) ? - tab_tracker_->GetResource(handle)->tab_contents() : NULL; + WebContents* contents = tab_tracker_->ContainsHandle(handle) ? + tab_tracker_->GetResource(handle)->GetWebContents() : NULL; automation_util::DeleteCookie(url, cookie_name, contents, success); } @@ -614,7 +614,7 @@ void TestingAutomationProvider::ShowCollectedCookiesDialog( *success = false; if (tab_tracker_->ContainsHandle(handle)) { NavigationController* controller = tab_tracker_->GetResource(handle); - TabContents* tab_contents = controller->tab_contents(); + WebContents* tab_contents = controller->GetWebContents(); Browser* browser = Browser::GetBrowserForController(controller, NULL); browser->ShowCollectedCookiesDialog( TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)); @@ -1271,9 +1271,9 @@ void TestingAutomationProvider::GetTabProcessID(int handle, int* process_id) { if (tab_tracker_->ContainsHandle(handle)) { *process_id = 0; - TabContents* tab_contents = - tab_tracker_->GetResource(handle)->tab_contents(); - content::RenderProcessHost* rph = tab_contents->GetRenderProcessHost(); + WebContents* web_contents = + tab_tracker_->GetResource(handle)->GetWebContents(); + content::RenderProcessHost* rph = web_contents->GetRenderProcessHost(); if (rph) *process_id = base::GetProcId(rph->GetHandle()); } @@ -1400,10 +1400,10 @@ void TestingAutomationProvider::GetConstrainedWindowCount(int handle, *count = -1; // -1 is the error code if (tab_tracker_->ContainsHandle(handle)) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); - TabContents* tab_contents = nav_controller->tab_contents(); - if (tab_contents) { + WebContents* web_contents = nav_controller->GetWebContents(); + if (web_contents) { TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents); if (wrapper) { *count = static_cast<int>(wrapper->constrained_window_tab_helper()-> constrained_window_count()); @@ -1524,13 +1524,13 @@ void TestingAutomationProvider::ShowInterstitialPage( IPC::Message* reply_message) { if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* controller = tab_tracker_->GetResource(tab_handle); - TabContents* tab_contents = controller->tab_contents(); + WebContents* web_contents = controller->GetWebContents(); new NavigationNotificationObserver(controller, this, reply_message, 1, false, false); AutomationInterstitialPage* interstitial = - new AutomationInterstitialPage(tab_contents, + new AutomationInterstitialPage(static_cast<TabContents*>(web_contents), GURL("about:interstitial"), html_text); interstitial->Show(); @@ -1599,7 +1599,7 @@ void TestingAutomationProvider::GetPageType( // In order to return the proper result when an interstitial is shown and // no navigation entry were created for it we need to ask the TabContents. if (*page_type == content::PAGE_TYPE_NORMAL && - tab->tab_contents()->ShowingInterstitialPage()) + tab->GetWebContents()->ShowingInterstitialPage()) *page_type = content::PAGE_TYPE_INTERSTITIAL; } else { *success = false; @@ -1622,9 +1622,10 @@ void TestingAutomationProvider::ActionOnSSLBlockingPage( NavigationController* tab = tab_tracker_->GetResource(handle); NavigationEntry* entry = tab->GetActiveEntry(); if (entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL) { - TabContents* tab_contents = tab->tab_contents(); + WebContents* web_contents = tab->GetWebContents(); InterstitialPage* ssl_blocking_page = - InterstitialPage::GetInterstitialPage(tab_contents); + InterstitialPage::GetInterstitialPage( + static_cast<TabContents*>(web_contents)); if (ssl_blocking_page) { if (proceed) { new NavigationNotificationObserver(tab, this, reply_message, 1, @@ -1717,7 +1718,7 @@ void TestingAutomationProvider::SavePage(int tab_handle, return; } - nav->tab_contents()->SavePage(file_name, dir_path, save_type); + nav->GetWebContents()->SavePage(file_name, dir_path, save_type); *success = true; } @@ -1973,7 +1974,7 @@ void TestingAutomationProvider::GetInfoBarCount(int handle, size_t* count) { if (nav_controller) { TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents( - nav_controller->tab_contents()); + nav_controller->GetWebContents()); *count = wrapper->infobar_tab_helper()->infobar_count(); } } @@ -1990,7 +1991,7 @@ void TestingAutomationProvider::ClickInfoBarAccept( if (nav_controller) { InfoBarTabHelper* infobar_helper = TabContentsWrapper::GetCurrentWrapperForContents( - nav_controller->tab_contents())->infobar_tab_helper(); + nav_controller->GetWebContents())->infobar_tab_helper(); if (info_bar_index < infobar_helper->infobar_count()) { if (wait_for_navigation) { new NavigationNotificationObserver(nav_controller, this, @@ -2220,7 +2221,7 @@ void TestingAutomationProvider::GetBlockedPopupCount(int handle, int* count) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); TabContentsWrapper* tab_contents = TabContentsWrapper::GetCurrentWrapperForContents( - nav_controller->tab_contents()); + nav_controller->GetWebContents()); if (tab_contents) { BlockedContentTabHelper* blocked_content = tab_contents->blocked_content_tab_helper(); @@ -6052,7 +6053,7 @@ void TestingAutomationProvider::GetIndicesFromTab( int id = id_or_handle; if (has_handle) { TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( - tab_tracker_->GetResource(id_or_handle)->tab_contents()); + tab_tracker_->GetResource(id_or_handle)->GetWebContents()); id = tab->restore_tab_helper()->session_id().id(); } BrowserList::const_iterator iter = BrowserList::begin(); @@ -6573,7 +6574,7 @@ void TestingAutomationProvider::WaitForInfoBarCount( // The delegate will delete itself. new InfoBarCountObserver(this, reply_message, TabContentsWrapper::GetCurrentWrapperForContents( - controller->tab_contents()), target_count); + controller->GetWebContents()), target_count); } // Gets the current used encoding name of the page in the specified tab. @@ -6582,10 +6583,8 @@ void TestingAutomationProvider::GetPageCurrentEncoding( if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* nav = tab_tracker_->GetResource(tab_handle); Browser* browser = FindAndActivateTab(nav); - DCHECK(browser); - if (browser->command_updater()->IsCommandEnabled(IDC_ENCODING_MENU)) - *current_encoding = nav->tab_contents()->GetEncoding(); + *current_encoding = nav->GetWebContents()->GetEncoding(); } } @@ -6631,7 +6630,7 @@ void TestingAutomationProvider::LoadBlockedPlugins(int tab_handle, NavigationController* nav = tab_tracker_->GetResource(tab_handle); if (!nav) return; - TabContents* contents = nav->tab_contents(); + WebContents* contents = nav->GetWebContents(); if (!contents) return; RenderViewHost* host = contents->GetRenderViewHost(); diff --git a/chrome/browser/chromeos/locale_change_guard.cc b/chrome/browser/chromeos/locale_change_guard.cc index 62b73c2..8725089 100644 --- a/chrome/browser/chromeos/locale_change_guard.cc +++ b/chrome/browser/chromeos/locale_change_guard.cc @@ -15,15 +15,16 @@ #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/user_metrics.h" +#include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" using content::UserMetricsAction; +using content::WebContents; namespace chromeos { @@ -88,7 +89,7 @@ void LocaleChangeGuard::Observe(int type, switch (type) { case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { if (profile_ == - content::Source<TabContents>(source)->GetBrowserContext()) { + content::Source<WebContents>(source)->GetBrowserContext()) { // We need to perform locale change check only once, so unsubscribe. registrar_.Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, content::NotificationService::AllSources()); diff --git a/chrome/browser/chromeos/login/login_html_dialog.cc b/chrome/browser/chromeos/login/login_html_dialog.cc index f9be759..12615d9 100644 --- a/chrome/browser/chromeos/login/login_html_dialog.cc +++ b/chrome/browser/chromeos/login/login_html_dialog.cc @@ -79,8 +79,8 @@ void LoginHtmlDialog::Show() { bubble_frame_view_->StartThrobber(); notification_registrar_.Add( this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, - content::Source<TabContents>( - html_view->dom_contents()->tab_contents())); + content::Source<WebContents>( + html_view->dom_contents()->web_contents())); } #endif html_view->GetWidget()->Show(); diff --git a/chrome/browser/crash_recovery_browsertest.cc b/chrome/browser/crash_recovery_browsertest.cc index b94d1d7..0754059 100644 --- a/chrome/browser/crash_recovery_browsertest.cc +++ b/chrome/browser/crash_recovery_browsertest.cc @@ -21,7 +21,7 @@ namespace { void SimulateRendererCrash(Browser* browser) { ui_test_utils::WindowedNotificationObserver observer( - content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, + content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, content::NotificationService::AllSources()); browser->OpenURL(OpenURLParams( GURL(chrome::kChromeUICrashURL), Referrer(), CURRENT_TAB, diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc index 689419d..ee72ab8 100644 --- a/chrome/browser/extensions/extension_browser_event_router.cc +++ b/chrome/browser/extensions/extension_browser_event_router.cc @@ -18,8 +18,9 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" -#include "content/browser/tab_contents/tab_contents.h" +#include "content/browser/tab_contents/navigation_controller.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/web_contents.h" #if defined(TOOLKIT_GTK) #include "ui/base/x/active_window_watcher_x.h" @@ -37,7 +38,7 @@ ExtensionBrowserEventRouter::TabEntry::TabEntry() } DictionaryValue* ExtensionBrowserEventRouter::TabEntry::UpdateLoadState( - const TabContents* contents) { + const WebContents* contents) { // The tab may go in & out of loading (for instance if iframes navigate). // We only want to respond to the first change from loading to !loading after // the NAV_ENTRY_COMMITTED was fired. @@ -53,7 +54,7 @@ DictionaryValue* ExtensionBrowserEventRouter::TabEntry::UpdateLoadState( } DictionaryValue* ExtensionBrowserEventRouter::TabEntry::DidNavigate( - const TabContents* contents) { + const WebContents* contents) { // Send "loading" state change. complete_waiting_on_load_ = true; DictionaryValue* changed_properties = new DictionaryValue(); @@ -93,7 +94,8 @@ void ExtensionBrowserEventRouter::Init() { Browser* browser = *iter; if (browser->tabstrip_model()) { for (int i = 0; i < browser->tabstrip_model()->count(); ++i) { - TabContents* contents = browser->GetTabContentsAt(i); + WebContents* contents = + browser->GetTabContentsWrapperAt(i)->web_contents(); int tab_id = ExtensionTabUtil::GetTabId(contents); tab_entries_[tab_id] = TabEntry(); } @@ -137,12 +139,14 @@ void ExtensionBrowserEventRouter::RegisterForBrowserNotifications( registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, content::Source<const Browser>(browser)); - for (int i = 0; i < browser->tabstrip_model()->count(); ++i) - RegisterForTabNotifications(browser->GetTabContentsAt(i)); + for (int i = 0; i < browser->tabstrip_model()->count(); ++i) { + RegisterForTabNotifications( + browser->GetTabContentsWrapperAt(i)->web_contents()); + } } void ExtensionBrowserEventRouter::RegisterForTabNotifications( - TabContents* contents) { + WebContents* contents) { registrar_.Add( this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>(&contents->GetController())); @@ -156,7 +160,7 @@ void ExtensionBrowserEventRouter::RegisterForTabNotifications( } void ExtensionBrowserEventRouter::UnregisterForTabNotifications( - TabContents* contents) { + WebContents* contents) { registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>(&contents->GetController())); registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, @@ -249,7 +253,7 @@ void ExtensionBrowserEventRouter::OnBrowserSetLastActive( none_json_args); } -void ExtensionBrowserEventRouter::TabCreatedAt(TabContents* contents, +void ExtensionBrowserEventRouter::TabCreatedAt(WebContents* contents, int index, bool active) { Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); @@ -262,11 +266,11 @@ void ExtensionBrowserEventRouter::TabInsertedAt(TabContentsWrapper* contents, int index, bool active) { // If tab is new, send created event. - int tab_id = ExtensionTabUtil::GetTabId(contents->tab_contents()); - if (!GetTabEntry(contents->tab_contents())) { + int tab_id = ExtensionTabUtil::GetTabId(contents->web_contents()); + if (!GetTabEntry(contents->web_contents())) { tab_entries_[tab_id] = TabEntry(); - TabCreatedAt(contents->tab_contents(), index, active); + TabCreatedAt(contents->web_contents(), index, active); return; } @@ -275,7 +279,7 @@ void ExtensionBrowserEventRouter::TabInsertedAt(TabContentsWrapper* contents, DictionaryValue* object_args = new DictionaryValue(); object_args->Set(tab_keys::kNewWindowIdKey, Value::CreateIntegerValue( - ExtensionTabUtil::GetWindowIdOfTab(contents->tab_contents()))); + ExtensionTabUtil::GetWindowIdOfTab(contents->web_contents()))); object_args->Set(tab_keys::kNewPositionKey, Value::CreateIntegerValue( index)); args.Append(object_args); @@ -288,18 +292,18 @@ void ExtensionBrowserEventRouter::TabInsertedAt(TabContentsWrapper* contents, void ExtensionBrowserEventRouter::TabDetachedAt(TabContentsWrapper* contents, int index) { - if (!GetTabEntry(contents->tab_contents())) { + if (!GetTabEntry(contents->web_contents())) { // The tab was removed. Don't send detach event. return; } ListValue args; args.Append(Value::CreateIntegerValue( - ExtensionTabUtil::GetTabId(contents->tab_contents()))); + ExtensionTabUtil::GetTabId(contents->web_contents()))); DictionaryValue* object_args = new DictionaryValue(); object_args->Set(tab_keys::kOldWindowIdKey, Value::CreateIntegerValue( - ExtensionTabUtil::GetWindowIdOfTab(contents->tab_contents()))); + ExtensionTabUtil::GetWindowIdOfTab(contents->web_contents()))); object_args->Set(tab_keys::kOldPositionKey, Value::CreateIntegerValue( index)); args.Append(object_args); @@ -313,7 +317,7 @@ void ExtensionBrowserEventRouter::TabDetachedAt(TabContentsWrapper* contents, void ExtensionBrowserEventRouter::TabClosingAt(TabStripModel* tab_strip_model, TabContentsWrapper* contents, int index) { - int tab_id = ExtensionTabUtil::GetTabId(contents->tab_contents()); + int tab_id = ExtensionTabUtil::GetTabId(contents->web_contents()); ListValue args; args.Append(Value::CreateIntegerValue(tab_id)); @@ -331,7 +335,7 @@ void ExtensionBrowserEventRouter::TabClosingAt(TabStripModel* tab_strip_model, int removed_count = tab_entries_.erase(tab_id); DCHECK_GT(removed_count, 0); - UnregisterForTabNotifications(contents->tab_contents()); + UnregisterForTabNotifications(contents->web_contents()); } void ExtensionBrowserEventRouter::ActiveTabChanged( @@ -341,11 +345,11 @@ void ExtensionBrowserEventRouter::ActiveTabChanged( bool user_gesture) { ListValue args; args.Append(Value::CreateIntegerValue( - ExtensionTabUtil::GetTabId(new_contents->tab_contents()))); + ExtensionTabUtil::GetTabId(new_contents->web_contents()))); DictionaryValue* object_args = new DictionaryValue(); object_args->Set(tab_keys::kWindowIdKey, Value::CreateIntegerValue( - ExtensionTabUtil::GetWindowIdOfTab(new_contents->tab_contents()))); + ExtensionTabUtil::GetWindowIdOfTab(new_contents->web_contents()))); args.Append(object_args); std::string json_args; @@ -370,7 +374,7 @@ void ExtensionBrowserEventRouter::TabSelectionChanged( TabContentsWrapper* contents = tab_strip_model->GetTabContentsAt(index); if (!contents) break; - int tab_id = ExtensionTabUtil::GetTabId(contents->tab_contents()); + int tab_id = ExtensionTabUtil::GetTabId(contents->web_contents()); all->Append(Value::CreateIntegerValue(tab_id)); } @@ -395,11 +399,11 @@ void ExtensionBrowserEventRouter::TabMoved(TabContentsWrapper* contents, int to_index) { ListValue args; args.Append(Value::CreateIntegerValue( - ExtensionTabUtil::GetTabId(contents->tab_contents()))); + ExtensionTabUtil::GetTabId(contents->web_contents()))); DictionaryValue* object_args = new DictionaryValue(); object_args->Set(tab_keys::kWindowIdKey, Value::CreateIntegerValue( - ExtensionTabUtil::GetWindowIdOfTab(contents->tab_contents()))); + ExtensionTabUtil::GetWindowIdOfTab(contents->web_contents()))); object_args->Set(tab_keys::kFromIndexKey, Value::CreateIntegerValue( from_index)); object_args->Set(tab_keys::kToIndexKey, Value::CreateIntegerValue( @@ -412,7 +416,7 @@ void ExtensionBrowserEventRouter::TabMoved(TabContentsWrapper* contents, DispatchEvent(contents->profile(), events::kOnTabMoved, json_args); } -void ExtensionBrowserEventRouter::TabUpdated(TabContents* contents, +void ExtensionBrowserEventRouter::TabUpdated(WebContents* contents, bool did_navigate) { TabEntry* entry = GetTabEntry(contents); DictionaryValue* changed_properties = NULL; @@ -466,14 +470,14 @@ void ExtensionBrowserEventRouter::DispatchEventWithTab( Profile* profile, const std::string& extension_id, const char* event_name, - const TabContents* tab_contents, + const WebContents* web_contents, bool active) { if (!profile_->IsSameProfile(profile)) return; ListValue args; args.Append(ExtensionTabUtil::CreateTabValueActive( - tab_contents, active)); + web_contents, active)); std::string json_args; base::JSONWriter::Write(&args, false, &json_args); if (!extension_id.empty()) { @@ -498,7 +502,7 @@ void ExtensionBrowserEventRouter::DispatchSimpleBrowserEvent( } void ExtensionBrowserEventRouter::DispatchTabUpdatedEvent( - TabContents* contents, DictionaryValue* changed_properties) { + WebContents* contents, DictionaryValue* changed_properties) { DCHECK(changed_properties); DCHECK(contents); @@ -523,7 +527,7 @@ void ExtensionBrowserEventRouter::DispatchTabUpdatedEvent( } ExtensionBrowserEventRouter::TabEntry* ExtensionBrowserEventRouter::GetTabEntry( - const TabContents* contents) { + const WebContents* contents) { int tab_id = ExtensionTabUtil::GetTabId(contents); std::map<int, TabEntry>::iterator i = tab_entries_.find(tab_id); if (tab_entries_.end() == i) @@ -538,7 +542,7 @@ void ExtensionBrowserEventRouter::Observe( if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { NavigationController* source_controller = content::Source<NavigationController>(source).ptr(); - TabUpdated(source_controller->tab_contents(), true); + TabUpdated(source_controller->GetWebContents(), true); } else if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { // Tab was destroyed after being detached (without being re-attached). WebContents* contents = content::Source<WebContents>(source).ptr(); @@ -561,7 +565,7 @@ void ExtensionBrowserEventRouter::Observe( void ExtensionBrowserEventRouter::TabChangedAt(TabContentsWrapper* contents, int index, TabChangeType change_type) { - TabUpdated(contents->tab_contents(), false); + TabUpdated(contents->web_contents(), false); } void ExtensionBrowserEventRouter::TabReplacedAt( @@ -580,11 +584,11 @@ void ExtensionBrowserEventRouter::TabPinnedStateChanged( int tab_index; if (ExtensionTabUtil::GetTabStripModel( - contents->tab_contents(), &tab_strip, &tab_index)) { + contents->web_contents(), &tab_strip, &tab_index)) { DictionaryValue* changed_properties = new DictionaryValue(); changed_properties->SetBoolean(tab_keys::kPinnedKey, tab_strip->IsTabPinned(tab_index)); - DispatchTabUpdatedEvent(contents->tab_contents(), changed_properties); + DispatchTabUpdatedEvent(contents->web_contents(), changed_properties); } } @@ -627,7 +631,7 @@ void ExtensionBrowserEventRouter::PageActionExecuted( return; } DispatchEventWithTab(profile, extension_id, "pageAction.onClicked", - tab_contents->tab_contents(), true); + tab_contents->web_contents(), true); } void ExtensionBrowserEventRouter::BrowserActionExecuted( @@ -637,5 +641,5 @@ void ExtensionBrowserEventRouter::BrowserActionExecuted( if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) return; DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", - tab_contents->tab_contents(), true); + tab_contents->web_contents(), true); } diff --git a/chrome/browser/extensions/extension_browser_event_router.h b/chrome/browser/extensions/extension_browser_event_router.h index f0f1703..9b97299 100644 --- a/chrome/browser/extensions/extension_browser_event_router.h +++ b/chrome/browser/extensions/extension_browser_event_router.h @@ -21,6 +21,10 @@ #include "ui/base/x/active_window_watcher_x_observer.h" #endif +namespace content { +class WebContents; +} + // The ExtensionBrowserEventRouter listens to Browser window & tab events // and routes them to listeners inside extension process renderers. // ExtensionBrowserEventRouter listens to *all* events, but will only route @@ -101,11 +105,11 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver, const content::NotificationDetails& details) OVERRIDE; private: // "Synthetic" event. Called from TabInsertedAt if new tab is detected. - void TabCreatedAt(TabContents* contents, int index, bool active); + void TabCreatedAt(content::WebContents* contents, int index, bool active); // Internal processing of tab updated events. Is called by both TabChangedAt // and Observe/NAV_ENTRY_COMMITTED. - void TabUpdated(TabContents* contents, bool did_navigate); + void TabUpdated(content::WebContents* contents, bool did_navigate); // The DispatchEvent methods forward events to the |profile|'s event router. // The ExtensionBrowserEventRouter listens to events for all profiles, @@ -127,7 +131,7 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver, void DispatchEventWithTab(Profile* profile, const std::string& extension_id, const char* event_name, - const TabContents* tab_contents, + const content::WebContents* web_contents, bool active); void DispatchSimpleBrowserEvent(Profile* profile, @@ -136,7 +140,7 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver, // Packages |changed_properties| as a tab updated event for the tab |contents| // and dispatches the event to the extension. - void DispatchTabUpdatedEvent(TabContents* contents, + void DispatchTabUpdatedEvent(content::WebContents* contents, DictionaryValue* changed_properties); // Called to dispatch a deprecated style page action click event that was @@ -155,10 +159,10 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver, // Register ourselves to receive the various notifications we are interested // in for a tab. - void RegisterForTabNotifications(TabContents* contents); + void RegisterForTabNotifications(content::WebContents* contents); // Removes notifications added in RegisterForTabNotifications. - void UnregisterForTabNotifications(TabContents* contents); + void UnregisterForTabNotifications(content::WebContents* contents); content::NotificationRegistrar registrar_; @@ -176,18 +180,18 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver, // std::map<> by value. TabEntry(); - // Update the load state of the tab based on its TabContents. Returns true + // Update the load state of the tab based on its WebContents. Returns true // if the state changed, false otherwise. Whether the state has changed or // not is used to determine if events needs to be sent to extensions during // processing of TabChangedAt(). This method will "hold" a state-change // to "loading", until the DidNavigate() method which should always follow // it. Returns NULL if no updates should be sent. - DictionaryValue* UpdateLoadState(const TabContents* contents); + DictionaryValue* UpdateLoadState(const content::WebContents* contents); // Indicates that a tab load has resulted in a navigation and the // destination url is available for inspection. Returns NULL if no updates // should be sent. - DictionaryValue* DidNavigate(const TabContents* contents); + DictionaryValue* DidNavigate(const content::WebContents* contents); private: // Whether we are waiting to fire the 'complete' status change. This will @@ -201,7 +205,7 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver, // Gets the TabEntry for the given |contents|. Returns TabEntry* if // found, NULL if not. - TabEntry* GetTabEntry(const TabContents* contents); + TabEntry* GetTabEntry(const content::WebContents* contents); std::map<int, TabEntry> tab_entries_; diff --git a/chrome/browser/extensions/extension_tab_id_map.cc b/chrome/browser/extensions/extension_tab_id_map.cc index cd70e74..48a9741 100644 --- a/chrome/browser/extensions/extension_tab_id_map.cc +++ b/chrome/browser/extensions/extension_tab_id_map.cc @@ -11,13 +11,14 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/web_contents.h" using content::BrowserThread; using content::WebContents; @@ -64,7 +65,7 @@ void ExtensionTabIdMap::TabObserver::Observe( const content::NotificationDetails& details) { switch (type) { case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { - TabContents* contents = content::Source<TabContents>(source).ptr(); + WebContents* contents = content::Source<WebContents>(source).ptr(); TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents(contents); if (!tab) @@ -85,7 +86,7 @@ void ExtensionTabIdMap::TabObserver::Observe( case content::NOTIFICATION_TAB_PARENTED: { TabContentsWrapper* tab = content::Source<TabContentsWrapper>(source).ptr(); - RenderViewHost* host = tab->tab_contents()->GetRenderViewHost(); + RenderViewHost* host = tab->web_contents()->GetRenderViewHost(); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind( diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc index bd0361e..ecd0223 100644 --- a/chrome/browser/extensions/webstore_installer.cc +++ b/chrome/browser/extensions/webstore_installer.cc @@ -201,7 +201,7 @@ void WebstoreInstaller::StartDownload(FilePath file) { // We will navigate the current tab to this url to start the download. The // download system will then pass the crx to the CrxInstaller. profile_->GetDownloadManager()->DownloadUrlToFile( - download_url_, referrer, "", save_info, controller_->tab_contents()); + download_url_, referrer, "", save_info, controller_->GetWebContents()); } void WebstoreInstaller::ReportFailure(const std::string& error) { diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index c1e0fbf..9ad3040 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -210,7 +210,7 @@ bool ExternalTabContainer::Init(Profile* profile, registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>(controller)); registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, - content::Source<TabContents>(tab_contents_->tab_contents())); + content::Source<WebContents>(tab_contents_->web_contents())); registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, content::NotificationService::AllSources()); registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index 6daa8e9..ae1c539 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.cc @@ -21,9 +21,9 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/web_contents.h" #include "content/public/common/url_fetcher.h" #include "grit/generated_resources.h" #include "net/base/load_flags.h" @@ -34,6 +34,7 @@ using content::OpenURLParams; using content::Referrer; +using content::WebContents; namespace { @@ -313,7 +314,7 @@ void GoogleURLTracker::RedoSearch() { if (new_search_url.is_valid()) { OpenURLParams params(new_search_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_GENERATED, false); - controller_->tab_contents()->OpenURL(params); + controller_->GetWebContents()->OpenURL(params); } } @@ -331,7 +332,7 @@ void GoogleURLTracker::Observe(int type, case content::NOTIFICATION_NAV_ENTRY_COMMITTED: case content::NOTIFICATION_TAB_CLOSED: OnNavigationCommittedOrTabClosed( - content::Source<NavigationController>(source).ptr()->tab_contents(), + content::Source<NavigationController>(source).ptr()->GetWebContents(), type); break; @@ -370,12 +371,12 @@ void GoogleURLTracker::OnNavigationPending( } void GoogleURLTracker::OnNavigationCommittedOrTabClosed( - TabContents* tab_contents, + WebContents* web_contents, int type) { registrar_.RemoveAll(); if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { - ShowGoogleURLInfoBarIfNecessary(tab_contents); + ShowGoogleURLInfoBarIfNecessary(web_contents); } else { controller_ = NULL; infobar_ = NULL; @@ -383,16 +384,16 @@ void GoogleURLTracker::OnNavigationCommittedOrTabClosed( } void GoogleURLTracker::ShowGoogleURLInfoBarIfNecessary( - TabContents* tab_contents) { + WebContents* web_contents) { if (!need_to_prompt_) return; DCHECK(!fetched_google_url_.is_empty()); // |tab_contents| can be NULL during tests. InfoBarTabHelper* infobar_helper = NULL; - if (tab_contents) { + if (web_contents) { TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents); infobar_helper = wrapper->infobar_tab_helper(); } infobar_ = (*infobar_creator_)(infobar_helper, this, fetched_google_url_); diff --git a/chrome/browser/google/google_url_tracker.h b/chrome/browser/google/google_url_tracker.h index c3d5d5e..f8ad46d 100644 --- a/chrome/browser/google/google_url_tracker.h +++ b/chrome/browser/google/google_url_tracker.h @@ -20,7 +20,10 @@ class NavigationController; class PrefService; -class TabContents; + +namespace content { +class WebContents; +} // This object is responsible for checking the Google URL once per network // change, and if necessary prompting the user to see if they want to change to @@ -119,9 +122,9 @@ class GoogleURLTracker : public content::URLFetcherDelegate, void SearchCommitted(); void OnNavigationPending(const content::NotificationSource& source, const GURL& pending_url); - void OnNavigationCommittedOrTabClosed(TabContents* tab_contents, + void OnNavigationCommittedOrTabClosed(content::WebContents* web_contents, int type); - void ShowGoogleURLInfoBarIfNecessary(TabContents* tab_contents); + void ShowGoogleURLInfoBarIfNecessary(content::WebContents* web_contents); content::NotificationRegistrar registrar_; InfobarCreator infobar_creator_; diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc index bad53ad..da7be4c 100644 --- a/chrome/browser/history/top_sites.cc +++ b/chrome/browser/history/top_sites.cc @@ -28,11 +28,11 @@ #include "chrome/common/pref_names.h" #include "chrome/common/thumbnail_score.h" #include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/web_contents.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -848,7 +848,7 @@ void TopSites::Observe(int type, NavigationController* controller = content::Source<NavigationController>(source).ptr(); Profile* profile = Profile::FromBrowserContext( - controller->tab_contents()->GetBrowserContext()); + controller->GetWebContents()->GetBrowserContext()); if (profile == profile_ && !IsFull()) { content::LoadCommittedDetails* load_details = content::Details<content::LoadCommittedDetails>(details).ptr(); diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc index b6013be..43bf30b 100644 --- a/chrome/browser/instant/instant_loader.cc +++ b/chrome/browser/instant/instant_loader.cc @@ -34,6 +34,7 @@ #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" +#include "content/browser/tab_contents/navigation_controller.h" #include "content/browser/tab_contents/provisional_load_details.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_view.h" @@ -93,17 +94,17 @@ const char* const InstantLoader::kInstantHeaderValue = "instant"; class InstantLoader::FrameLoadObserver : public content::NotificationObserver { public: FrameLoadObserver(InstantLoader* loader, - TabContents* tab_contents, + WebContents* web_contents, const string16& text, bool verbatim) : loader_(loader), - tab_contents_(tab_contents), + web_contents_(web_contents), text_(text), verbatim_(verbatim), unique_id_( - tab_contents_->GetController().GetPendingEntry()->GetUniqueID()) { + web_contents_->GetController().GetPendingEntry()->GetUniqueID()) { registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, - content::Source<TabContents>(tab_contents_)); + content::Source<WebContents>(web_contents_)); } // Sets the text to send to the page. @@ -120,8 +121,8 @@ class InstantLoader::FrameLoadObserver : public content::NotificationObserver { private: InstantLoader* loader_; - // The TabContents we're listening for changes on. - TabContents* tab_contents_; + // The WebContents we're listening for changes on. + WebContents* web_contents_; // Text to send down to the page. string16 text_; @@ -146,7 +147,7 @@ void InstantLoader::FrameLoadObserver::Observe( case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { int page_id = *(content::Details<int>(details).ptr()); NavigationEntry* active_entry = - tab_contents_->GetController().GetActiveEntry(); + web_contents_->GetController().GetActiveEntry(); if (!active_entry || active_entry->GetPageID() != page_id || active_entry->GetUniqueID() != unique_id_) { return; @@ -154,7 +155,7 @@ void InstantLoader::FrameLoadObserver::Observe( loader_->SendBoundsToPage(true); // TODO: support real cursor position. int text_length = static_cast<int>(text_.size()); - RenderViewHost* host = tab_contents_->GetRenderViewHost(); + RenderViewHost* host = web_contents_->GetRenderViewHost(); host->Send(new ChromeViewMsg_DetermineIfPageSupportsInstant( host->routing_id(), text_, verbatim_, text_length, text_length)); break; @@ -285,7 +286,7 @@ class InstantLoader::TabContentsDelegateImpl InstantLoader::TabContentsDelegateImpl::TabContentsDelegateImpl( InstantLoader* loader) - : content::WebContentsObserver(loader->preview_contents()->tab_contents()), + : content::WebContentsObserver(loader->preview_contents()->web_contents()), loader_(loader), registered_render_widget_host_(NULL), waiting_for_new_page_(true), @@ -293,10 +294,10 @@ InstantLoader::TabContentsDelegateImpl::TabContentsDelegateImpl( user_typed_before_load_(false) { DCHECK(loader->preview_contents()); registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED, - content::Source<TabContents>(loader->preview_contents()->tab_contents())); + content::Source<WebContents>(loader->preview_contents()->web_contents())); registrar_.Add(this, content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, content::Source<NavigationController>( - &loader->preview_contents()->tab_contents()->GetController())); + &loader->preview_contents()->web_contents()->GetController())); } void InstantLoader::TabContentsDelegateImpl::PrepareForNewLoad() { @@ -337,7 +338,7 @@ void InstantLoader::TabContentsDelegateImpl::CommitHistory( } NavigationEntry* active_entry = - tab->tab_contents()->GetController().GetActiveEntry(); + tab->web_contents()->GetController().GetActiveEntry(); if (!active_entry) { // It appears to be possible to get here with no active entry. This seems // to be possible with an auth dialog, but I can't narrow down the @@ -554,7 +555,7 @@ void InstantLoader::TabContentsDelegateImpl::OnSetSuggestions( InstantCompleteBehavior behavior) { TabContentsWrapper* source = loader_->preview_contents(); NavigationEntry* entry = - source->tab_contents()->GetController().GetActiveEntry(); + source->web_contents()->GetController().GetActiveEntry(); if (!entry || page_id != entry->GetPageID()) return; @@ -567,7 +568,7 @@ void InstantLoader::TabContentsDelegateImpl::OnSetSuggestions( void InstantLoader::TabContentsDelegateImpl::OnInstantSupportDetermined( int32 page_id, bool result) { - TabContents* source = loader_->preview_contents()->tab_contents(); + WebContents* source = loader_->preview_contents()->web_contents(); if (!source->GetController().GetActiveEntry() || page_id != source->GetController().GetActiveEntry()->GetPageID()) return; @@ -676,7 +677,7 @@ bool InstantLoader::Update(TabContentsWrapper* tab_contents, // TODO: support real cursor position. int text_length = static_cast<int>(user_text_.size()); RenderViewHost* host = - preview_contents_->tab_contents()->GetRenderViewHost(); + preview_contents_->web_contents()->GetRenderViewHost(); host->Send(new ChromeViewMsg_SearchBoxChange( host->routing_id(), user_text_, verbatim, text_length, text_length)); @@ -698,7 +699,7 @@ bool InstantLoader::Update(TabContentsWrapper* tab_contents, DCHECK(template_url_id_ == 0); preview_tab_contents_delegate_->PrepareForNewLoad(); frame_load_observer_.reset(NULL); - preview_contents_->tab_contents()->GetController().LoadURL( + preview_contents_->web_contents()->GetController().LoadURL( url_, content::Referrer(), transition_type, std::string()); } return true; @@ -746,7 +747,7 @@ TabContentsWrapper* InstantLoader::ReleasePreviewContents( if (type != INSTANT_COMMIT_DESTROY && is_showing_instant()) { RenderViewHost* host = - preview_contents_->tab_contents()->GetRenderViewHost(); + preview_contents_->web_contents()->GetRenderViewHost(); if (type == INSTANT_COMMIT_FOCUS_LOST) { host->Send(new ChromeViewMsg_SearchBoxCancel(host->routing_id())); } else { @@ -771,18 +772,18 @@ TabContentsWrapper* InstantLoader::ReleasePreviewContents( } preview_tab_contents_delegate_->CommitHistory(template_url_id_ != 0); } - if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) { + if (preview_contents_->web_contents()->GetRenderWidgetHostView()) { #if defined(OS_MACOSX) - preview_contents_->tab_contents()->GetRenderWidgetHostView()-> + preview_contents_->web_contents()->GetRenderWidgetHostView()-> SetTakesFocusOnlyOnMouseDown(false); registrar_.Remove( this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, content::Source<NavigationController>( - &preview_contents_->tab_contents()->GetController())); + &preview_contents_->web_contents()->GetController())); #endif } - preview_contents_->tab_contents()->SetDelegate(NULL); + preview_contents_->web_contents()->SetDelegate(NULL); ready_ = false; } update_bounds_timer_.Stop(); @@ -816,7 +817,7 @@ void InstantLoader::MaybeLoadInstantURL(TabContentsWrapper* tab_contents, bool InstantLoader::IsNavigationPending() const { return preview_contents_.get() && - preview_contents_->tab_contents()->GetController().GetPendingEntry(); + preview_contents_->web_contents()->GetController().GetPendingEntry(); } void InstantLoader::Observe(int type, @@ -824,8 +825,8 @@ void InstantLoader::Observe(int type, const content::NotificationDetails& details) { #if defined(OS_MACOSX) if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { - if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) { - preview_contents_->tab_contents()->GetRenderWidgetHostView()-> + if (preview_contents_->web_contents()->GetRenderWidgetHostView()) { + preview_contents_->web_contents()->GetRenderWidgetHostView()-> SetTakesFocusOnlyOnMouseDown(true); } return; @@ -972,7 +973,7 @@ void InstantLoader::SendBoundsToPage(bool force_if_waiting) { (force_if_waiting || !is_determining_if_page_supports_instant())) { last_omnibox_bounds_ = omnibox_bounds_; RenderViewHost* host = - preview_contents_->tab_contents()->GetRenderViewHost(); + preview_contents_->web_contents()->GetRenderViewHost(); host->Send(new ChromeViewMsg_SearchBoxResize( host->routing_id(), GetOmniboxBoundsInTermsOfPreview())); } @@ -992,20 +993,20 @@ void InstantLoader::ReplacePreviewContents(TabContentsWrapper* old_tc, // Cleanup the old preview contents. old_tc->constrained_window_tab_helper()->set_delegate(NULL); old_tc->core_tab_helper()->set_delegate(NULL); - old_tc->tab_contents()->SetDelegate(NULL); + old_tc->web_contents()->SetDelegate(NULL); #if defined(OS_MACOSX) registrar_.Remove( this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, content::Source<NavigationController>( - &old_tc->tab_contents()->GetController())); + &old_tc->web_contents()->GetController())); #endif registrar_.Remove( this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>( - &old_tc->tab_contents()->GetController())); + &old_tc->web_contents()->GetController())); // We prerendered so we should be ready to show. If we're ready, swap in // immediately, otherwise show the preview as normal. @@ -1016,7 +1017,7 @@ void InstantLoader::ReplacePreviewContents(TabContentsWrapper* old_tc, } void InstantLoader::SetupPreviewContents(TabContentsWrapper* tab_contents) { - preview_contents_->tab_contents()->SetDelegate( + preview_contents_->web_contents()->SetDelegate( preview_tab_contents_delegate_.get()); preview_contents_->blocked_content_tab_helper()->SetAllContentsBlocked(true); preview_contents_->constrained_window_tab_helper()->set_delegate( @@ -1027,9 +1028,9 @@ void InstantLoader::SetupPreviewContents(TabContentsWrapper* tab_contents) { // Propagate the max page id. That way if we end up merging the two // NavigationControllers (which happens if we commit) none of the page ids // will overlap. - int32 max_page_id = tab_contents->tab_contents()->GetMaxPageID(); + int32 max_page_id = tab_contents->web_contents()->GetMaxPageID(); if (max_page_id != -1) { - preview_contents_->tab_contents()->GetController().SetMaxRestoredPageID( + preview_contents_->web_contents()->GetController().SetMaxRestoredPageID( max_page_id + 1); } @@ -1037,26 +1038,26 @@ void InstantLoader::SetupPreviewContents(TabContentsWrapper* tab_contents) { // If |preview_contents_| does not currently have a RWHV, we will call // SetTakesFocusOnlyOnMouseDown() as a result of the // RENDER_VIEW_HOST_CHANGED notification. - if (preview_contents_->tab_contents()->GetRenderWidgetHostView()) { - preview_contents_->tab_contents()->GetRenderWidgetHostView()-> + if (preview_contents_->web_contents()->GetRenderWidgetHostView()) { + preview_contents_->web_contents()->GetRenderWidgetHostView()-> SetTakesFocusOnlyOnMouseDown(true); } registrar_.Add( this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, content::Source<NavigationController>( - &preview_contents_->tab_contents()->GetController())); + &preview_contents_->web_contents()->GetController())); #endif registrar_.Add( this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>( - &preview_contents_->tab_contents()->GetController())); + &preview_contents_->web_contents()->GetController())); gfx::Rect tab_bounds; - tab_contents->tab_contents()->GetView()->GetContainerBounds(&tab_bounds); - preview_contents_->tab_contents()->GetView()->SizeContents(tab_bounds.size()); + tab_contents->web_contents()->GetView()->GetContainerBounds(&tab_bounds); + preview_contents_->web_contents()->GetView()->SizeContents(tab_bounds.size()); } void InstantLoader::CreatePreviewContents(TabContentsWrapper* tab_contents) { @@ -1068,7 +1069,7 @@ void InstantLoader::CreatePreviewContents(TabContentsWrapper* tab_contents) { preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); SetupPreviewContents(tab_contents); - preview_contents_->tab_contents()->ShowContents(); + preview_contents_->web_contents()->ShowContents(); } void InstantLoader::LoadInstantURL(TabContentsWrapper* tab_contents, @@ -1091,10 +1092,10 @@ void InstantLoader::LoadInstantURL(TabContentsWrapper* tab_contents, CommandLine* cl = CommandLine::ForCurrentProcess(); if (cl->HasSwitch(switches::kInstantURL)) instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); - preview_contents_->tab_contents()->GetController().LoadURL( + preview_contents_->web_contents()->GetController().LoadURL( instant_url, content::Referrer(), transition_type, std::string()); - RenderViewHost* host = preview_contents_->tab_contents()->GetRenderViewHost(); - preview_contents_->tab_contents()->HideContents(); + RenderViewHost* host = preview_contents_->web_contents()->GetRenderViewHost(); + preview_contents_->web_contents()->HideContents(); // 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 @@ -1111,5 +1112,5 @@ void InstantLoader::LoadInstantURL(TabContentsWrapper* tab_contents, } frame_load_observer_.reset(new FrameLoadObserver( - this, preview_contents()->tab_contents(), user_text, verbatim)); + this, preview_contents()->web_contents(), user_text, verbatim)); } diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc index 049b214..8ca50a2 100644 --- a/chrome/browser/prerender/prerender_contents.cc +++ b/chrome/browser/prerender/prerender_contents.cc @@ -327,7 +327,7 @@ void PrerenderContents::StartPrerendering( // Register to inform new RenderViews that we're prerendering. notification_registrar_.Add( this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, - content::Source<TabContents>(new_contents)); + content::Source<WebContents>(new_contents)); // Register for redirect notifications sourced from |this|. notification_registrar_.Add( @@ -440,8 +440,8 @@ void PrerenderContents::Observe(int type, case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { if (prerender_contents_.get()) { - DCHECK_EQ(content::Source<TabContents>(source).ptr(), - prerender_contents_->tab_contents()); + DCHECK_EQ(content::Source<WebContents>(source).ptr(), + prerender_contents_->web_contents()); content::Details<RenderViewHost> new_render_view_host(details); OnRenderViewHostCreated(new_render_view_host.ptr()); diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc index 5a8cfc9..a95f42d 100644 --- a/chrome/browser/printing/print_preview_tab_controller.cc +++ b/chrome/browser/printing/print_preview_tab_controller.cc @@ -29,12 +29,15 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/tab_contents/tab_contents.h" +#include "content/browser/renderer_host/render_view_host_delegate.h" +#include "content/browser/tab_contents/navigation_controller.h" +#include "content/public/browser/web_contents.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/render_process_host.h" #include "webkit/plugins/webplugininfo.h" using content::WebContents; @@ -45,8 +48,8 @@ namespace { void EnableInternalPDFPluginForTab(TabContentsWrapper* preview_tab) { // Always enable the internal PDF plugin for the print preview page. ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( - preview_tab->tab_contents()->GetRenderProcessHost()->GetID(), - preview_tab->tab_contents()->GetRenderViewHost()->routing_id(), + preview_tab->web_contents()->GetRenderProcessHost()->GetID(), + preview_tab->web_contents()->GetRenderViewHost()->routing_id(), GURL(), ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); } @@ -79,7 +82,7 @@ PrintPreviewTabDelegate::PrintPreviewTabDelegate( const gfx::Size kMinDialogSize(800, 480); const int kBorder = 50; gfx::Rect rect; - initiator_tab->tab_contents()->GetContainerBounds(&rect); + initiator_tab->web_contents()->GetContainerBounds(&rect); size_.set_width(std::max(rect.width(), kMinDialogSize.width()) - kBorder); size_.set_height(std::max(rect.height(), kMinDialogSize.height()) - kBorder); @@ -160,7 +163,7 @@ PrintPreviewTabController* PrintPreviewTabController::GetInstance() { // static void PrintPreviewTabController::PrintPreview(TabContentsWrapper* tab) { - if (tab->tab_contents()->ShowingInterstitialPage()) + if (tab->web_contents()->ShowingInterstitialPage()) return; PrintPreviewTabController* tab_controller = GetInstance(); @@ -179,8 +182,7 @@ TabContentsWrapper* PrintPreviewTabController::GetOrCreatePreviewTab( return CreatePrintPreviewTab(initiator_tab); // Show the initiator tab holding the existing preview tab. - static_cast<RenderViewHostDelegate*>( - initiator_tab->tab_contents())->Activate(); + initiator_tab->web_contents()->GetRenderViewHost()->delegate()->Activate(); return preview_tab; } @@ -224,7 +226,7 @@ void PrintPreviewTabController::Observe( content::Source<NavigationController>(source).ptr(); TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents( - controller->tab_contents()); + controller->GetWebContents()); content::LoadCommittedDetails* load_details = content::Details<content::LoadCommittedDetails>(details).ptr(); OnNavEntryCommitted(wrapper, load_details); @@ -247,10 +249,10 @@ void PrintPreviewTabController::OnRendererProcessClosed( iter != preview_tab_map_.end(); ++iter) { TabContentsWrapper* preview_tab = iter->first; TabContentsWrapper* initiator_tab = iter->second; - if (preview_tab->tab_contents()->GetRenderProcessHost() == rph) { + if (preview_tab->web_contents()->GetRenderProcessHost() == rph) { closed_preview_tabs.push_back(preview_tab); } else if (initiator_tab && - initiator_tab->tab_contents()->GetRenderProcessHost() == rph) { + initiator_tab->web_contents()->GetRenderProcessHost() == rph) { closed_initiator_tabs.push_back(initiator_tab); } } @@ -259,7 +261,7 @@ void PrintPreviewTabController::OnRendererProcessClosed( RemovePreviewTab(closed_preview_tabs[i]); PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( - closed_preview_tabs[i]->tab_contents()->GetWebUI()); + closed_preview_tabs[i]->web_contents()->GetWebUI()); if (print_preview_ui) print_preview_ui->OnPrintPreviewTabClosed(); } @@ -306,7 +308,7 @@ void PrintPreviewTabController::OnNavEntryCommitted( SetInitiatorTabURLAndTitle(preview_tab); // Disabling the delegate will prevent all future navigation. - tab->tab_contents()->SetDelegate(NULL); + tab->web_contents()->SetDelegate(NULL); return; } @@ -328,7 +330,7 @@ void PrintPreviewTabController::OnNavEntryCommitted( // static bool PrintPreviewTabController::IsPrintPreviewTab(TabContentsWrapper* tab) { - return IsPrintPreviewURL(tab->tab_contents()->GetURL()); + return IsPrintPreviewURL(tab->web_contents()->GetURL()); } // static @@ -367,7 +369,7 @@ TabContentsWrapper* PrintPreviewTabController::CreatePrintPreviewTab( if (!current_browser) { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame)) { Profile* profile = Profile::FromBrowserContext( - initiator_tab->tab_contents()->GetBrowserContext()); + initiator_tab->web_contents()->GetBrowserContext()); current_browser = Browser::CreateForType(Browser::TYPE_POPUP, profile); if (!current_browser) { NOTREACHED() << "Failed to create popup browser window"; @@ -399,17 +401,17 @@ TabContentsWrapper* PrintPreviewTabController::CreatePrintPreviewTab( void PrintPreviewTabController::SetInitiatorTabURLAndTitle( TabContentsWrapper* preview_tab) { TabContentsWrapper* initiator_tab = GetInitiatorTab(preview_tab); - if (initiator_tab && preview_tab->tab_contents()->GetWebUI()) { + if (initiator_tab && preview_tab->web_contents()->GetWebUI()) { PrintPreviewUI* print_preview_ui = - static_cast<PrintPreviewUI*>(preview_tab->tab_contents()->GetWebUI()); + static_cast<PrintPreviewUI*>(preview_tab->web_contents()->GetWebUI()); print_preview_ui->SetInitiatorTabURLAndTitle( - initiator_tab->tab_contents()->GetURL().spec(), + initiator_tab->web_contents()->GetURL().spec(), initiator_tab->print_view_manager()->RenderSourceName()); } } void PrintPreviewTabController::AddObservers(TabContentsWrapper* tab) { - TabContents* contents = tab->tab_contents(); + WebContents* contents = tab->web_contents(); registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::Source<WebContents>(contents)); registrar_.Add( @@ -418,7 +420,7 @@ void PrintPreviewTabController::AddObservers(TabContentsWrapper* tab) { // Multiple sites may share the same RenderProcessHost, so check if this // notification has already been added. - content::RenderProcessHost* rph = tab->tab_contents()->GetRenderProcessHost(); + content::RenderProcessHost* rph = tab->web_contents()->GetRenderProcessHost(); if (!registrar_.IsRegistered(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, content::Source<content::RenderProcessHost>( @@ -429,7 +431,7 @@ void PrintPreviewTabController::AddObservers(TabContentsWrapper* tab) { } void PrintPreviewTabController::RemoveObservers(TabContentsWrapper* tab) { - TabContents* contents = tab->tab_contents(); + WebContents* contents = tab->web_contents(); registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::Source<WebContents>(contents)); registrar_.Remove( @@ -438,7 +440,7 @@ void PrintPreviewTabController::RemoveObservers(TabContentsWrapper* tab) { // Multiple sites may share the same RenderProcessHost, so check if this // notification has already been added. - content::RenderProcessHost* rph = tab->tab_contents()->GetRenderProcessHost(); + content::RenderProcessHost* rph = tab->web_contents()->GetRenderProcessHost(); if (registrar_.IsRegistered(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, content::Source<content::RenderProcessHost>( @@ -465,7 +467,7 @@ void PrintPreviewTabController::RemoveInitiatorTab( // Initiator tab is closed. Close the print preview tab too. PrintPreviewUI* print_preview_ui = - static_cast<PrintPreviewUI*>(preview_tab->tab_contents()->GetWebUI()); + static_cast<PrintPreviewUI*>(preview_tab->web_contents()->GetWebUI()); if (print_preview_ui) print_preview_ui->OnInitiatorTabClosed(); } @@ -482,7 +484,7 @@ void PrintPreviewTabController::RemovePreviewTab( // Print preview TabContents is destroyed. Notify |PrintPreviewUI| to abort // the initiator tab preview request. PrintPreviewUI* print_preview_ui = - static_cast<PrintPreviewUI*>(preview_tab->tab_contents()->GetWebUI()); + static_cast<PrintPreviewUI*>(preview_tab->web_contents()->GetWebUI()); if (print_preview_ui) print_preview_ui->OnTabDestroyed(); diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc index ff2cf92..f69647e 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc @@ -318,7 +318,7 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest, TabContents* contents = browser()->GetSelectedTabContents(); ui_test_utils::WindowedNotificationObserver interstitial_observer( content::NOTIFICATION_INTERSTITIAL_ATTACHED, - content::Source<TabContents>(contents)); + content::Source<WebContents>(contents)); if (!InterstitialPage::GetInterstitialPage(contents)) interstitial_observer.Wait(); } diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index 7883184..65af702 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -209,7 +209,7 @@ void TabLoader::LoadNextTab() { tabs_loading_.insert(tab); tabs_to_load_.pop_front(); tab->LoadIfNecessary(); - if (tab->tab_contents()) { + if (tab->GetWebContents()) { int tab_index; Browser* browser = Browser::GetBrowserForController(tab, &tab_index); if (browser && browser->active_index() != tab_index) { @@ -220,7 +220,7 @@ void TabLoader::LoadNextTab() { // NOTE: We need to do this here rather than when the tab is added to // the Browser as at that time not everything has been created, so that // the call would do nothing. - tab->tab_contents()->WasHidden(); + tab->GetWebContents()->WasHidden(); } } } @@ -329,7 +329,7 @@ void TabLoader::OnOnlineStateChanged(bool online) { void TabLoader::RemoveTab(NavigationController* tab) { registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, - content::Source<WebContents>(tab->tab_contents())); + content::Source<WebContents>(tab->GetWebContents())); registrar_.Remove(this, content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>(tab)); registrar_.Remove(this, content::NOTIFICATION_LOAD_START, @@ -351,10 +351,10 @@ void TabLoader::ForceLoadTimerFired() { } RenderWidgetHost* TabLoader::GetRenderWidgetHost(NavigationController* tab) { - TabContents* tab_contents = tab->tab_contents(); - if (tab_contents) { + WebContents* web_contents = tab->GetWebContents(); + if (web_contents) { RenderWidgetHostView* render_widget_host_view = - tab_contents->GetRenderWidgetHostView(); + web_contents->GetRenderWidgetHostView(); if (render_widget_host_view) return render_widget_host_view->GetRenderWidgetHost(); } @@ -363,7 +363,7 @@ RenderWidgetHost* TabLoader::GetRenderWidgetHost(NavigationController* tab) { void TabLoader::RegisterForNotifications(NavigationController* controller) { registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, - content::Source<WebContents>(controller->tab_contents())); + content::Source<WebContents>(controller->GetWebContents())); registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>(controller)); registrar_.Add(this, content::NOTIFICATION_LOAD_START, diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc index e7e28c9..5325ee3 100644 --- a/chrome/browser/sessions/session_service.cc +++ b/chrome/browser/sessions/session_service.cc @@ -534,7 +534,7 @@ void SessionService::Observe(int type, TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( content::Source<NavigationController>( - source).ptr()->tab_contents()); + source).ptr()->GetWebContents()); if (!tab || tab->profile() != profile()) return; TabClosed(tab->restore_tab_helper()->window_id(), @@ -549,7 +549,7 @@ void SessionService::Observe(int type, TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( content::Source<NavigationController>( - source).ptr()->tab_contents()); + source).ptr()->GetWebContents()); if (!tab || tab->profile() != profile()) return; content::Details<content::PrunedDetails> pruned_details(details); @@ -573,7 +573,7 @@ void SessionService::Observe(int type, TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( content::Source<NavigationController>( - source).ptr()->tab_contents()); + source).ptr()->GetWebContents()); if (!tab || tab->profile() != profile()) return; content::Details<content::EntryChangedDetails> changed(details); @@ -588,7 +588,7 @@ void SessionService::Observe(int type, TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( content::Source<NavigationController>( - source).ptr()->tab_contents()); + source).ptr()->GetWebContents()); if (!tab || tab->profile() != profile()) return; int current_entry_index = diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc index f4c651b..78c2ecd 100644 --- a/chrome/browser/sessions/tab_restore_service.cc +++ b/chrome/browser/sessions/tab_restore_service.cc @@ -504,7 +504,7 @@ void TabRestoreService::PopulateTab(Tab* tab, TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents( - controller->tab_contents()); + controller->GetWebContents()); // wrapper is NULL in some browser tests. if (wrapper) { const Extension* extension = diff --git a/chrome/browser/sync/glue/session_change_processor.cc b/chrome/browser/sync/glue/session_change_processor.cc index a80a1a9..a0e2f63 100644 --- a/chrome/browser/sync/glue/session_change_processor.cc +++ b/chrome/browser/sync/glue/session_change_processor.cc @@ -21,12 +21,13 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" +#include "content/public/browser/web_contents.h" using content::BrowserThread; +using content::WebContents; namespace browser_sync { @@ -37,7 +38,7 @@ namespace { SyncedTabDelegate* ExtractSyncedTabDelegate( const content::NotificationSource& source) { TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( - content::Source<NavigationController>(source).ptr()->tab_contents()); + content::Source<NavigationController>(source).ptr()->GetWebContents()); if (!tab) return NULL; return tab->synced_tab_delegate(); @@ -107,7 +108,7 @@ void SessionChangeProcessor::Observe( case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { TabContentsWrapper* tab_contents_wrapper = TabContentsWrapper::GetCurrentWrapperForContents( - content::Source<TabContents>(source).ptr()); + content::Source<WebContents>(source).ptr()); if (!tab_contents_wrapper) { return; } diff --git a/chrome/browser/tab_contents/tab_util.h b/chrome/browser/tab_contents/tab_util.h index 9e37c97..63bcbfa 100644 --- a/chrome/browser/tab_contents/tab_util.h +++ b/chrome/browser/tab_contents/tab_util.h @@ -20,6 +20,7 @@ namespace tab_util { // Helper to find the TabContents that originated the given request. Can be // NULL if the tab has been closed or some other error occurs. // Should only be called from the UI thread, since it accesses TabContent. +// TODO(jam): remove TabContents version TabContents* GetTabContentsByID(int render_process_id, int render_view_id); content::WebContents* GetWebContentsByID(int render_process_id, int render_view_id); diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc index 1cbdf18..7e651be 100644 --- a/chrome/browser/tab_contents/thumbnail_generator.cc +++ b/chrome/browser/tab_contents/thumbnail_generator.cc @@ -17,10 +17,11 @@ #include "chrome/common/thumbnail_score.h" #include "content/browser/renderer_host/backing_store.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/web_contents.h" #include "googleurl/src/gurl.h" #include "skia/ext/image_operations.h" #include "skia/ext/platform_canvas.h" @@ -146,8 +147,8 @@ ThumbnailGenerator::ThumbnailGenerator() ThumbnailGenerator::~ThumbnailGenerator() { } -void ThumbnailGenerator::StartThumbnailing(TabContents* tab_contents) { - content::WebContentsObserver::Observe(tab_contents); +void ThumbnailGenerator::StartThumbnailing(WebContents* web_contents) { + content::WebContentsObserver::Observe(web_contents); if (registrar_.IsEmpty()) { // Even though we deal in RenderWidgetHosts, we only care about its @@ -155,9 +156,9 @@ void ThumbnailGenerator::StartThumbnailing(TabContents* tab_contents) { // for RenderViewHosts that aren't in tabs, or RenderWidgetHosts that // aren't views like select popups. registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, - content::Source<TabContents>(tab_contents)); - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, - content::Source<TabContents>(tab_contents)); + content::Source<WebContents>(web_contents)); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, + content::Source<WebContents>(web_contents)); } } @@ -352,8 +353,8 @@ void ThumbnailGenerator::Observe(int type, break; } - case content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED: - TabContentsDisconnected(content::Source<TabContents>(source).ptr()); + case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: + WebContentsDisconnected(content::Source<WebContents>(source).ptr()); break; default: @@ -370,7 +371,7 @@ void ThumbnailGenerator::WidgetHidden(RenderWidgetHost* widget) { UpdateThumbnailIfNecessary(web_contents()); } -void ThumbnailGenerator::TabContentsDisconnected(TabContents* contents) { +void ThumbnailGenerator::WebContentsDisconnected(WebContents* contents) { // Go through the existing callbacks, and find any that have the // same renderer as this TabContents and remove them so they don't // hang around. diff --git a/chrome/browser/tab_contents/thumbnail_generator.h b/chrome/browser/tab_contents/thumbnail_generator.h index 7140357..c805a9b 100644 --- a/chrome/browser/tab_contents/thumbnail_generator.h +++ b/chrome/browser/tab_contents/thumbnail_generator.h @@ -58,7 +58,7 @@ class ThumbnailGenerator : public content::NotificationObserver, virtual ~ThumbnailGenerator(); // Starts taking thumbnails of the given tab contents. - void StartThumbnailing(TabContents* tab_contents); + void StartThumbnailing(content::WebContents* web_contents); // This registers a callback that can receive the resulting SkBitmap // from the renderer when it is done rendering it. This differs @@ -140,9 +140,9 @@ class ThumbnailGenerator : public content::NotificationObserver, // Indicates that the given widget has changed is visibility. void WidgetHidden(RenderWidgetHost* widget); - // Called when the given tab contents are disconnected (either + // Called when the given web contents are disconnected (either // through being closed, or because the renderer is no longer there). - void TabContentsDisconnected(TabContents* contents); + void WebContentsDisconnected(content::WebContents* contents); content::NotificationRegistrar registrar_; diff --git a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc index 456930a..9c23f25 100644 --- a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc +++ b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc @@ -22,6 +22,8 @@ #include "ui/gfx/canvas_skia.h" #include "ui/gfx/surface/transport_dib.h" +using content::WebContents; + static const int kBitmapWidth = 100; static const int kBitmapHeight = 100; @@ -70,7 +72,7 @@ class ThumbnailGeneratorTest : public testing::Test { // will want a RenderWidget, so it works out OK. content::NotificationService::current()->Notify( content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, - content::Source<RenderViewHostManager>(NULL), + content::Source<WebContents>(NULL), content::Details<RenderViewHost>(reinterpret_cast<RenderViewHost*>( widget_.get()))); diff --git a/chrome/browser/tab_contents/web_drag_source_win.cc b/chrome/browser/tab_contents/web_drag_source_win.cc index 21dd68f..5140096 100644 --- a/chrome/browser/tab_contents/web_drag_source_win.cc +++ b/chrome/browser/tab_contents/web_drag_source_win.cc @@ -12,8 +12,9 @@ #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" -using content::BrowserThread; using WebKit::WebDragOperationNone; +using content::BrowserThread; +using content::WebContents; namespace { @@ -39,8 +40,8 @@ WebDragSource::WebDragSource(gfx::NativeWindow source_wnd, effect_(DROPEFFECT_NONE) { registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_SWAPPED, content::Source<TabContents>(tab_contents)); - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, - content::Source<TabContents>(tab_contents)); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, + content::Source<WebContents>(tab_contents)); } WebDragSource::~WebDragSource() { @@ -116,7 +117,7 @@ void WebDragSource::Observe(int type, // That's OK, we can continue the drag, we just can't send messages back to // our drag source. render_view_host_ = NULL; - } else if (content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED == type) { + } else if (content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED == type) { // This could be possible when we close the tab and the source is still // being used in DoDragDrop at the time that the virtual file is being // downloaded. diff --git a/chrome/browser/tab_first_render_watcher.cc b/chrome/browser/tab_first_render_watcher.cc index 3d0d53d..69de9cf 100644 --- a/chrome/browser/tab_first_render_watcher.cc +++ b/chrome/browser/tab_first_render_watcher.cc @@ -9,18 +9,21 @@ #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/web_contents.h" -TabFirstRenderWatcher::TabFirstRenderWatcher(TabContents* tab, +using content::WebContents; + +TabFirstRenderWatcher::TabFirstRenderWatcher(WebContents* tab, Delegate* delegate) : state_(NONE), - tab_contents_(tab), + web_contents_(tab), delegate_(delegate) { registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, - content::Source<TabContents>(tab_contents_)); + content::Source<WebContents>(web_contents_)); registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, - content::Source<TabContents>(tab_contents_)); + content::Source<WebContents>(web_contents_)); } void TabFirstRenderWatcher::Observe(int type, diff --git a/chrome/browser/tab_first_render_watcher.h b/chrome/browser/tab_first_render_watcher.h index d09f3b8..f73c4fb 100644 --- a/chrome/browser/tab_first_render_watcher.h +++ b/chrome/browser/tab_first_render_watcher.h @@ -11,7 +11,10 @@ #include "content/public/browser/notification_registrar.h" class RenderViewHost; -class TabContents; + +namespace content { +class WebContents; +} // This class watches given TabContent's loading and rendering state change. class TabFirstRenderWatcher : public content::NotificationObserver { @@ -23,7 +26,7 @@ class TabFirstRenderWatcher : public content::NotificationObserver { virtual void OnTabMainFrameFirstRender() = 0; }; - TabFirstRenderWatcher(TabContents* tab, Delegate* delegate); + TabFirstRenderWatcher(content::WebContents* tab, Delegate* delegate); private: // Overridden from content::NotificationObserver @@ -38,8 +41,8 @@ class TabFirstRenderWatcher : public content::NotificationObserver { }; State state_; - // TabContents that this class watches. - TabContents* tab_contents_; + // WebContents that this class watches. + content::WebContents* web_contents_; // Delegate to notify. Delegate* delegate_; diff --git a/chrome/browser/tab_first_render_watcher_browsertest.cc b/chrome/browser/tab_first_render_watcher_browsertest.cc index 1c81a5f..9172500 100644 --- a/chrome/browser/tab_first_render_watcher_browsertest.cc +++ b/chrome/browser/tab_first_render_watcher_browsertest.cc @@ -66,7 +66,7 @@ IN_PROC_BROWSER_TEST_F(TabFirstRenderWatcherTest, dom_view->GetWidget()->Show(); scoped_ptr<TabFirstRenderWatcher> watcher( - new TabFirstRenderWatcher(dom_view->dom_contents()->tab_contents(), + new TabFirstRenderWatcher(dom_view->dom_contents()->web_contents(), this)); EXPECT_FALSE(host_created_); diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc index 1c54df5..0a18d2a 100644 --- a/chrome/browser/task_manager/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager/task_manager_resource_providers.cc @@ -390,7 +390,7 @@ void TaskManagerTabContentsResourceProvider::StartUpdating() { content::NotificationService::AllBrowserContextsAndSources()); registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_SWAPPED, content::NotificationService::AllBrowserContextsAndSources()); - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, content::NotificationService::AllBrowserContextsAndSources()); // TAB_CONTENTS_DISCONNECTED should be enough to know when to remove a // resource. This is an attempt at mitigating a crasher that seem to @@ -414,7 +414,7 @@ void TaskManagerTabContentsResourceProvider::StopUpdating() { this, content::NOTIFICATION_TAB_CONTENTS_SWAPPED, content::NotificationService::AllBrowserContextsAndSources()); registrar_.Remove( - this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, + this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, content::NotificationService::AllBrowserContextsAndSources()); registrar_.Remove( this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, @@ -525,7 +525,7 @@ void TaskManagerTabContentsResourceProvider::Observe(int type, resources_.end()) << "TAB_CONTENTS_DESTROYED with no associated " "TAB_CONTENTS_DISCONNECTED"; // Fall through. - case content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED: + case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: Remove(tab_contents); break; case chrome::NOTIFICATION_INSTANT_COMMITTED: diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index dcb2324..ef5e257 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -35,13 +35,15 @@ #include "chrome/common/translate_errors.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/tab_contents/tab_contents.h" +#include "content/browser/tab_contents/navigation_controller.h" +#include "content/public/browser/web_contents.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/render_process_host.h" #include "content/public/common/url_fetcher.h" #include "grit/browser_resources.h" #include "net/base/escape.h" @@ -271,7 +273,7 @@ void TranslateManager::Observe(int type, TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents( - controller->tab_contents()); + controller->GetWebContents()); if (!wrapper || !wrapper->translate_tab_helper()) return; @@ -297,8 +299,8 @@ void TranslateManager::Observe(int type, base::Bind( &TranslateManager::InitiateTranslationPosted, weak_method_factory_.GetWeakPtr(), - controller->tab_contents()->GetRenderProcessHost()->GetID(), - controller->tab_contents()->GetRenderViewHost()->routing_id(), + controller->GetWebContents()->GetRenderProcessHost()->GetID(), + controller->GetWebContents()->GetRenderViewHost()->routing_id(), helper->language_state().original_language())); break; } @@ -397,7 +399,7 @@ void TranslateManager::OnURLFetchComplete(const content::URLFetcher* source) { for (iter = pending_requests_.begin(); iter != pending_requests_.end(); ++iter) { const PendingRequest& request = *iter; - TabContents* tab = tab_util::GetTabContentsByID(request.render_process_id, + WebContents* tab = tab_util::GetWebContentsByID(request.render_process_id, request.render_view_id); if (!tab) { // The tab went away while we were retrieving the script. @@ -539,7 +541,7 @@ void TranslateManager::InitiateTranslation(WebContents* tab, void TranslateManager::InitiateTranslationPosted( int process_id, int render_id, const std::string& page_lang) { // The tab might have been closed. - TabContents* tab = tab_util::GetTabContentsByID(process_id, render_id); + WebContents* tab = tab_util::GetWebContentsByID(process_id, render_id); if (!tab) return; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index b114f7f..b5757be 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -3106,7 +3106,7 @@ TabContentsWrapper* Browser::CreateTabContentsForURL( bool Browser::CanDuplicateContentsAt(int index) { NavigationController& nc = GetTabContentsAt(index)->GetController(); - return nc.tab_contents() && nc.GetLastCommittedEntry(); + return nc.GetWebContents() && nc.GetLastCommittedEntry(); } void Browser::DuplicateContentsAt(int index) { @@ -3259,14 +3259,14 @@ void Browser::TabInsertedAt(TabContentsWrapper* contents, // If the tab crashes in the beforeunload or unload handler, it won't be // able to ack. But we know we can close it. - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, - content::Source<TabContents>(contents->tab_contents())); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, + content::Source<WebContents>(contents->web_contents())); registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED, - content::Source<TabContents>(contents->tab_contents())); + content::Source<WebContents>(contents->web_contents())); registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_DETACHED, - content::Source<TabContents>(contents->tab_contents())); + content::Source<WebContents>(contents->web_contents())); } void Browser::TabClosingAt(TabStripModel* tab_strip_model, @@ -4093,12 +4093,12 @@ void Browser::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { switch (type) { - case content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED: + case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: if (is_attempting_to_close_browser_) { // Pass in false so that we delay processing. We need to delay the // processing as it may close the tab, which is currently on the call // stack above us. - ClearUnloadState(content::Source<TabContents>(source).ptr(), false); + ClearUnloadState(content::Source<WebContents>(source).ptr(), false); } break; @@ -5120,11 +5120,11 @@ void Browser::TabDetachedAtImpl(TabContentsWrapper* contents, int index, } registrar_.Remove(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED, - content::Source<TabContents>(contents->tab_contents())); + content::Source<WebContents>(contents->web_contents())); registrar_.Remove(this, content::NOTIFICATION_INTERSTITIAL_DETACHED, - content::Source<TabContents>(contents->tab_contents())); - registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, - content::Source<TabContents>(contents->tab_contents())); + content::Source<WebContents>(contents->tab_contents())); + registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, + content::Source<WebContents>(contents->web_contents())); } // static diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index bc3c0a4..99fbfa5 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -1356,7 +1356,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { ui_test_utils::WindowedNotificationObserver interstitial_observer( content::NOTIFICATION_INTERSTITIAL_ATTACHED, - content::Source<TabContents>(contents)); + content::Source<WebContents>(contents)); interstitial->Show(); interstitial_observer.Wait(); @@ -1369,7 +1369,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { ui_test_utils::WindowedNotificationObserver interstitial_detach_observer( content::NOTIFICATION_INTERSTITIAL_DETACHED, - content::Source<TabContents>(contents)); + content::Source<WebContents>(contents)); interstitial->Proceed(); interstitial_detach_observer.Wait(); // interstitial is deleted now. diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.cc b/chrome/browser/ui/toolbar/back_forward_menu_model.cc index 1a06fa2..a86b97e 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.cc @@ -13,13 +13,14 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/favicon_status.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/user_metrics.h" +#include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" @@ -31,6 +32,7 @@ using content::NavigationEntry; using content::UserMetricsAction; +using content::WebContents; const int BackForwardMenuModel::kMaxHistoryItems = 12; const int BackForwardMenuModel::kMaxChapterStops = 5; @@ -39,7 +41,7 @@ static const int kMaxWidth = 700; BackForwardMenuModel::BackForwardMenuModel(Browser* browser, ModelType model_type) : browser_(browser), - test_tab_contents_(NULL), + test_web_contents_(NULL), model_type_(model_type), menu_model_delegate_(NULL) { } @@ -93,7 +95,7 @@ string16 BackForwardMenuModel::GetLabelAt(int index) const { // super long. NavigationEntry* entry = GetNavigationEntry(index); Profile* profile = - Profile::FromBrowserContext(GetTabContents()->GetBrowserContext()); + Profile::FromBrowserContext(GetWebContents()->GetBrowserContext()); string16 menu_text(entry->GetTitleForDisplay( profile->GetPrefs()->GetString(prefs::kAcceptLanguages))); menu_text = @@ -286,7 +288,7 @@ void BackForwardMenuModel::OnFavIconDataAvailable( } int BackForwardMenuModel::GetHistoryItemCount() const { - TabContents* contents = GetTabContents(); + WebContents* contents = GetWebContents(); int items = 0; if (model_type_ == FORWARD_MENU) { @@ -306,7 +308,7 @@ int BackForwardMenuModel::GetHistoryItemCount() const { } int BackForwardMenuModel::GetChapterStopCount(int history_items) const { - TabContents* contents = GetTabContents(); + WebContents* contents = GetWebContents(); int chapter_stops = 0; int current_entry = contents->GetController().GetCurrentEntryIndex(); @@ -332,7 +334,7 @@ int BackForwardMenuModel::GetChapterStopCount(int history_items) const { int BackForwardMenuModel::GetIndexOfNextChapterStop(int start_from, bool forward) const { - TabContents* contents = GetTabContents(); + WebContents* contents = GetWebContents(); NavigationController& controller = contents->GetController(); int max_count = controller.GetEntryCount(); @@ -384,7 +386,7 @@ int BackForwardMenuModel::FindChapterStop(int offset, if (!forward) offset *= -1; - TabContents* contents = GetTabContents(); + WebContents* contents = GetWebContents(); int entry = contents->GetController().GetCurrentEntryIndex() + offset; for (int i = 0; i < skip + 1; i++) entry = GetIndexOfNextChapterStop(entry, forward); @@ -404,14 +406,15 @@ string16 BackForwardMenuModel::GetShowFullHistoryLabel() const { return l10n_util::GetStringUTF16(IDS_SHOWFULLHISTORY_LINK); } -TabContents* BackForwardMenuModel::GetTabContents() const { - // We use the test tab contents if the unit test has specified it. - return test_tab_contents_ ? test_tab_contents_ : - browser_->GetSelectedTabContents(); +WebContents* BackForwardMenuModel::GetWebContents() const { + // We use the test web contents if the unit test has specified it. + return test_web_contents_ ? + test_web_contents_ : + browser_->GetSelectedTabContentsWrapper()->web_contents(); } int BackForwardMenuModel::MenuIndexToNavEntryIndex(int index) const { - TabContents* contents = GetTabContents(); + WebContents* contents = GetWebContents(); int history_items = GetHistoryItemCount(); DCHECK_GE(index, 0); @@ -442,7 +445,7 @@ int BackForwardMenuModel::MenuIndexToNavEntryIndex(int index) const { NavigationEntry* BackForwardMenuModel::GetNavigationEntry(int index) const { int controller_index = MenuIndexToNavEntryIndex(index); - NavigationController& controller = GetTabContents()->GetController(); + NavigationController& controller = GetWebContents()->GetController(); if (controller_index >= 0 && controller_index < controller.GetEntryCount()) return controller.GetEntryAtIndex(controller_index); diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.h b/chrome/browser/ui/toolbar/back_forward_menu_model.h index 70d5f9e..0c8cf54 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.h +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.h @@ -18,10 +18,10 @@ class Browser; class SkBitmap; -class TabContents; namespace content { class NavigationEntry; +class WebContents; } /////////////////////////////////////////////////////////////////////////////// @@ -95,8 +95,8 @@ class BackForwardMenuModel : public ui::MenuModel { history::FaviconData favicon); // Allows the unit test to use its own dummy tab contents. - void set_test_tab_contents(TabContents* test_tab_contents) { - test_tab_contents_ = test_tab_contents; + void set_test_web_contents(content::WebContents* test_web_contents) { + test_web_contents_ = test_web_contents; } // Returns how many history items the menu should show. For example, if the @@ -168,10 +168,10 @@ class BackForwardMenuModel : public ui::MenuModel { // Looks up a NavigationEntry by menu id. content::NavigationEntry* GetNavigationEntry(int index) const; - // Retrieves the TabContents pointer to use, which is either the one that - // the unit test sets (using SetTabContentsForUnitTest) or the one from + // Retrieves the WebContents pointer to use, which is either the one that + // the unit test sets (using set_test_web_contents) or the one from // the browser window. - TabContents* GetTabContents() const; + content::WebContents* GetWebContents() const; // Build a string version of a user action on this menu, used as an // identifier for logging user behavior. @@ -181,8 +181,8 @@ class BackForwardMenuModel : public ui::MenuModel { Browser* browser_; - // The unit tests will provide their own TabContents to use. - TabContents* test_tab_contents_; + // The unit tests will provide their own WebContents to use. + content::WebContents* test_web_contents_; // Represents whether this is the delegate for the forward button or the // back button. diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc index f3ecc60..6c3efa5 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc @@ -15,9 +15,9 @@ #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/navigation_entry.h" +#include "content/public/browser/web_contents.h" #include "content/test/test_browser_thread.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -108,11 +108,11 @@ class BackFwdMenuModelTest : public ChromeRenderViewHostTestHarness { TEST_F(BackFwdMenuModelTest, BasicCase) { scoped_ptr<BackForwardMenuModel> back_model(new BackForwardMenuModel( NULL, BackForwardMenuModel::BACKWARD_MENU)); - back_model->set_test_tab_contents(contents()); + back_model->set_test_web_contents(contents()); scoped_ptr<BackForwardMenuModel> forward_model(new BackForwardMenuModel( NULL, BackForwardMenuModel::FORWARD_MENU)); - forward_model->set_test_tab_contents(contents()); + forward_model->set_test_web_contents(contents()); EXPECT_EQ(0, back_model->GetItemCount()); EXPECT_EQ(0, forward_model->GetItemCount()); @@ -176,11 +176,11 @@ TEST_F(BackFwdMenuModelTest, BasicCase) { TEST_F(BackFwdMenuModelTest, MaxItemsTest) { scoped_ptr<BackForwardMenuModel> back_model(new BackForwardMenuModel( NULL, BackForwardMenuModel::BACKWARD_MENU)); - back_model->set_test_tab_contents(contents()); + back_model->set_test_web_contents(contents()); scoped_ptr<BackForwardMenuModel> forward_model(new BackForwardMenuModel( NULL, BackForwardMenuModel::FORWARD_MENU)); - forward_model->set_test_tab_contents(contents()); + forward_model->set_test_web_contents(contents()); // Seed the controller with 32 URLs LoadURLAndUpdateState("http://www.a.com/1", "A1"); @@ -258,11 +258,11 @@ TEST_F(BackFwdMenuModelTest, MaxItemsTest) { TEST_F(BackFwdMenuModelTest, ChapterStops) { scoped_ptr<BackForwardMenuModel> back_model(new BackForwardMenuModel( NULL, BackForwardMenuModel::BACKWARD_MENU)); - back_model->set_test_tab_contents(contents()); + back_model->set_test_web_contents(contents()); scoped_ptr<BackForwardMenuModel> forward_model(new BackForwardMenuModel( NULL, BackForwardMenuModel::FORWARD_MENU)); - forward_model->set_test_tab_contents(contents()); + forward_model->set_test_web_contents(contents()); // Seed the controller with 32 URLs. int i = 0; @@ -469,7 +469,7 @@ TEST_F(BackFwdMenuModelTest, ChapterStops) { TEST_F(BackFwdMenuModelTest, EscapeLabel) { scoped_ptr<BackForwardMenuModel> back_model(new BackForwardMenuModel( NULL, BackForwardMenuModel::BACKWARD_MENU)); - back_model->set_test_tab_contents(contents()); + back_model->set_test_web_contents(contents()); EXPECT_EQ(0, back_model->GetItemCount()); EXPECT_FALSE(back_model->ItemHasCommand(1)); @@ -505,7 +505,7 @@ TEST_F(BackFwdMenuModelTest, FaviconLoadTest) { BackForwardMenuModel back_model( &browser, BackForwardMenuModel::BACKWARD_MENU); - back_model.set_test_tab_contents(controller().tab_contents()); + back_model.set_test_web_contents(controller().GetWebContents()); back_model.SetMenuModelDelegate(&favicon_delegate); SkBitmap new_icon(CreateBitmap(SK_ColorRED)); diff --git a/chrome/browser/ui/views/extensions/extension_popup.cc b/chrome/browser/ui/views/extensions/extension_popup.cc index b955dcb..1a6af81 100644 --- a/chrome/browser/ui/views/extensions/extension_popup.cc +++ b/chrome/browser/ui/views/extensions/extension_popup.cc @@ -19,6 +19,8 @@ #include "content/public/browser/notification_source.h" #include "ui/views/layout/fill_layout.h" +using content::WebContents; + // The minimum/maximum dimensions of the popup. // The minimum is just a little larger than the size of the button itself. // The maximum is an arbitrary number that should be smaller than most screens. @@ -50,7 +52,7 @@ ExtensionPopup::ExtensionPopup( // Wait to show the popup until the contained host finishes loading. registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, - content::Source<TabContents>(host->host_contents())); + content::Source<WebContents>(host->host_contents())); // Listen for the containing view calling window.close(); registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, @@ -68,7 +70,7 @@ void ExtensionPopup::Observe(int type, const content::NotificationDetails& details) { switch (type) { case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: - DCHECK(content::Source<TabContents>(host()->host_contents()) == source); + DCHECK(content::Source<WebContents>(host()->host_contents()) == source); // Show when the content finishes loading and its width is computed. Show(); // Focus on the host contents when the bubble is first shown. diff --git a/chrome/browser/user_style_sheet_watcher.cc b/chrome/browser/user_style_sheet_watcher.cc index 5b2371d..09093e6 100644 --- a/chrome/browser/user_style_sheet_watcher.cc +++ b/chrome/browser/user_style_sheet_watcher.cc @@ -9,12 +9,13 @@ #include "base/file_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_notification_types.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/web_contents.h" using ::base::files::FilePathWatcher; using content::BrowserThread; +using content::WebContents; namespace { @@ -176,7 +177,7 @@ void UserStyleSheetWatcher::Observe(int type, DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(type == content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB); if (profile_->IsSameProfile(Profile::FromBrowserContext( - content::Source<TabContents>(source)->GetBrowserContext()))) { + content::Source<WebContents>(source)->GetBrowserContext()))) { loader_->NotifyLoaded(); registrar_.RemoveAll(); } diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc index ba38fd0..df2a6b8 100644 --- a/chrome/test/base/browser_with_test_window_test.cc +++ b/chrome/test/base/browser_with_test_window_test.cc @@ -14,11 +14,13 @@ #include "chrome/common/render_messages.h" #include "chrome/test/base/testing_profile.h" #include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/tab_contents.h" +#include "content/browser/tab_contents/render_view_host_manager.h" #include "content/public/browser/navigation_entry.h" +#include "content/public/browser/web_contents.h" #include "content/public/common/page_transition_types.h" using content::BrowserThread; +using content::WebContents; BrowserWithTestWindowTest::BrowserWithTestWindowTest() : ui_thread_(BrowserThread::UI, message_loop()), @@ -57,8 +59,8 @@ BrowserWithTestWindowTest::~BrowserWithTestWindowTest() { } TestRenderViewHost* BrowserWithTestWindowTest::TestRenderViewHostForTab( - TabContents* tab_contents) { - return static_cast<TestRenderViewHost*>(tab_contents->GetRenderViewHost()); + WebContents* web_contents) { + return static_cast<TestRenderViewHost*>(web_contents->GetRenderViewHost()); } void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { @@ -66,7 +68,7 @@ void BrowserWithTestWindowTest::AddTab(Browser* browser, const GURL& url) { params.tabstrip_index = 0; params.disposition = NEW_FOREGROUND_TAB; browser::Navigate(¶ms); - CommitPendingLoad(¶ms.target_contents->tab_contents()->GetController()); + CommitPendingLoad(¶ms.target_contents->web_contents()->GetController()); } void BrowserWithTestWindowTest::CommitPendingLoad( @@ -75,10 +77,10 @@ void BrowserWithTestWindowTest::CommitPendingLoad( return; // Nothing to commit. TestRenderViewHost* old_rvh = - TestRenderViewHostForTab(controller->tab_contents()); + TestRenderViewHostForTab(controller->GetWebContents()); TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>( - controller->tab_contents()->GetRenderManagerForTesting()-> + controller->GetWebContents()->GetRenderManagerForTesting()-> pending_render_view_host()); if (pending_rvh) { // Simulate the ShouldClose_ACK that is received from the current renderer @@ -100,7 +102,7 @@ void BrowserWithTestWindowTest::CommitPendingLoad( controller->GetPendingEntry()->GetTransitionType()); } else { test_rvh->SendNavigateWithTransition( - controller->tab_contents()-> + controller->GetWebContents()-> GetMaxPageIDForSiteInstance(test_rvh->site_instance()) + 1, controller->GetPendingEntry()->GetURL(), controller->GetPendingEntry()->GetTransitionType()); @@ -121,7 +123,8 @@ void BrowserWithTestWindowTest::NavigateAndCommit( } void BrowserWithTestWindowTest::NavigateAndCommitActiveTab(const GURL& url) { - NavigateAndCommit(&browser()->GetSelectedTabContents()->GetController(), url); + NavigateAndCommit(&browser()->GetSelectedTabContentsWrapper()-> + web_contents()->GetController(), url); } void BrowserWithTestWindowTest::DestroyBrowser() { diff --git a/chrome/test/base/browser_with_test_window_test.h b/chrome/test/base/browser_with_test_window_test.h index ec8fee3..cc06bc6 100644 --- a/chrome/test/base/browser_with_test_window_test.h +++ b/chrome/test/base/browser_with_test_window_test.h @@ -18,6 +18,9 @@ #include "ui/aura/test/test_activation_client.h" #endif +class GURL; +class NavigationController; + #if defined(USE_AURA) namespace aura { namespace test { @@ -26,8 +29,9 @@ class TestActivationClient; } #endif -class GURL; -class NavigationController; +namespace content { +class WebContents; +} // Base class for browser based unit tests. BrowserWithTestWindowTest creates a // Browser with a TestingProfile and TestBrowserWindow. To add a tab use @@ -60,7 +64,8 @@ class BrowserWithTestWindowTest : public testing::Test { // Returns the current RenderViewHost for the current tab as a // TestRenderViewHost. - TestRenderViewHost* TestRenderViewHostForTab(TabContents* tab_contents); + TestRenderViewHost* TestRenderViewHostForTab( + content::WebContents* web_contents); protected: TestBrowserWindow* window() const { return window_.get(); } diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc index 29c8a15..309e7df 100644 --- a/content/browser/download/download_manager_impl.cc +++ b/content/browser/download/download_manager_impl.cc @@ -768,8 +768,7 @@ void DownloadManagerImpl::DownloadUrlToFile(const GURL& url, const GURL& referrer, const std::string& referrer_charset, const DownloadSaveInfo& save_info, - TabContents* tab_contents) { - DCHECK(tab_contents); + WebContents* web_contents) { ResourceDispatcherHost* resource_dispatcher_host = content::GetContentClient()->browser()->GetResourceDispatcherHost(); @@ -780,9 +779,9 @@ void DownloadManagerImpl::DownloadUrlToFile(const GURL& url, BrowserThread::IO, FROM_HERE, base::Bind(&BeginDownload, URLParams(url, referrer), save_info, resource_dispatcher_host, - RenderParams(tab_contents->GetRenderProcessHost()->GetID(), - tab_contents->GetRenderViewHost()->routing_id()), - &tab_contents->GetBrowserContext()->GetResourceContext())); + RenderParams(web_contents->GetRenderProcessHost()->GetID(), + web_contents->GetRenderViewHost()->routing_id()), + &web_contents->GetBrowserContext()->GetResourceContext())); } void DownloadManagerImpl::AddObserver(Observer* observer) { diff --git a/content/browser/download/download_manager_impl.h b/content/browser/download/download_manager_impl.h index 6966fa3..c45fe0a 100644 --- a/content/browser/download/download_manager_impl.h +++ b/content/browser/download/download_manager_impl.h @@ -70,7 +70,7 @@ class CONTENT_EXPORT DownloadManagerImpl const GURL& referrer, const std::string& referrer_encoding, const DownloadSaveInfo& save_info, - TabContents* tab_contents) OVERRIDE; + content::WebContents* web_contents) OVERRIDE; virtual void AddObserver(Observer* observer) OVERRIDE; virtual void RemoveObserver(Observer* observer) OVERRIDE; virtual void OnPersistentStoreQueryComplete( diff --git a/content/browser/download/mock_download_manager.cc b/content/browser/download/mock_download_manager.cc index b5f7142..d5f28db 100644 --- a/content/browser/download/mock_download_manager.cc +++ b/content/browser/download/mock_download_manager.cc @@ -8,6 +8,7 @@ #include "content/browser/download/download_item_impl.h" using content::DownloadItem; +using content::WebContents; MockDownloadManager::MockDownloadManager( content::DownloadManagerDelegate* delegate, @@ -101,7 +102,7 @@ void MockDownloadManager::DownloadUrlToFile( const GURL& referrer, const std::string& referrer_encoding, const DownloadSaveInfo& save_info, - TabContents* tab_contents) { + WebContents* web_contents) { } void MockDownloadManager::AddObserver(Observer* observer) { diff --git a/content/browser/download/mock_download_manager.h b/content/browser/download/mock_download_manager.h index d7a1f2b..f941572 100644 --- a/content/browser/download/mock_download_manager.h +++ b/content/browser/download/mock_download_manager.h @@ -56,7 +56,7 @@ class MockDownloadManager : public content::DownloadManager { const GURL& referrer, const std::string& referrer_encoding, const DownloadSaveInfo& save_info, - TabContents* tab_contents) OVERRIDE; + content::WebContents* web_contents) OVERRIDE; virtual void AddObserver(Observer* observer) OVERRIDE; virtual void RemoveObserver(Observer* observer) OVERRIDE; virtual void OnPersistentStoreQueryComplete( diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc index 75369a9..6c89fcb 100644 --- a/content/browser/tab_contents/interstitial_page.cc +++ b/content/browser/tab_contents/interstitial_page.cc @@ -248,7 +248,7 @@ void InterstitialPage::Hide() { content::NotificationService::current()->Notify( content::NOTIFICATION_INTERSTITIAL_DETACHED, - content::Source<TabContents>(tab_), + content::Source<WebContents>(tab_), content::NotificationService::NoDetails()); delete this; @@ -343,7 +343,7 @@ void InterstitialPage::DidNavigate( // hiding the bookmark bar. content::NotificationService::current()->Notify( content::NOTIFICATION_INTERSTITIAL_ATTACHED, - content::Source<TabContents>(tab_), + content::Source<WebContents>(tab_), content::NotificationService::NoDetails()); RenderWidgetHostView* rwh_view = tab_->GetRenderViewHost()->view(); diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc index 280fe99..55e6ce3 100644 --- a/content/browser/tab_contents/navigation_controller.cc +++ b/content/browser/tab_contents/navigation_controller.cc @@ -35,6 +35,7 @@ using content::GlobalRequestID; using content::NavigationEntry; using content::NavigationEntryImpl; using content::UserMetricsAction; +using content::WebContents; namespace { @@ -181,6 +182,10 @@ NavigationController::~NavigationController() { content::NotificationService::NoDetails()); } +WebContents* NavigationController::GetWebContents() const { + return tab_contents_; +} + content::BrowserContext* NavigationController::GetBrowserContext() const { return browser_context_; } diff --git a/content/browser/tab_contents/navigation_controller.h b/content/browser/tab_contents/navigation_controller.h index 0f7f687..2699d88 100644 --- a/content/browser/tab_contents/navigation_controller.h +++ b/content/browser/tab_contents/navigation_controller.h @@ -15,6 +15,7 @@ #include "content/public/browser/navigation_type.h" class SiteInstance; +class TabContents; struct ViewHostMsg_FrameNavigate_Params; namespace content { @@ -32,6 +33,7 @@ class CONTENT_EXPORT NavigationController virtual ~NavigationController(); // NavigationController implementation: + virtual content::WebContents* GetWebContents() const OVERRIDE; virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; virtual void Restore( int selected_navigation, @@ -121,8 +123,6 @@ class CONTENT_EXPORT NavigationController // TabContents --------------------------------------------------------------- - // Returns the tab contents associated with this controller. Non-NULL except - // during set-up of the tab. TabContents* tab_contents() const { // This currently returns the active tab contents which should be renamed to // tab_contents. diff --git a/content/browser/tab_contents/navigation_controller_unittest.cc b/content/browser/tab_contents/navigation_controller_unittest.cc index 64e5458..b388f6d 100644 --- a/content/browser/tab_contents/navigation_controller_unittest.cc +++ b/content/browser/tab_contents/navigation_controller_unittest.cc @@ -1936,7 +1936,7 @@ TEST_F(NavigationControllerTest, CloneAndGoBack) { NavigateAndCommit(url1); NavigateAndCommit(url2); - scoped_ptr<TabContents> clone(controller().tab_contents()->Clone()); + scoped_ptr<TabContents> clone(controller().GetWebContents()->Clone()); ASSERT_EQ(2, clone->GetController().GetEntryCount()); EXPECT_TRUE(clone->GetController().NeedsReload()); @@ -1958,7 +1958,7 @@ TEST_F(NavigationControllerTest, CloneOmitsInterstitials) { interstitial_entry->set_page_type(content::PAGE_TYPE_INTERSTITIAL); controller().AddTransientEntry(interstitial_entry); - scoped_ptr<TabContents> clone(controller().tab_contents()->Clone()); + scoped_ptr<TabContents> clone(controller().GetWebContents()->Clone()); ASSERT_EQ(2, clone->GetController().GetEntryCount()); } diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 808366a..8b26b57 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -1579,8 +1579,8 @@ void TabContents::NotifyDisconnected() { notify_disconnection_ = false; content::NotificationService::current()->Notify( - content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, - content::Source<TabContents>(this), + content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, + content::Source<WebContents>(this), content::NotificationService::NoDetails()); } @@ -1613,7 +1613,7 @@ content::ViewType TabContents::GetRenderViewType() const { void TabContents::RenderViewCreated(RenderViewHost* render_view_host) { content::NotificationService::current()->Notify( content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, - content::Source<TabContents>(this), + content::Source<WebContents>(this), content::Details<RenderViewHost>(render_view_host)); NavigationEntry* entry = controller_.GetActiveEntry(); if (!entry) @@ -1898,7 +1898,7 @@ void TabContents::DocumentOnLoadCompletedInMainFrame( int32 page_id) { content::NotificationService::current()->Notify( content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, - content::Source<TabContents>(this), + content::Source<WebContents>(this), content::Details<int>(&page_id)); } diff --git a/content/public/browser/download_manager.h b/content/public/browser/download_manager.h index c123cc0..c4a4fd6 100644 --- a/content/public/browser/download_manager.h +++ b/content/public/browser/download_manager.h @@ -52,6 +52,7 @@ struct DownloadSaveInfo; namespace content { class BrowserContext; class DownloadManagerDelegate; +class WebContents; // Browser's download manager: manages all downloads and destination view. class CONTENT_EXPORT DownloadManager @@ -156,18 +157,18 @@ class CONTENT_EXPORT DownloadManager // Download the object at the URL. Used in cases such as "Save Link As..." virtual void DownloadUrl(const GURL& url, - const GURL& referrer, - const std::string& referrer_encoding, - TabContents* tab_contents) = 0; + const GURL& referrer, + const std::string& referrer_encoding, + TabContents* tab_contents) = 0; // Download the object at the URL and save it to the specified path. The // download is treated as the temporary download and thus will not appear // in the download history. Used in cases such as drag and drop. virtual void DownloadUrlToFile(const GURL& url, - const GURL& referrer, - const std::string& referrer_encoding, - const DownloadSaveInfo& save_info, - TabContents* tab_contents) = 0; + const GURL& referrer, + const std::string& referrer_encoding, + const DownloadSaveInfo& save_info, + WebContents* web_contents) = 0; // Allow objects to observe the download creation process. virtual void AddObserver(Observer* observer) = 0; diff --git a/content/public/browser/navigation_controller.h b/content/public/browser/navigation_controller.h index 22d2eed..3abe622 100644 --- a/content/public/browser/navigation_controller.h +++ b/content/public/browser/navigation_controller.h @@ -17,19 +17,19 @@ class GURL; class SessionStorageNamespace; class SSLManager; -class TabContents; namespace content { class BrowserContext; class NavigationEntry; +class WebContents; struct Referrer; // A NavigationController maintains the back-forward list for a single tab and // manages all navigation within that list. // -// The NavigationController also owns all TabContents for the tab. This is to -// make sure that we have at most one TabContents instance per type. +// The NavigationController also owns all WebContents for the tab. This is to +// make sure that we have at most one WebContents instance per type. class NavigationController { public: enum ReloadType { @@ -51,6 +51,10 @@ class NavigationController { virtual ~NavigationController() {} + // Returns the web contents associated with this controller. Non-NULL except + // during set-up of the tab. + virtual WebContents* GetWebContents() const = 0; + // Returns the browser context for this controller. It can never be NULL. virtual BrowserContext* GetBrowserContext() const = 0; diff --git a/content/public/browser/notification_types.h b/content/public/browser/notification_types.h index bfa3d38..281c55e 100644 --- a/content/public/browser/notification_types.h +++ b/content/public/browser/notification_types.h @@ -82,7 +82,7 @@ enum NotificationType { // Other load-related (not from NavigationController) ---------------------- // Corresponds to ViewHostMsg_DocumentOnLoadCompletedInMainFrame. The source - // is the TabContents and the details the page_id. + // is the WebContents and the details the page_id. NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, // A content load is starting. The source will be a @@ -237,10 +237,10 @@ enum NotificationType { // source pointer becomes junk. No details are expected. NOTIFICATION_TAB_CONTENTS_SWAPPED, - // This message is sent after a TabContents is disconnected from the - // renderer process. The source is a Source<TabContents> with a pointer to - // the TabContents (the pointer is usable). No details are expected. - NOTIFICATION_TAB_CONTENTS_DISCONNECTED, + // This message is sent after a WebContents is disconnected from the + // renderer process. The source is a Source<WebContents> with a pointer to + // the WebContents (the pointer is usable). No details are expected. + NOTIFICATION_WEB_CONTENTS_DISCONNECTED, // This notification is sent after TabContents' title is updated. The source // is a Source<TabContents> with a pointer to the TabContents. The details @@ -262,17 +262,17 @@ enum NotificationType { // TODO(sky): Remove when we figure out http://crbug.com/107172. NOTIFICATION_WEB_CONTENTS_DELEGATE_DESTROYED, - // A RenderViewHost was created for a TabContents. The source is the - // associated TabContents, and the details is the RenderViewHost + // A RenderViewHost was created for a WebContents. The source is the + // associated WebContents, and the details is the RenderViewHost // pointer. NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, // Notification than an interstitial has become associated with a tab. The - // source is the TabContents, the details not used. + // source is the WebContents, the details not used. NOTIFICATION_INTERSTITIAL_ATTACHED, // Notification than an interstitial has become detached from a tab. The - // source is the TabContents, the details not used. + // source is the WebContents, the details not used. NOTIFICATION_INTERSTITIAL_DETACHED, // Indicates that a RenderProcessHost was created and its handle is now |