diff options
138 files changed, 903 insertions, 706 deletions
diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index d284323..7ab97c0 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -76,7 +76,7 @@ string16 AlternateNavInfoBarDelegate::GetLinkText() const { bool AlternateNavInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { - owner()->tab_contents()->OpenURL( + owner()->web_contents()->OpenURL( alternate_nav_url_, GURL(), disposition, // Pretend the user typed this URL, so that navigating to // it will be the default action when it's typed again in diff --git a/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc b/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc index 1f845b4..f48c9f3 100644 --- a/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc +++ b/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc @@ -9,8 +9,8 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/webui/bug_report_ui.h" #include "chrome/browser/userfeedback/proto/extension.pb.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/navigation_details.h" +#include "content/public/browser/web_contents.h" #include "googleurl/src/gurl.h" AutofillFeedbackInfoBarDelegate::AutofillFeedbackInfoBarDelegate( @@ -50,7 +50,7 @@ bool AutofillFeedbackInfoBarDelegate::LinkClicked( browser::ShowHtmlBugReportView( Browser::GetBrowserForController( - &owner()->tab_contents()->GetController(), NULL), + &owner()->web_contents()->GetController(), NULL), feedback_message_, issue_type); return true; diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index f163f10..e5265ae 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -45,10 +45,10 @@ #include "chrome/common/pref_names.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/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" +#include "content/public/browser/web_contents.h" #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" #include "ipc/ipc_message_macros.h" @@ -245,7 +245,7 @@ void CheckForPopularForms(const std::vector<FormStructure*>& forms, } // namespace AutofillManager::AutofillManager(TabContentsWrapper* tab_contents) - : content::WebContentsObserver(tab_contents->tab_contents()), + : content::WebContentsObserver(tab_contents->web_contents()), tab_contents_wrapper_(tab_contents), personal_data_(NULL), download_manager_(tab_contents->profile(), this), @@ -331,7 +331,7 @@ bool AutofillManager::OnFormSubmitted(const FormData& form, if (!IsAutofillEnabled()) return false; - if (tab_contents()->GetBrowserContext()->IsOffTheRecord()) + if (web_contents()->GetBrowserContext()->IsOffTheRecord()) return false; // Don't save data that was submitted through JavaScript. @@ -640,7 +640,7 @@ void AutofillManager::OnFillAutofillFormData(int query_id, void AutofillManager::OnShowAutofillDialog() { Browser* browser = BrowserList::GetLastActiveWithProfile( - Profile::FromBrowserContext(tab_contents()->GetBrowserContext())); + Profile::FromBrowserContext(web_contents()->GetBrowserContext())); if (browser) browser->ShowOptionsTab(chrome::kAutofillSubPage); } @@ -648,7 +648,7 @@ void AutofillManager::OnShowAutofillDialog() { void AutofillManager::OnDidPreviewAutofillFormData() { content::NotificationService::current()->Notify( chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA, - content::Source<RenderViewHost>(tab_contents()->GetRenderViewHost()), + content::Source<RenderViewHost>(web_contents()->GetRenderViewHost()), content::NotificationService::NoDetails()); } @@ -656,7 +656,7 @@ void AutofillManager::OnDidPreviewAutofillFormData() { void AutofillManager::OnDidFillAutofillFormData(const TimeTicks& timestamp) { content::NotificationService::current()->Notify( chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA, - content::Source<RenderViewHost>(tab_contents()->GetRenderViewHost()), + content::Source<RenderViewHost>(web_contents()->GetRenderViewHost()), content::NotificationService::NoDetails()); metric_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL); @@ -672,7 +672,7 @@ void AutofillManager::OnDidFillAutofillFormData(const TimeTicks& timestamp) { void AutofillManager::OnDidShowAutofillSuggestions(bool is_new_popup) { content::NotificationService::current()->Notify( chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS, - content::Source<RenderViewHost>(tab_contents()->GetRenderViewHost()), + content::Source<RenderViewHost>(web_contents()->GetRenderViewHost()), content::NotificationService::NoDetails()); if (is_new_popup) { @@ -709,7 +709,7 @@ void AutofillManager::OnDidEndTextFieldEditing() { bool AutofillManager::IsAutofillEnabled() const { Profile* profile = Profile::FromBrowserContext( - const_cast<AutofillManager*>(this)->tab_contents()->GetBrowserContext()); + const_cast<AutofillManager*>(this)->web_contents()->GetBrowserContext()); return profile->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); } @@ -719,7 +719,7 @@ void AutofillManager::SendAutofillTypePredictions( switches::kShowAutofillTypePredictions)) return; - RenderViewHost* host = tab_contents()->GetRenderViewHost(); + RenderViewHost* host = web_contents()->GetRenderViewHost(); if (!host) return; @@ -737,7 +737,7 @@ void AutofillManager::ImportFormData(const FormStructure& submitted_form) { // If credit card information was submitted, show an infobar to offer to save // it. scoped_ptr<const CreditCard> scoped_credit_card(imported_credit_card); - if (imported_credit_card && tab_contents()) { + if (imported_credit_card && web_contents()) { InfoBarTabHelper* infobar_helper = tab_contents_wrapper_->infobar_tab_helper(); infobar_helper->AddInfoBar( @@ -802,7 +802,7 @@ void AutofillManager::Reset() { AutofillManager::AutofillManager(TabContentsWrapper* tab_contents, PersonalDataManager* personal_data) - : content::WebContentsObserver(tab_contents->tab_contents()), + : content::WebContentsObserver(tab_contents->web_contents()), tab_contents_wrapper_(tab_contents), personal_data_(personal_data), download_manager_(tab_contents->profile(), this), @@ -832,7 +832,7 @@ bool AutofillManager::GetHost(const std::vector<AutofillProfile*>& profiles, if (profiles.empty() && credit_cards.empty()) return false; - *host = tab_contents()->GetRenderViewHost(); + *host = web_contents()->GetRenderViewHost(); if (!*host) return false; diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 7df0658..8340316 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -104,6 +104,7 @@ using WebKit::WebFindOptions; using base::Time; using content::BrowserThread; using content::DownloadItem; +using content::WebContents; namespace { @@ -598,7 +599,7 @@ void AutomationProvider::SetProxyConfig(const std::string& new_proxy_config) { new_proxy_config)); } -TabContents* AutomationProvider::GetTabContentsForHandle( +WebContents* AutomationProvider::GetWebContentsForHandle( int handle, NavigationController** tab) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* nav_controller = tab_tracker_->GetResource(handle); @@ -1002,7 +1003,7 @@ void AutomationProvider::GetExtensionProperty( void AutomationProvider::SaveAsAsync(int tab_handle) { NavigationController* tab = NULL; - TabContents* tab_contents = GetTabContentsForHandle(tab_handle, &tab); - if (tab_contents) - tab_contents->OnSavePage(); + WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); + if (web_contents) + web_contents->OnSavePage(); } diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 3be4f6b..c2a092f 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -69,6 +69,7 @@ class DictionaryValue; namespace content { class DownloadItem; +class WebContents; } namespace gfx { @@ -167,10 +168,11 @@ class AutomationProvider // Returns the Browser if found. Browser* FindAndActivateTab(NavigationController* contents); - // Convert a tab handle into a TabContents. If |tab| is non-NULL a pointer + // Convert a tab handle into a WebContents. If |tab| is non-NULL a pointer // to the tab is also returned. Returns NULL in case of failure or if the tab - // is not of the TabContents type. - TabContents* GetTabContentsForHandle(int handle, NavigationController** tab); + // is not of the WebContents type. + content::WebContents* GetWebContentsForHandle(int handle, + NavigationController** tab); // Returns the protocol version which typically is the module version. virtual std::string GetProtocolVersion(); diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index a2f01e2..b865594 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -89,6 +89,7 @@ using content::BrowserThread; using content::DownloadItem; using content::DownloadManager; +using content::WebContents; // Holds onto start and stop timestamps for a particular tab class InitialLoadObserver::TabTime { @@ -1208,7 +1209,7 @@ DomOperationObserver::DomOperationObserver() { content::NotificationService::AllSources()); registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, content::NotificationService::AllSources()); - registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED, + registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, content::NotificationService::AllSources()); } @@ -1222,11 +1223,11 @@ void DomOperationObserver::Observe( OnDomOperationCompleted(dom_op_details->json()); } else if (type == chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN) { OnModalDialogShown(); - } else if (type == chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED) { - TabContents* tab_contents = content::Source<TabContents>(source).ptr(); - if (tab_contents) { + } else if (type == chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED) { + WebContents* web_contents = content::Source<WebContents>(source).ptr(); + if (web_contents) { TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents); if (wrapper && wrapper->content_settings() && wrapper->content_settings()->IsContentBlocked( diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 3b0a8dc..dd250da 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -25,11 +25,14 @@ #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/public/browser/web_contents.h" #include "content/public/common/page_zoom.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/views/focus/accelerator_handler.h" #include "ui/views/widget/root_view.h" +using content::WebContents; + namespace { // This callback just adds another callback to the event queue. This is useful @@ -189,10 +192,10 @@ void AutomationProvider::CreateExternalTab( settings.route_all_top_level_navigations); if (AddExternalTab(external_tab_container)) { - TabContents* tab_contents = external_tab_container->tab_contents(); + WebContents* web_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(); + *tab_window = web_contents->GetNativeView(); *session_id = external_tab_container->tab_contents_wrapper()-> restore_tab_helper()->session_id().id(); } else { @@ -205,9 +208,9 @@ void AutomationProvider::CreateExternalTab( bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { DCHECK(external_tab != NULL); - TabContents* tab_contents = external_tab->tab_contents(); - if (tab_contents) { - int tab_handle = tab_tracker_->Add(&tab_contents->GetController()); + WebContents* web_contents = external_tab->web_contents(); + if (web_contents) { + int tab_handle = tab_tracker_->Add(&web_contents->GetController()); external_tab->SetTabHandle(tab_handle); return true; } @@ -235,12 +238,12 @@ void AutomationProvider::SetInitialFocus(const IPC::Message& message, } void AutomationProvider::PrintAsync(int tab_handle) { - TabContents* tab_contents = GetTabContentsForHandle(tab_handle, NULL); - if (!tab_contents) + WebContents* web_contents = GetWebContentsForHandle(tab_handle, NULL); + if (!web_contents) return; TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents); wrapper->print_view_manager()->PrintNow(); } diff --git a/chrome/browser/automation/automation_tab_helper.cc b/chrome/browser/automation/automation_tab_helper.cc index 1d346ce..d012852 100644 --- a/chrome/browser/automation/automation_tab_helper.cc +++ b/chrome/browser/automation/automation_tab_helper.cc @@ -6,9 +6,9 @@ #include <algorithm> -#include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/tab_contents.h" #include "chrome/common/automation_messages.h" +#include "content/browser/tab_contents/navigation_controller.h" +#include "content/public/browser/web_contents.h" #include "ipc/ipc_message.h" #include "ipc/ipc_message_macros.h" #include "ui/gfx/size.h" @@ -37,8 +37,8 @@ void TabEventObserver::StopObserving(AutomationTabHelper* tab_helper) { event_sources_.erase(iter); } -AutomationTabHelper::AutomationTabHelper(TabContents* tab_contents) - : content::WebContentsObserver(tab_contents), +AutomationTabHelper::AutomationTabHelper(WebContents* web_contents) + : content::WebContentsObserver(web_contents), is_loading_(false) { } @@ -72,7 +72,7 @@ void AutomationTabHelper::DidStartLoading() { is_loading_ = true; if (!had_pending_loads) { FOR_EACH_OBSERVER(TabEventObserver, observers_, - OnFirstPendingLoad(tab_contents())); + OnFirstPendingLoad(web_contents())); } } @@ -84,12 +84,12 @@ void AutomationTabHelper::DidStopLoading() { is_loading_ = false; if (!has_pending_loads()) { FOR_EACH_OBSERVER(TabEventObserver, observers_, - OnNoMorePendingLoads(tab_contents())); + OnNoMorePendingLoads(web_contents())); } } void AutomationTabHelper::RenderViewGone(base::TerminationStatus status) { - OnTabOrRenderViewDestroyed(tab_contents()); + OnTabOrRenderViewDestroyed(web_contents()); } void AutomationTabHelper::WebContentsDestroyed(WebContents* web_contents) { @@ -146,7 +146,7 @@ void AutomationTabHelper::OnWillPerformClientRedirect( pending_client_redirects_.insert(frame_id); if (first_pending_load) { FOR_EACH_OBSERVER(TabEventObserver, observers_, - OnFirstPendingLoad(tab_contents())); + OnFirstPendingLoad(web_contents())); } } @@ -159,7 +159,7 @@ void AutomationTabHelper::OnDidCompleteOrCancelClientRedirect(int64 frame_id) { pending_client_redirects_.erase(iter); if (!has_pending_loads()) { FOR_EACH_OBSERVER(TabEventObserver, observers_, - OnNoMorePendingLoads(tab_contents())); + OnNoMorePendingLoads(web_contents())); } } } diff --git a/chrome/browser/automation/automation_tab_helper.h b/chrome/browser/automation/automation_tab_helper.h index 5d17565..40419ed 100644 --- a/chrome/browser/automation/automation_tab_helper.h +++ b/chrome/browser/automation/automation_tab_helper.h @@ -79,7 +79,7 @@ class AutomationTabHelper : public content::WebContentsObserver, public base::SupportsWeakPtr<AutomationTabHelper> { public: - explicit AutomationTabHelper(TabContents* tab_contents); + explicit AutomationTabHelper(content::WebContents* web_contents); virtual ~AutomationTabHelper(); void AddObserver(TabEventObserver* observer); diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 5a90048..ecb1134 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -153,6 +153,7 @@ using content::ChildProcessHost; using content::DownloadItem; using content::DownloadManager; using content::PluginService; +using content::WebContents; namespace { @@ -534,7 +535,7 @@ void TestingAutomationProvider::AppendTab(int handle, browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); if (contents) { append_tab_response = GetIndexForNavigationController( - &contents->tab_contents()->GetController(), browser); + &contents->web_contents()->GetController(), browser); } } @@ -1372,8 +1373,8 @@ void TestingAutomationProvider::ExecuteJavascript( const std::wstring& frame_xpath, const std::wstring& script, IPC::Message* reply_message) { - TabContents* tab_contents = GetTabContentsForHandle(handle, NULL); - if (!tab_contents) { + WebContents* web_contents = GetWebContentsForHandle(handle, NULL); + if (!web_contents) { AutomationMsg_DomOperation::WriteReplyParams(reply_message, std::string()); Send(reply_message); return; @@ -1382,7 +1383,7 @@ void TestingAutomationProvider::ExecuteJavascript( new DomOperationMessageSender(this, reply_message, false); ExecuteJavascriptInRenderViewFrame(WideToUTF16Hack(frame_xpath), WideToUTF16Hack(script), reply_message, - tab_contents->GetRenderViewHost()); + web_contents->GetRenderViewHost()); } void TestingAutomationProvider::GetConstrainedWindowCount(int handle, @@ -1404,12 +1405,12 @@ void TestingAutomationProvider::GetConstrainedWindowCount(int handle, void TestingAutomationProvider::HandleInspectElementRequest( int handle, int x, int y, IPC::Message* reply_message) { - TabContents* tab_contents = GetTabContentsForHandle(handle, NULL); - if (tab_contents) { + WebContents* web_contents = GetWebContentsForHandle(handle, NULL); + if (web_contents) { DCHECK(!reply_message_); reply_message_ = reply_message; - DevToolsWindow::InspectElement(tab_contents->GetRenderViewHost(), x, y); + DevToolsWindow::InspectElement(web_contents->GetRenderViewHost(), x, y); } else { AutomationMsg_InspectElement::WriteReplyParams(reply_message, -1); Send(reply_message); @@ -1535,9 +1536,9 @@ void TestingAutomationProvider::ShowInterstitialPage( void TestingAutomationProvider::HideInterstitialPage(int tab_handle, bool* success) { *success = false; - TabContents* tab_contents = GetTabContentsForHandle(tab_handle, NULL); - if (tab_contents && tab_contents->GetInterstitialPage()) { - tab_contents->GetInterstitialPage()->DontProceed(); + WebContents* web_contents = GetWebContentsForHandle(tab_handle, NULL); + if (web_contents && web_contents->GetInterstitialPage()) { + web_contents->GetInterstitialPage()->DontProceed(); *success = true; } } @@ -1660,15 +1661,15 @@ void TestingAutomationProvider::IsMenuCommandEnabled(int browser_handle, void TestingAutomationProvider::PrintNow(int tab_handle, IPC::Message* reply_message) { NavigationController* tab = NULL; - TabContents* tab_contents = GetTabContentsForHandle(tab_handle, &tab); - if (tab_contents) { + WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); + if (web_contents) { FindAndActivateTab(tab); content::NotificationObserver* observer = new DocumentPrintedNotificationObserver(this, reply_message); TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents); if (!wrapper->print_view_manager()->PrintNow()) { // Clean up the observer. It will send the reply message. delete observer; diff --git a/chrome/browser/bookmarks/bookmark_extension_api.cc b/chrome/browser/bookmarks/bookmark_extension_api.cc index 6c157ac..ca3eb87 100644 --- a/chrome/browser/bookmarks/bookmark_extension_api.cc +++ b/chrome/browser/bookmarks/bookmark_extension_api.cc @@ -42,6 +42,7 @@ namespace keys = bookmark_extension_api_constants; using base::TimeDelta; using content::BrowserThread; +using content::WebContents; typedef QuotaLimitHeuristic::Bucket Bucket; typedef QuotaLimitHeuristic::Config Config; typedef QuotaLimitHeuristic::BucketList BucketList; @@ -877,8 +878,8 @@ void BookmarksIOFunction::ShowSelectFileDialog(SelectFileDialog::Type type, file_type_info.extensions.resize(1); file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); - TabContents* tab_contents = dispatcher()->delegate()-> - GetAssociatedTabContents(); + WebContents* web_contents = dispatcher()->delegate()-> + GetAssociatedWebContents(); // |tab_contents| can be NULL (for background pages), which is fine. In such // a case if file-selection dialogs are forbidden by policy, we will not @@ -889,7 +890,7 @@ void BookmarksIOFunction::ShowSelectFileDialog(SelectFileDialog::Type type, &file_type_info, 0, FILE_PATH_LITERAL(""), - tab_contents, + web_contents, NULL, NULL); } diff --git a/chrome/browser/bookmarks/bookmark_manager_extension_api.cc b/chrome/browser/bookmarks/bookmark_manager_extension_api.cc index 95593b5..2d52b4c 100644 --- a/chrome/browser/bookmarks/bookmark_manager_extension_api.cc +++ b/chrome/browser/bookmarks/bookmark_manager_extension_api.cc @@ -30,6 +30,8 @@ namespace keys = bookmark_extension_api_constants; +using content::WebContents; + namespace { // Returns a single bookmark node from the argument ID. @@ -378,11 +380,11 @@ bool StartDragBookmarkManagerFunction::RunImpl() { if (render_view_host_->delegate()->GetRenderViewType() == content::VIEW_TYPE_TAB_CONTENTS) { - TabContents* tab_contents = - dispatcher()->delegate()->GetAssociatedTabContents(); - CHECK(tab_contents); + WebContents* web_contents = + dispatcher()->delegate()->GetAssociatedWebContents(); + CHECK(web_contents); bookmark_utils::DragBookmarks(profile(), nodes, - tab_contents->GetNativeView()); + web_contents->GetNativeView()); return true; } else { @@ -420,11 +422,11 @@ bool DropBookmarkManagerFunction::RunImpl() { if (render_view_host_->delegate()->GetRenderViewType() == content::VIEW_TYPE_TAB_CONTENTS) { - TabContents* tab_contents = - dispatcher()->delegate()->GetAssociatedTabContents(); - CHECK(tab_contents); + WebContents* web_contents = + dispatcher()->delegate()->GetAssociatedWebContents(); + CHECK(web_contents); ExtensionWebUI* web_ui = - static_cast<ExtensionWebUI*>(tab_contents->GetWebUI()); + static_cast<ExtensionWebUI*>(web_contents->GetWebUI()); CHECK(web_ui); BookmarkManagerExtensionEventRouter* router = web_ui->bookmark_manager_extension_event_router(); diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 7127cc9..d84467f 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -897,7 +897,7 @@ void ChromeContentBrowserClient::AllowCertificateError( prerender::PrerenderManager* prerender_manager = prerender::PrerenderManagerFactory::GetForProfile( Profile::FromBrowserContext(tab->GetBrowserContext())); - if (prerender_manager && prerender_manager->IsTabContentsPrerendering(tab)) { + if (prerender_manager && prerender_manager->IsWebContentsPrerendering(tab)) { if (prerender_manager->prerender_tracker()->TryCancel( handler->render_process_host_id(), handler->tab_contents_id(), diff --git a/chrome/browser/chromeos/boot_times_loader.cc b/chrome/browser/chromeos/boot_times_loader.cc index 375854f..ca821444 100644 --- a/chrome/browser/chromeos/boot_times_loader.cc +++ b/chrome/browser/chromeos/boot_times_loader.cc @@ -33,6 +33,7 @@ #include "content/public/browser/notification_service.h" using content::BrowserThread; +using content::WebContents; namespace { @@ -348,7 +349,7 @@ void BootTimesLoader::LoginDone() { content::NotificationService::AllSources()); registrar_.Remove(this, content::NOTIFICATION_LOAD_STOP, content::NotificationService::AllSources()); - registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, + registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); registrar_.Remove(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, content::NotificationService::AllSources()); @@ -412,7 +413,7 @@ void BootTimesLoader::RecordLoginAttempted() { content::NotificationService::AllSources()); registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, content::NotificationService::AllSources()); - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT, content::NotificationService::AllSources()); @@ -472,10 +473,10 @@ void BootTimesLoader::Observe( } break; } - case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: { - TabContents* tab_contents = content::Source<TabContents>(source).ptr(); + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { + WebContents* web_contents = content::Source<WebContents>(source).ptr(); RenderWidgetHost* render_widget_host = - GetRenderWidgetHost(&tab_contents->GetController()); + GetRenderWidgetHost(&web_contents->GetController()); render_widget_hosts_loading_.erase(render_widget_host); break; } diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc index 122e185..bd5a077 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings.cc +++ b/chrome/browser/content_settings/tab_specific_content_settings.cc @@ -31,6 +31,7 @@ #include "webkit/fileapi/file_system_types.h" using content::BrowserThread; +using content::WebContents; namespace { typedef std::list<TabSpecificContentSettings*> TabSpecificList; @@ -80,7 +81,7 @@ TabSpecificContentSettings* TabSpecificContentSettings::Get( // latter will miss provisional RenderViewHosts. for (TabSpecificList::iterator i = g_tab_specific.Get().begin(); i != g_tab_specific.Get().end(); ++i) { - if (view->delegate() == (*i)->tab_contents()) + if (view->delegate()->GetAsTabContents() == (*i)->web_contents()) return (*i); } @@ -233,8 +234,8 @@ void TabSpecificContentSettings::OnContentBlocked( content_blocked_[type] = true; // TODO: it would be nice to have a way of mocking this in tests. content::NotificationService::current()->Notify( - chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED, - content::Source<TabContents>(tab_contents()), + chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, + content::Source<WebContents>(web_contents()), content::NotificationService::NoDetails()); } } @@ -245,8 +246,8 @@ void TabSpecificContentSettings::OnContentAccessed(ContentSettingsType type) { if (!content_accessed_[type]) { content_accessed_[type] = true; content::NotificationService::current()->Notify( - chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED, - content::Source<TabContents>(tab_contents()), + chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, + content::Source<WebContents>(web_contents()), content::NotificationService::NoDetails()); } } @@ -350,8 +351,8 @@ void TabSpecificContentSettings::OnGeolocationPermissionSet( geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin, allowed); content::NotificationService::current()->Notify( - chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED, - content::Source<TabContents>(tab_contents()), + chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, + content::Source<WebContents>(web_contents()), content::NotificationService::NoDetails()); } @@ -366,8 +367,8 @@ void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { } load_plugins_link_enabled_ = true; content::NotificationService::current()->Notify( - chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED, - content::Source<TabContents>(tab_contents()), + chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, + content::Source<WebContents>(web_contents()), content::NotificationService::NoDetails()); } @@ -378,8 +379,8 @@ void TabSpecificContentSettings::ClearCookieSpecificContentSettings() { content_accessed_[CONTENT_SETTINGS_TYPE_COOKIES] = false; content_blockage_indicated_to_user_[CONTENT_SETTINGS_TYPE_COOKIES] = false; content::NotificationService::current()->Notify( - chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED, - content::Source<TabContents>(tab_contents()), + chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, + content::Source<WebContents>(web_contents()), content::NotificationService::NoDetails()); } @@ -387,8 +388,8 @@ void TabSpecificContentSettings::SetPopupsBlocked(bool blocked) { content_blocked_[CONTENT_SETTINGS_TYPE_POPUPS] = blocked; content_blockage_indicated_to_user_[CONTENT_SETTINGS_TYPE_POPUPS] = false; content::NotificationService::current()->Notify( - chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED, - content::Source<TabContents>(tab_contents()), + chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, + content::Source<WebContents>(web_contents()), content::NotificationService::NoDetails()); } @@ -464,7 +465,7 @@ void TabSpecificContentSettings::Observe( DCHECK(type == chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED); content::Details<const ContentSettingsDetails> settings_details(details); - const NavigationController& controller = tab_contents()->GetController(); + const NavigationController& controller = web_contents()->GetController(); NavigationEntry* entry = controller.GetActiveEntry(); GURL entry_url; if (entry) @@ -474,7 +475,7 @@ void TabSpecificContentSettings::Observe( // Currently this should be matched by the |primary_pattern|. settings_details.ptr()->primary_pattern().Matches(entry_url)) { Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); RendererContentSettingRules rules; GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules); diff --git a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc index 957f33b..00ed210 100644 --- a/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc +++ b/chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc @@ -93,7 +93,7 @@ bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { content::RecordAction( UserMetricsAction("RegisterProtocolHandler.InfoBar_LearnMore")); - owner()->tab_contents()->OpenURL(google_util::AppendGoogleLocaleParam(GURL( + owner()->web_contents()->OpenURL(google_util::AppendGoogleLocaleParam(GURL( chrome::kLearnMoreRegisterProtocolHandlerURL)), GURL(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK); diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc index 9de3a1e..3e27707 100644 --- a/chrome/browser/download/download_request_limiter.cc +++ b/chrome/browser/download/download_request_limiter.cc @@ -21,6 +21,7 @@ #include "content/public/browser/web_contents_delegate.h" using content::BrowserThread; +using content::WebContents; // TabDownloadState ------------------------------------------------------------ @@ -212,7 +213,7 @@ void DownloadRequestLimiter::CanDownloadOnIOThread(int render_process_host_id, render_process_host_id, render_view_id, request_id, callback)); } -void DownloadRequestLimiter::OnUserGesture(TabContents* tab) { +void DownloadRequestLimiter::OnUserGesture(WebContents* tab) { TabDownloadState* state = GetDownloadState(&tab->GetController(), NULL, false); if (!state) diff --git a/chrome/browser/download/download_request_limiter.h b/chrome/browser/download/download_request_limiter.h index 0224e89..0889924 100644 --- a/chrome/browser/download/download_request_limiter.h +++ b/chrome/browser/download/download_request_limiter.h @@ -19,6 +19,10 @@ class NavigationController; class TabContents; class TabContentsWrapper; +namespace content { +class WebContents; +} + // DownloadRequestLimiter is responsible for determining whether a download // should be allowed or not. It is designed to keep pages from downloading // multiple files without user interaction. DownloadRequestLimiter is invoked @@ -184,7 +188,7 @@ class DownloadRequestLimiter // Invoked when the user presses the mouse, enter key or space bar. This may // change the download status for the page. See the class description for // details. - void OnUserGesture(TabContents* tab); + void OnUserGesture(content::WebContents* tab); private: friend class base::RefCountedThreadSafe<DownloadRequestLimiter>; diff --git a/chrome/browser/download/download_request_limiter_observer.cc b/chrome/browser/download/download_request_limiter_observer.cc index 661b466..c5bd6e7 100644 --- a/chrome/browser/download/download_request_limiter_observer.cc +++ b/chrome/browser/download/download_request_limiter_observer.cc @@ -20,5 +20,5 @@ DownloadRequestLimiterObserver::~DownloadRequestLimiterObserver() { void DownloadRequestLimiterObserver::DidGetUserGesture() { if (!g_browser_process->download_request_limiter()) return; // NULL in unitests. - g_browser_process->download_request_limiter()->OnUserGesture(tab_contents()); + g_browser_process->download_request_limiter()->OnUserGesture(web_contents()); } diff --git a/chrome/browser/download/download_started_animation.h b/chrome/browser/download/download_started_animation.h index 1ac93c4..db154aad 100644 --- a/chrome/browser/download/download_started_animation.h +++ b/chrome/browser/download/download_started_animation.h @@ -8,11 +8,13 @@ #include "base/basictypes.h" -class TabContents; +namespace content { +class WebContents; +} class DownloadStartedAnimation { public: - static void Show(TabContents* tab_contents); + static void Show(content::WebContents* web_contents); private: DownloadStartedAnimation() { } diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc index 1932b93..689419d 100644 --- a/chrome/browser/extensions/extension_browser_event_router.cc +++ b/chrome/browser/extensions/extension_browser_event_router.cc @@ -29,6 +29,8 @@ namespace events = extension_event_names; namespace tab_keys = extension_tabs_module_constants; namespace page_action_keys = extension_page_actions_module_constants; +using content::WebContents; + ExtensionBrowserEventRouter::TabEntry::TabEntry() : complete_waiting_on_load_(false), url_() { @@ -149,16 +151,16 @@ void ExtensionBrowserEventRouter::RegisterForTabNotifications( // possible for tabs to be created, detached and then destroyed without // ever having been re-attached and closed. This happens in the case of // a devtools TabContents that is opened in window, docked, then closed. - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(contents)); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(contents)); } void ExtensionBrowserEventRouter::UnregisterForTabNotifications( TabContents* contents) { registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>(&contents->GetController())); - registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(contents)); + registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(contents)); } void ExtensionBrowserEventRouter::OnBrowserWindowReady(const Browser* browser) { @@ -537,13 +539,13 @@ void ExtensionBrowserEventRouter::Observe( NavigationController* source_controller = content::Source<NavigationController>(source).ptr(); TabUpdated(source_controller->tab_contents(), true); - } else if (type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED) { + } else if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { // Tab was destroyed after being detached (without being re-attached). - TabContents* contents = content::Source<TabContents>(source).ptr(); + WebContents* contents = content::Source<WebContents>(source).ptr(); registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>(&contents->GetController())); - registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(contents)); + registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(contents)); } else if (type == chrome::NOTIFICATION_BROWSER_WINDOW_READY) { const Browser* browser = content::Source<const Browser>(source).ptr(); OnBrowserWindowReady(browser); diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc index 585a88b..d10ff88 100644 --- a/chrome/browser/extensions/extension_file_browser_private_api.cc +++ b/chrome/browser/extensions/extension_file_browser_private_api.cc @@ -51,6 +51,7 @@ #include "webkit/fileapi/file_system_util.h" using content::BrowserThread; +using content::WebContents; namespace { @@ -978,13 +979,13 @@ int32 FileBrowserFunction::GetTabId() const { LOG(WARNING) << "No delegate"; return 0; } - TabContents* tab_contents = - dispatcher()->delegate()->GetAssociatedTabContents(); - if (!tab_contents) { + WebContents* web_contents = + dispatcher()->delegate()->GetAssociatedWebContents(); + if (!web_contents) { LOG(WARNING) << "No associated tab contents"; return 0; } - return ExtensionTabUtil::GetTabId(tab_contents); + return ExtensionTabUtil::GetTabId(web_contents); } void FileBrowserFunction::GetLocalPathsOnFileThreadAndRunCallbackOnUIThread( diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h index fd4c7da..c06beef 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.h +++ b/chrome/browser/extensions/extension_function_dispatcher.h @@ -21,9 +21,12 @@ class Extension; class ExtensionFunction; class Profile; class RenderViewHost; -class TabContents; struct ExtensionHostMsg_Request_Params; +namespace content { +class WebContents; +} + namespace extensions { class ProcessMap; } @@ -57,11 +60,11 @@ class ExtensionFunctionDispatcher // if the view is not visible. virtual gfx::NativeView GetNativeViewOfHost() = 0; - // Asks the delegate for any relevant TabContents associated with this - // context. For example, the TabContents in which an infobar or + // Asks the delegate for any relevant WebbContents associated with this + // context. For example, the WebbContents in which an infobar or // chrome-extension://<id> URL are being shown. Callers must check for a // NULL return value (as in the case of a background page). - virtual TabContents* GetAssociatedTabContents() const = 0; + virtual content::WebContents* GetAssociatedWebContents() const = 0; protected: virtual ~Delegate() {} diff --git a/chrome/browser/extensions/extension_function_test_utils.cc b/chrome/browser/extensions/extension_function_test_utils.cc index 46a278c..ea7a2ac 100644 --- a/chrome/browser/extensions/extension_function_test_utils.cc +++ b/chrome/browser/extensions/extension_function_test_utils.cc @@ -16,6 +16,8 @@ #include "chrome/test/base/ui_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" +using content::WebContents; + namespace { class TestFunctionDispatcherDelegate @@ -34,7 +36,7 @@ class TestFunctionDispatcherDelegate return NULL; } - virtual TabContents* GetAssociatedTabContents() const OVERRIDE { + virtual WebContents* GetAssociatedWebContents() const OVERRIDE { return NULL; } diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 84ae278..af3e76b 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -52,6 +52,7 @@ using WebKit::WebDragOperation; using WebKit::WebDragOperationsMask; +using content::WebContents; // Helper class that rate-limits the creation of renderer processes for // ExtensionHosts, to avoid blocking the UI. @@ -128,7 +129,7 @@ ExtensionHost::ExtensionHost(const Extension* extension, ALLOW_THIS_IN_INITIALIZER_LIST( extension_function_dispatcher_(profile_, this)), extension_host_type_(host_type), - associated_tab_contents_(NULL) { + associated_web_contents_(NULL) { host_contents_.reset(new TabContents( profile_, site_instance, MSG_ROUTING_NONE, NULL, NULL)); content::WebContentsObserver::Observe(host_contents_.get()); @@ -157,7 +158,7 @@ ExtensionHost::ExtensionHost(const Extension* extension, ALLOW_THIS_IN_INITIALIZER_LIST( extension_function_dispatcher_(profile_, this)), extension_host_type_(host_type), - associated_tab_contents_(NULL) { + associated_web_contents_(NULL) { } ExtensionHost::~ExtensionHost() { @@ -186,8 +187,8 @@ void ExtensionHost::CreateView(Browser* browser) { #endif } -TabContents* ExtensionHost::GetAssociatedTabContents() const { - return associated_tab_contents_; +WebContents* ExtensionHost::GetAssociatedWebContents() const { + return associated_web_contents_; } content::RenderProcessHost* ExtensionHost::render_process_host() const { @@ -506,7 +507,7 @@ void ExtensionHost::AddNewContents(TabContents* source, // Note that we don't do this for popup windows, because we need to associate // those with their extension_app_id. if (disposition != NEW_POPUP) { - TabContents* associated_contents = GetAssociatedTabContents(); + WebContents* associated_contents = GetAssociatedWebContents(); if (associated_contents && associated_contents->GetBrowserContext() == new_contents->GetBrowserContext()) { diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index b5b45c8..68fb721 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -86,9 +86,9 @@ class ExtensionHost : public content::WebContentsDelegate, const GURL& GetURL() const; // ExtensionFunctionDispatcher::Delegate - virtual TabContents* GetAssociatedTabContents() const OVERRIDE; - void set_associated_tab_contents(TabContents* associated_tab_contents) { - associated_tab_contents_ = associated_tab_contents; + virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; + void set_associated_web_contents(content::WebContents* web_contents) { + associated_web_contents_ = web_contents; } // Returns true if the render view is initialized and didn't crash. @@ -219,8 +219,8 @@ class ExtensionHost : public content::WebContentsDelegate, // are used here, others are not hosted by ExtensionHost. content::ViewType extension_host_type_; - // The relevant TabContents associated with this ExtensionHost, if any. - TabContents* associated_tab_contents_; + // The relevant WebContents associated with this ExtensionHost, if any. + content::WebContents* associated_web_contents_; // Used to measure how long it's been since the host was created. PerfTimer since_created_; diff --git a/chrome/browser/extensions/extension_infobar_delegate.cc b/chrome/browser/extensions/extension_infobar_delegate.cc index b1922dbc..e5ad10b 100644 --- a/chrome/browser/extensions/extension_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_infobar_delegate.cc @@ -29,7 +29,7 @@ ExtensionInfoBarDelegate::ExtensionInfoBarDelegate( ExtensionProcessManager* manager = browser->profile()->GetExtensionProcessManager(); extension_host_.reset(manager->CreateInfobarHost(url, browser)); - extension_host_->set_associated_tab_contents(infobar_helper->tab_contents()); + extension_host_->set_associated_web_contents(infobar_helper->web_contents()); registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, content::Source<Profile>(browser->profile())); diff --git a/chrome/browser/extensions/extension_menu_manager.cc b/chrome/browser/extensions/extension_menu_manager.cc index d69539e..b2e04ad 100644 --- a/chrome/browser/extensions/extension_menu_manager.cc +++ b/chrome/browser/extensions/extension_menu_manager.cc @@ -23,6 +23,8 @@ #include "ui/gfx/favicon_size.h" #include "webkit/glue/context_menu.h" +using content::WebContents; + ExtensionMenuItem::ExtensionMenuItem(const Id& id, const std::string& title, bool checked, @@ -373,7 +375,7 @@ static void AddURLProperty(DictionaryValue* dictionary, void ExtensionMenuManager::ExecuteCommand( Profile* profile, - TabContents* tab_contents, + WebContents* web_contents, const ContextMenuParams& params, const ExtensionMenuItem::Id& menuItemId) { ExtensionEventRouter* event_router = profile->GetExtensionEventRouter(); @@ -420,8 +422,8 @@ void ExtensionMenuManager::ExecuteCommand( args.Append(properties); // Add the tab info to the argument list. - if (tab_contents) { - args.Append(ExtensionTabUtil::CreateTabValue(tab_contents)); + if (web_contents) { + args.Append(ExtensionTabUtil::CreateTabValue(web_contents)); } else { args.Append(new DictionaryValue()); } diff --git a/chrome/browser/extensions/extension_menu_manager.h b/chrome/browser/extensions/extension_menu_manager.h index 06652af..4fdacda 100644 --- a/chrome/browser/extensions/extension_menu_manager.h +++ b/chrome/browser/extensions/extension_menu_manager.h @@ -26,7 +26,10 @@ struct ContextMenuParams; class Extension; class Profile; class SkBitmap; -class TabContents; + +namespace content { +class WebContents; +} // Represents a menu item added by an extension. class ExtensionMenuItem { @@ -237,7 +240,7 @@ class ExtensionMenuManager : public content::NotificationObserver { ExtensionMenuItem* GetItemById(const ExtensionMenuItem::Id& id) const; // Called when a menu item is clicked on by the user. - void ExecuteCommand(Profile* profile, TabContents* tab_contents, + void ExecuteCommand(Profile* profile, content::WebContents* web_contents, const ContextMenuParams& params, const ExtensionMenuItem::Id& menuItemId); diff --git a/chrome/browser/extensions/extension_sidebar_api.cc b/chrome/browser/extensions/extension_sidebar_api.cc index 0b7e176..b48a07e 100644 --- a/chrome/browser/extensions/extension_sidebar_api.cc +++ b/chrome/browser/extensions/extension_sidebar_api.cc @@ -25,6 +25,8 @@ #include "ipc/ipc_message_utils.h" #include "third_party/skia/include/core/SkBitmap.h" +using content::WebContents; + namespace { // Errors. const char kNoSidebarError[] = @@ -54,7 +56,7 @@ const char kShownState[] = "shown"; // static void ExtensionSidebarEventRouter::OnStateChanged( - Profile* profile, TabContents* tab, const std::string& content_id, + Profile* profile, WebContents* tab, const std::string& content_id, const std::string& state) { int tab_id = ExtensionTabUtil::GetTabId(tab); DictionaryValue* details = new DictionaryValue; diff --git a/chrome/browser/extensions/extension_sidebar_api.h b/chrome/browser/extensions/extension_sidebar_api.h index fcee7af..7db615e 100644 --- a/chrome/browser/extensions/extension_sidebar_api.h +++ b/chrome/browser/extensions/extension_sidebar_api.h @@ -15,6 +15,10 @@ namespace base { class DictionaryValue; } +namespace content { +class WebContents; +} + namespace extension_sidebar_constants { extern const char kActiveState[]; extern const char kHiddenState[]; @@ -26,8 +30,8 @@ class ExtensionSidebarEventRouter { public: // Sidebar state changed. static void OnStateChanged( - Profile* profile, TabContents* tab, const std::string& content_id, - const std::string& state); + Profile* profile, content::WebContents* tab, + const std::string& content_id, const std::string& state); private: DISALLOW_COPY_AND_ASSIGN(ExtensionSidebarEventRouter); diff --git a/chrome/browser/extensions/extension_tab_helper.cc b/chrome/browser/extensions/extension_tab_helper.cc index 5d9ca1d..912a762 100644 --- a/chrome/browser/extensions/extension_tab_helper.cc +++ b/chrome/browser/extensions/extension_tab_helper.cc @@ -23,6 +23,8 @@ #include "content/public/browser/navigation_details.h" #include "content/public/browser/notification_service.h" +using content::WebContents; + ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) : content::WebContentsObserver(wrapper->tab_contents()), delegate_(NULL), @@ -41,7 +43,7 @@ void ExtensionTabHelper::CopyStateFrom(const ExtensionTabHelper& source) { } void ExtensionTabHelper::PageActionStateChanged() { - tab_contents()->NotifyNavigationStateChanged( + web_contents()->NotifyNavigationStateChanged( TabContents::INVALIDATE_PAGE_ACTIONS); } @@ -67,7 +69,7 @@ void ExtensionTabHelper::SetExtensionAppById( return; Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); ExtensionService* extension_service = profile->GetExtensionService(); if (!extension_service || !extension_service->is_ready()) return; @@ -92,7 +94,7 @@ void ExtensionTabHelper::DidNavigateMainFrame( return; Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); ExtensionService* service = profile->GetExtensionService(); if (!service) return; @@ -153,7 +155,7 @@ void ExtensionTabHelper::OnInlineWebstoreInstall( const std::string& webstore_item_id, const GURL& requestor_url) { scoped_refptr<WebstoreInlineInstaller> installer(new WebstoreInlineInstaller( - tab_contents(), install_id, webstore_item_id, requestor_url, this)); + web_contents(), install_id, webstore_item_id, requestor_url, this)); installer->BeginInstall(); } @@ -165,7 +167,7 @@ void ExtensionTabHelper::OnGetAppNotifyChannel( // Check for permission first. Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); ExtensionService* extension_service = profile->GetExtensionService(); extensions::ProcessMap* process_map = extension_service->process_map(); content::RenderProcessHost* process = @@ -208,7 +210,7 @@ void ExtensionTabHelper::AppNotifyChannelSetupComplete( // If the setup was successful, record that fact in ExtensionService. if (!channel_id.empty() && error.empty()) { Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); ExtensionService* service = profile->GetExtensionService(); if (service->GetExtensionById(setup->extension_id(), true)) service->SetAppNotificationSetupDone(setup->extension_id(), @@ -222,7 +224,7 @@ void ExtensionTabHelper::AppNotifyChannelSetupComplete( void ExtensionTabHelper::OnRequest( const ExtensionHostMsg_Request_Params& request) { extension_function_dispatcher_.Dispatch(request, - tab_contents()->GetRenderViewHost()); + web_contents()->GetRenderViewHost()); } void ExtensionTabHelper::UpdateExtensionAppIcon(const Extension* extension) { @@ -244,7 +246,7 @@ void ExtensionTabHelper::UpdateExtensionAppIcon(const Extension* extension) { void ExtensionTabHelper::SetAppIcon(const SkBitmap& app_icon) { extension_app_icon_ = app_icon; - tab_contents()->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE); + web_contents()->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE); } void ExtensionTabHelper::OnImageLoaded(SkBitmap* image, @@ -252,12 +254,12 @@ void ExtensionTabHelper::OnImageLoaded(SkBitmap* image, int index) { if (image) { extension_app_icon_ = *image; - tab_contents()->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB); + web_contents()->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB); } } Browser* ExtensionTabHelper::GetBrowser() { - TabContents* contents = tab_contents(); + content::WebContents* contents = web_contents(); TabContentsIterator tab_iterator; for (; !tab_iterator.done(); ++tab_iterator) { if (contents == (*tab_iterator)->tab_contents()) @@ -278,11 +280,11 @@ void ExtensionTabHelper::OnInlineInstallFailure(int install_id, routing_id(), install_id, false, error)); } -TabContents* ExtensionTabHelper::GetAssociatedTabContents() const { - return tab_contents(); +WebContents* ExtensionTabHelper::GetAssociatedWebContents() const { + return web_contents(); } gfx::NativeView ExtensionTabHelper::GetNativeViewOfHost() { - RenderWidgetHostView* rwhv = tab_contents()->GetRenderWidgetHostView(); + RenderWidgetHostView* rwhv = web_contents()->GetRenderWidgetHostView(); return rwhv ? rwhv->GetNativeView() : NULL; } diff --git a/chrome/browser/extensions/extension_tab_helper.h b/chrome/browser/extensions/extension_tab_helper.h index 869034e..ff053d4 100644 --- a/chrome/browser/extensions/extension_tab_helper.h +++ b/chrome/browser/extensions/extension_tab_helper.h @@ -83,8 +83,8 @@ class ExtensionTabHelper return wrapper_; } - TabContents* tab_contents() const { - return content::WebContentsObserver::tab_contents(); + content::WebContents* web_contents() const { + return content::WebContentsObserver::web_contents(); } // Sets a non-extension app icon associated with TabContents and fires an @@ -101,7 +101,7 @@ class ExtensionTabHelper // ExtensionFunctionDispatcher::Delegate overrides. virtual Browser* GetBrowser() OVERRIDE; virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; - virtual TabContents* GetAssociatedTabContents() const OVERRIDE; + virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; // Message handlers. void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info); diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc index 4ab20a64..d5236a9 100644 --- a/chrome/browser/extensions/extension_tab_util.cc +++ b/chrome/browser/extensions/extension_tab_util.cc @@ -44,9 +44,9 @@ std::string ExtensionTabUtil::GetTabStatusText(bool is_loading) { } // TODO(sky): this function should really take a TabContentsWrapper. -int ExtensionTabUtil::GetWindowIdOfTab(const TabContents* tab_contents) { +int ExtensionTabUtil::GetWindowIdOfTab(const WebContents* web_contents) { const TabContentsWrapper* tab = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents); return tab ? tab->restore_tab_helper()->window_id().id() : -1; } @@ -71,8 +71,7 @@ std::string ExtensionTabUtil::GetWindowShowStateText(const Browser* browser) { return keys::kShowStateValueNormal; } -DictionaryValue* ExtensionTabUtil::CreateTabValue( - const TabContents* contents) { +DictionaryValue* ExtensionTabUtil::CreateTabValue(const WebContents* contents) { // Find the tab strip and index of this guy. TabStripModel* tab_strip = NULL; int tab_index; @@ -94,7 +93,7 @@ ListValue* ExtensionTabUtil::CreateTabList(const Browser* browser) { return tab_list; } -DictionaryValue* ExtensionTabUtil::CreateTabValue(const TabContents* contents, +DictionaryValue* ExtensionTabUtil::CreateTabValue(const WebContents* contents, TabStripModel* tab_strip, int tab_index) { DictionaryValue* result = new DictionaryValue(); @@ -129,7 +128,7 @@ DictionaryValue* ExtensionTabUtil::CreateTabValue(const TabContents* contents, } DictionaryValue* ExtensionTabUtil::CreateTabValueActive( - const TabContents* contents, + const WebContents* contents, bool active) { DictionaryValue* result = ExtensionTabUtil::CreateTabValue(contents); result->SetBoolean(keys::kSelectedKey, active); @@ -167,17 +166,17 @@ DictionaryValue* ExtensionTabUtil::CreateWindowValue(const Browser* browser, return result; } -bool ExtensionTabUtil::GetTabStripModel(const TabContents* tab_contents, +bool ExtensionTabUtil::GetTabStripModel(const WebContents* web_contents, TabStripModel** tab_strip_model, int* tab_index) { - DCHECK(tab_contents); + DCHECK(web_contents); DCHECK(tab_strip_model); DCHECK(tab_index); for (BrowserList::const_iterator it = BrowserList::begin(); it != BrowserList::end(); ++it) { TabStripModel* tab_strip = (*it)->tabstrip_model(); - int index = tab_strip->GetWrapperIndex(tab_contents); + int index = tab_strip->GetWrapperIndex(web_contents); if (index != -1) { *tab_strip_model = tab_strip; *tab_index = index; diff --git a/chrome/browser/extensions/extension_tab_util.h b/chrome/browser/extensions/extension_tab_util.h index 385f6ad..0dd9274 100644 --- a/chrome/browser/extensions/extension_tab_util.h +++ b/chrome/browser/extensions/extension_tab_util.h @@ -33,23 +33,24 @@ class ExtensionTabUtil { int argument_index, int *tab_id, std::string* error_message); static std::string GetTabStatusText(bool is_loading); - static int GetWindowIdOfTab(const TabContents* tab_contents); + static int GetWindowIdOfTab(const content::WebContents* web_contents); static std::string GetWindowTypeText(const Browser* browser); static std::string GetWindowShowStateText(const Browser* browser); static base::ListValue* CreateTabList(const Browser* browser); static base::DictionaryValue* CreateTabValue( - const TabContents* tab_contents); - static base::DictionaryValue* CreateTabValue(const TabContents* tab_contents, - TabStripModel* tab_strip, - int tab_index); + const content::WebContents* web_contents); + static base::DictionaryValue* CreateTabValue( + const content::WebContents* web_contents, + TabStripModel* tab_strip, + int tab_index); // Create a tab value, overriding its kSelectedKey to the provided boolean. static base::DictionaryValue* CreateTabValueActive( - const TabContents* tab_contents, + const content::WebContents* web_contents, bool active); static base::DictionaryValue* CreateWindowValue(const Browser* browser, bool populate_tabs); - // Gets the |tab_strip_model| and |tab_index| for the given |tab_contents|. - static bool GetTabStripModel(const TabContents* tab_contents, + // Gets the |tab_strip_model| and |tab_index| for the given |web_contents|. + static bool GetTabStripModel(const content::WebContents* web_contents, TabStripModel** tab_strip_model, int* tab_index); static bool GetDefaultTab(Browser* browser, diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index d0ae2b0..97ffa2d 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -60,6 +60,8 @@ namespace keys = extension_tabs_module_constants; namespace errors = extension_manifest_errors; +using content::WebContents; + const int CaptureVisibleTabFunction::kDefaultQuality = 90; namespace { @@ -965,7 +967,7 @@ bool GetTabFunction::RunImpl() { bool GetCurrentTabFunction::RunImpl() { DCHECK(dispatcher()); - TabContents* contents = dispatcher()->delegate()->GetAssociatedTabContents(); + WebContents* contents = dispatcher()->delegate()->GetAssociatedWebContents(); if (contents) result_.reset(ExtensionTabUtil::CreateTabValue(contents)); diff --git a/chrome/browser/extensions/extension_webnavigation_api.cc b/chrome/browser/extensions/extension_webnavigation_api.cc index eb647e3..a74d742 100644 --- a/chrome/browser/extensions/extension_webnavigation_api.cc +++ b/chrome/browser/extensions/extension_webnavigation_api.cc @@ -20,10 +20,11 @@ #include "chrome/common/chrome_notification_types.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/public/browser/navigation_details.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/web_contents.h" #include "net/base/net_errors.h" namespace keys = extension_webnavigation_api_constants; @@ -380,7 +381,7 @@ void ExtensionWebNavigationEventRouter::Init() { content::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); registrar_.Add(this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllSources()); } } @@ -396,11 +397,11 @@ void ExtensionWebNavigationEventRouter::Observe( break; case content::NOTIFICATION_TAB_ADDED: - TabAdded(content::Details<TabContents>(details).ptr()); + TabAdded(content::Details<WebContents>(details).ptr()); break; - case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: - TabDestroyed(content::Source<TabContents>(source).ptr()); + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: + TabDestroyed(content::Source<WebContents>(source).ptr()); break; default: @@ -518,7 +519,7 @@ void ExtensionWebNavigationTabObserver::DidStartProvisionalLoadForFrame( if (!navigation_state_.CanSendEvents(frame_id)) return; DispatchOnBeforeNavigate( - tab_contents(), frame_id, is_main_frame, validated_url); + web_contents(), frame_id, is_main_frame, validated_url); } void ExtensionWebNavigationTabObserver::DidCommitProvisionalLoadForFrame( @@ -542,7 +543,7 @@ void ExtensionWebNavigationTabObserver::DidCommitProvisionalLoadForFrame( if (is_reference_fragment_navigation) { DispatchOnCommitted( keys::kOnReferenceFragmentUpdated, - tab_contents(), + web_contents(), frame_id, is_main_frame, url, @@ -551,7 +552,7 @@ void ExtensionWebNavigationTabObserver::DidCommitProvisionalLoadForFrame( } else { DispatchOnCommitted( keys::kOnCommitted, - tab_contents(), + web_contents(), frame_id, is_main_frame, url, @@ -569,14 +570,14 @@ void ExtensionWebNavigationTabObserver::DidFailProvisionalLoad( return; navigation_state_.SetErrorOccurredInFrame(frame_id); DispatchOnErrorOccurred( - tab_contents(), validated_url, frame_id, is_main_frame, error_code); + web_contents(), validated_url, frame_id, is_main_frame, error_code); } void ExtensionWebNavigationTabObserver::DocumentLoadedInFrame( int64 frame_id) { if (!navigation_state_.CanSendEvents(frame_id)) return; - DispatchOnDOMContentLoaded(tab_contents(), + DispatchOnDOMContentLoaded(web_contents(), navigation_state_.GetUrl(frame_id), navigation_state_.IsMainFrame(frame_id), frame_id); @@ -591,7 +592,7 @@ void ExtensionWebNavigationTabObserver::DidFinishLoad( navigation_state_.SetNavigationCompleted(frame_id); DCHECK_EQ(navigation_state_.GetUrl(frame_id), validated_url); DCHECK_EQ(navigation_state_.IsMainFrame(frame_id), is_main_frame); - DispatchOnCompleted(tab_contents(), + DispatchOnCompleted(web_contents(), validated_url, is_main_frame, frame_id); @@ -618,7 +619,7 @@ void ExtensionWebNavigationTabObserver::DidOpenRequestedURL( return; DispatchOnCreatedNavigationTarget( - tab_contents(), + web_contents(), new_contents->GetBrowserContext(), source_frame_id, navigation_state_.IsMainFrame(source_frame_id), @@ -676,9 +677,9 @@ bool GetFrameFunction::RunImpl() { return true; } - TabContents* tab_contents = wrapper->tab_contents(); + WebContents* web_contents = wrapper->web_contents(); ExtensionWebNavigationTabObserver* observer = - ExtensionWebNavigationTabObserver::Get(tab_contents); + ExtensionWebNavigationTabObserver::Get(web_contents); DCHECK(observer); const FrameNavigationState& frame_navigation_state = @@ -719,9 +720,9 @@ bool GetAllFramesFunction::RunImpl() { return true; } - TabContents* tab_contents = wrapper->tab_contents(); + WebContents* web_contents = wrapper->web_contents(); ExtensionWebNavigationTabObserver* observer = - ExtensionWebNavigationTabObserver::Get(tab_contents); + ExtensionWebNavigationTabObserver::Get(web_contents); DCHECK(observer); const FrameNavigationState& navigation_state = diff --git a/chrome/browser/extensions/extension_webnavigation_api.h b/chrome/browser/extensions/extension_webnavigation_api.h index 9d184f1..1fc7047 100644 --- a/chrome/browser/extensions/extension_webnavigation_api.h +++ b/chrome/browser/extensions/extension_webnavigation_api.h @@ -212,7 +212,7 @@ class ExtensionWebNavigationEventRouter : public content::NotificationObserver { // of such an event and creates a JSON formated extension event from it. void TabAdded(content::WebContents* tab); - // Handler for NOTIFICATION_TAB_CONTENTS_DESTROYED. If |tab| is in + // Handler for NOTIFICATION_WEB_CONTENTS_DESTROYED. If |tab| is in // |pending_web_contents_|, it is removed. void TabDestroyed(content::WebContents* tab); diff --git a/chrome/browser/extensions/extension_webstore_private_api.cc b/chrome/browser/extensions/extension_webstore_private_api.cc index 85c6c38..4bc5285 100644 --- a/chrome/browser/extensions/extension_webstore_private_api.cc +++ b/chrome/browser/extensions/extension_webstore_private_api.cc @@ -371,7 +371,7 @@ bool CompleteInstallFunction::RunImpl() { // permissions install dialog. scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( profile(), test_webstore_installer_delegate, - &(dispatcher()->delegate()->GetAssociatedTabContents()->GetController()), + &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), id, WebstoreInstaller::FLAG_NONE); installer->Start(); @@ -426,7 +426,7 @@ void SilentlyInstallFunction::OnWebstoreParseSuccess( scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( profile(), this, - &(dispatcher()->delegate()->GetAssociatedTabContents()->GetController()), + &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), id_, WebstoreInstaller::FLAG_NONE); installer->Start(); } diff --git a/chrome/browser/extensions/webstore_inline_installer.cc b/chrome/browser/extensions/webstore_inline_installer.cc index b58a652..95056c2 100644 --- a/chrome/browser/extensions/webstore_inline_installer.cc +++ b/chrome/browser/extensions/webstore_inline_installer.cc @@ -18,8 +18,8 @@ #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/url_pattern.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/utility_process_host.h" +#include "content/public/browser/web_contents.h" #include "content/public/common/url_fetcher.h" #include "net/base/escape.h" #include "net/base/load_flags.h" @@ -174,7 +174,7 @@ void WebstoreInlineInstaller::BeginInstall() { webstore_data_url_fetcher_.reset(content::URLFetcher::Create( webstore_data_url, content::URLFetcher::GET, this)); Profile* profile = Profile::FromBrowserContext( - tab_contents()->GetBrowserContext()); + web_contents()->GetBrowserContext()); webstore_data_url_fetcher_->SetRequestContext( profile->GetRequestContext()); // Use the requesting page as the referrer both since that is more correct @@ -192,7 +192,7 @@ void WebstoreInlineInstaller::OnURLFetchComplete( CHECK_EQ(webstore_data_url_fetcher_.get(), source); // We shouldn't be getting UrlFetcher callbacks if the WebContents has gone // away; we stop any in in-progress fetches in WebContentsDestroyed. - CHECK(tab_contents()); + CHECK(web_contents()); if (!webstore_data_url_fetcher_->GetStatus().is_success() || webstore_data_url_fetcher_->GetResponseCode() != 200) { @@ -214,7 +214,7 @@ void WebstoreInlineInstaller::OnURLFetchComplete( void WebstoreInlineInstaller::OnWebstoreResponseParseSuccess( DictionaryValue* webstore_data) { // Check if the tab has gone away in the meantime. - if (!tab_contents()) { + if (!web_contents()) { CompleteInstall(""); return; } @@ -238,9 +238,9 @@ void WebstoreInlineInstaller::OnWebstoreResponseParseSuccess( return; } - tab_contents()->OpenURL(OpenURLParams( + web_contents()->OpenURL(OpenURLParams( GURL(redirect_url), - content::Referrer(tab_contents()->GetURL(), + content::Referrer(web_contents()->GetURL(), WebKit::WebReferrerPolicyDefault), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_AUTO_BOOKMARK, @@ -320,7 +320,7 @@ void WebstoreInlineInstaller::OnWebstoreResponseParseSuccess( manifest, "", // We don't have any icon data. icon_url, - Profile::FromBrowserContext(tab_contents()->GetBrowserContext())-> + Profile::FromBrowserContext(web_contents()->GetBrowserContext())-> GetRequestContext()); // The helper will call us back via OnWebstoreParseSucces or // OnWebstoreParseFailure. @@ -337,7 +337,7 @@ void WebstoreInlineInstaller::OnWebstoreParseSuccess( const SkBitmap& icon, base::DictionaryValue* manifest) { // Check if the tab has gone away in the meantime. - if (!tab_contents()) { + if (!web_contents()) { CompleteInstall(""); return; } @@ -347,7 +347,7 @@ void WebstoreInlineInstaller::OnWebstoreParseSuccess( icon_ = icon; Profile* profile = Profile::FromBrowserContext( - tab_contents()->GetBrowserContext()); + web_contents()->GetBrowserContext()); ExtensionInstallUI::Prompt prompt(ExtensionInstallUI::INLINE_INSTALL_PROMPT); prompt.SetInlineInstallWebstoreData(localized_user_count_, @@ -379,7 +379,7 @@ void WebstoreInlineInstaller::OnWebstoreParseFailure( void WebstoreInlineInstaller::InstallUIProceed() { // Check if the tab has gone away in the meantime. - if (!tab_contents()) { + if (!web_contents()) { CompleteInstall(""); return; } @@ -392,10 +392,10 @@ void WebstoreInlineInstaller::InstallUIProceed() { CrxInstaller::SetWhitelistEntry(id_, entry); Profile* profile = Profile::FromBrowserContext( - tab_contents()->GetBrowserContext()); + web_contents()->GetBrowserContext()); scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( - profile, this, &(tab_contents()->GetController()), id_, + profile, this, &(web_contents()->GetController()), id_, WebstoreInstaller::FLAG_INLINE_INSTALL); installer->Start(); } @@ -426,7 +426,7 @@ void WebstoreInlineInstaller::OnExtensionInstallFailure( void WebstoreInlineInstaller::CompleteInstall(const std::string& error) { // Only bother responding if there's still a tab contents to send back the // response to. - if (tab_contents()) { + if (web_contents()) { if (error.empty()) { delegate_->OnInlineInstallSuccess(install_id_); } else { diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index aee37e5..81301aa 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -65,6 +65,7 @@ #include "ui/views/layout/grid_layout.h" using content::BrowserThread; +using content::WebContents; using ui::ViewProp; using WebKit::WebCString; using WebKit::WebString; @@ -133,6 +134,10 @@ TabContents* ExternalTabContainer::tab_contents() const { return tab_contents_.get() ? tab_contents_->tab_contents() : NULL; } +WebContents * ExternalTabContainer::web_contents() const { + return tab_contents(); +} + bool ExternalTabContainer::Init(Profile* profile, HWND parent, const gfx::Rect& bounds, diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h index a07db59..df3d7d0 100644 --- a/chrome/browser/external_tab_container_win.h +++ b/chrome/browser/external_tab_container_win.h @@ -62,6 +62,7 @@ class ExternalTabContainer : public content::WebContentsDelegate, AutomationResourceMessageFilter* filter); TabContents* tab_contents() const; + content::WebContents* web_contents() const; TabContentsWrapper* tab_contents_wrapper() { return tab_contents_.get(); } // Temporary hack so we can send notifications back diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc index 3e59fbb..282cf1c 100644 --- a/chrome/browser/favicon/favicon_tab_helper.cc +++ b/chrome/browser/favicon/favicon_tab_helper.cc @@ -20,6 +20,8 @@ #include "ui/gfx/codec/png_codec.h" #include "ui/gfx/image/image.h" +using content::WebContents; + FaviconTabHelper::FaviconTabHelper(TabContents* tab_contents) : content::WebContentsObserver(tab_contents), profile_(Profile::FromBrowserContext(tab_contents->GetBrowserContext())) { @@ -42,7 +44,7 @@ void FaviconTabHelper::FetchFavicon(const GURL& url) { SkBitmap FaviconTabHelper::GetFavicon() const { // Like GetTitle(), we also want to use the favicon for the last committed // entry rather than a pending navigation entry. - const NavigationController& controller = tab_contents()->GetController(); + const NavigationController& controller = web_contents()->GetController(); NavigationEntry* entry = controller.GetTransientEntry(); if (entry) return entry->favicon().bitmap(); @@ -54,7 +56,7 @@ SkBitmap FaviconTabHelper::GetFavicon() const { } bool FaviconTabHelper::FaviconIsValid() const { - const NavigationController& controller = tab_contents()->GetController(); + const NavigationController& controller = web_contents()->GetController(); NavigationEntry* entry = controller.GetTransientEntry(); if (entry) return entry->favicon().is_valid(); @@ -68,18 +70,18 @@ bool FaviconTabHelper::FaviconIsValid() const { bool FaviconTabHelper::ShouldDisplayFavicon() { // Always display a throbber during pending loads. - const NavigationController& controller = tab_contents()->GetController(); + const NavigationController& controller = web_contents()->GetController(); if (controller.GetLastCommittedEntry() && controller.pending_entry()) return true; - WebUI* web_ui = tab_contents()->GetWebUIForCurrentState(); + WebUI* web_ui = web_contents()->GetWebUIForCurrentState(); if (web_ui) return !web_ui->hide_favicon(); return true; } void FaviconTabHelper::SaveFavicon() { - NavigationEntry* entry = tab_contents()->GetController().GetActiveEntry(); + NavigationEntry* entry = web_contents()->GetController().GetActiveEntry(); if (!entry || entry->GetURL().is_empty()) return; @@ -128,11 +130,11 @@ void FaviconTabHelper::OnUpdateFaviconURL( } NavigationEntry* FaviconTabHelper::GetActiveEntry() { - return tab_contents()->GetController().GetActiveEntry(); + return web_contents()->GetController().GetActiveEntry(); } void FaviconTabHelper::StartDownload(int id, const GURL& url, int image_size) { - RenderViewHost* host = tab_contents()->GetRenderViewHost(); + RenderViewHost* host = web_contents()->GetRenderViewHost(); host->Send(new IconMsg_DownloadFavicon( host->routing_id(), id, url, image_size)); } @@ -140,9 +142,9 @@ void FaviconTabHelper::StartDownload(int id, const GURL& url, int image_size) { void FaviconTabHelper::NotifyFaviconUpdated() { content::NotificationService::current()->Notify( chrome::NOTIFICATION_FAVICON_UPDATED, - content::Source<TabContents>(tab_contents()), + content::Source<WebContents>(web_contents()), content::NotificationService::NoDetails()); - tab_contents()->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB); + web_contents()->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB); } void FaviconTabHelper::NavigateToPendingEntry( diff --git a/chrome/browser/file_select_helper.cc b/chrome/browser/file_select_helper.cc index d6d73f7..ac4832d 100644 --- a/chrome/browser/file_select_helper.cc +++ b/chrome/browser/file_select_helper.cc @@ -16,7 +16,6 @@ #include "chrome/browser/profiles/profile.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" -#include "content/browser/tab_contents/tab_contents.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "content/public/browser/notification_details.h" @@ -28,6 +27,7 @@ #include "ui/base/l10n/l10n_util.h" using content::BrowserThread; +using content::WebContents; namespace { @@ -74,7 +74,7 @@ struct FileSelectHelper::ActiveDirectoryEnumeration { FileSelectHelper::FileSelectHelper(Profile* profile) : profile_(profile), render_view_host_(NULL), - tab_contents_(NULL), + web_contents_(NULL), select_file_dialog_(), select_file_types_(), dialog_type_(SelectFileDialog::SELECT_OPEN_FILE) { @@ -263,19 +263,19 @@ SelectFileDialog::FileTypeInfo* FileSelectHelper::GetFileTypesFromAcceptType( void FileSelectHelper::RunFileChooser( RenderViewHost* render_view_host, - TabContents* tab_contents, + content::WebContents* web_contents, const content::FileChooserParams& params) { DCHECK(!render_view_host_); - DCHECK(!tab_contents_); + DCHECK(!web_contents_); render_view_host_ = render_view_host; - tab_contents_ = tab_contents; + web_contents_ = web_contents; notification_registrar_.RemoveAll(); notification_registrar_.Add( this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, content::Source<RenderWidgetHost>(render_view_host_)); notification_registrar_.Add( - this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents_)); + this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents_)); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, @@ -301,7 +301,7 @@ void FileSelectHelper::RunFileChooserOnFileThread( void FileSelectHelper::RunFileChooserOnUIThread( const content::FileChooserParams& params) { - if (!render_view_host_ || !tab_contents_) { + if (!render_view_host_ || !web_contents_) { // If the renderer was destroyed before we started, just cancel the // operation. RunFileChooserEnd(); @@ -342,7 +342,7 @@ void FileSelectHelper::RunFileChooserOnUIThread( select_file_types_.get(), select_file_types_.get() ? 1 : 0, // 1-based index. FILE_PATH_LITERAL(""), - tab_contents_, + web_contents_, owning_window, NULL); @@ -354,7 +354,7 @@ void FileSelectHelper::RunFileChooserOnUIThread( // in RunFileChooser(). void FileSelectHelper::RunFileChooserEnd() { render_view_host_ = NULL; - tab_contents_ = NULL; + web_contents_ = NULL; Release(); } @@ -390,9 +390,9 @@ void FileSelectHelper::Observe(int type, break; } - case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: { - DCHECK(content::Source<TabContents>(source).ptr() == tab_contents_); - tab_contents_ = NULL; + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { + DCHECK(content::Source<WebContents>(source).ptr() == web_contents_); + web_contents_ = NULL; break; } diff --git a/chrome/browser/file_select_helper.h b/chrome/browser/file_select_helper.h index 714ee7b..5b58ecb 100644 --- a/chrome/browser/file_select_helper.h +++ b/chrome/browser/file_select_helper.h @@ -34,7 +34,7 @@ class FileSelectHelper // Show the file chooser dialog. void RunFileChooser(RenderViewHost* render_view_host, - TabContents* tab_contents, + content::WebContents* tab_contents, const content::FileChooserParams& params); // Enumerates all the files in directory. @@ -116,10 +116,10 @@ class FileSelectHelper // Profile used to set/retrieve the last used directory. Profile* profile_; - // The RenderViewHost and TabContents for the page showing a file dialog + // The RenderViewHost and WebContents for the page showing a file dialog // (may only be one such dialog). RenderViewHost* render_view_host_; - TabContents* tab_contents_; + content::WebContents* web_contents_; // Dialog box used for choosing files to upload from file form fields. scoped_refptr<SelectFileDialog> select_file_dialog_; diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc index 3879c47..b9f4552 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc @@ -40,6 +40,7 @@ #include "ui/base/resource/resource_bundle.h" using content::BrowserThread; +using content::WebContents; using WebKit::WebSecurityOrigin; // GeolocationInfoBarQueueController ------------------------------------------ @@ -175,7 +176,7 @@ GeolocationConfirmInfoBarDelegate::GeolocationConfirmInfoBarDelegate( requesting_frame_url_(requesting_frame_url), display_languages_(display_languages) { const NavigationEntry* committed_entry = - infobar_helper->tab_contents()->GetController().GetLastCommittedEntry(); + infobar_helper->web_contents()->GetController().GetLastCommittedEntry(); committed_contents_unique_id_ = committed_entry ? committed_entry->GetUniqueID() : 0; } @@ -218,13 +219,14 @@ string16 GeolocationConfirmInfoBarDelegate::GetButtonLabel( bool GeolocationConfirmInfoBarDelegate::Accept() { controller_->OnPermissionSet(render_process_id_, render_view_id_, bridge_id_, - requesting_frame_url_, owner()->tab_contents()->GetURL(), true); + requesting_frame_url_, owner()->web_contents()->GetURL(), true); return true; } bool GeolocationConfirmInfoBarDelegate::Cancel() { controller_->OnPermissionSet(render_process_id_, render_view_id_, bridge_id_, - requesting_frame_url_, owner()->tab_contents()->GetURL(), false); + requesting_frame_url_, owner()->web_contents()->GetURL(), + false); return true; } @@ -241,7 +243,7 @@ bool GeolocationConfirmInfoBarDelegate::LinkClicked( "https://www.google.com/support/chrome/bin/answer.py?answer=142065"; #endif - owner()->tab_contents()->OpenURL( + owner()->web_contents()->OpenURL( google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), GURL(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK); @@ -458,13 +460,13 @@ void GeolocationInfoBarQueueController::OnPermissionSet( void GeolocationInfoBarQueueController::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, + registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, source); - TabContents* tab_contents = content::Source<TabContents>(source).ptr(); + WebContents* web_contents = content::Source<WebContents>(source).ptr(); for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin(); i != pending_infobar_requests_.end();) { if (i->infobar_delegate == NULL && - tab_contents == tab_util::GetTabContentsByID(i->render_process_id, + web_contents == tab_util::GetTabContentsByID(i->render_process_id, i->render_view_id)) { i = pending_infobar_requests_.erase(i); } else { @@ -490,10 +492,10 @@ void GeolocationInfoBarQueueController::ShowQueuedInfoBar(int render_process_id, if (!i->infobar_delegate) { if (!registrar_.IsRegistered( - this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents))) { - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents)); + this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab_contents))) { + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab_contents)); } i->infobar_delegate = new GeolocationConfirmInfoBarDelegate( wrapper->infobar_tab_helper(), this, render_process_id, @@ -576,8 +578,7 @@ void ChromeGeolocationPermissionContext::RequestGeolocationPermission( TabContents* tab_contents = tab_util::GetTabContentsByID(render_process_id, render_view_id); - if (!tab_contents || - tab_contents->GetRenderViewHost()->delegate()->GetRenderViewType() != + if (!tab_contents || tab_contents->GetViewType() != content::VIEW_TYPE_TAB_CONTENTS) { // The tab may have gone away, or the request may not be from a tab at all. // TODO(mpcomplete): the request could be from a background page or diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index 7ad2f62..293f99f 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.cc @@ -72,7 +72,7 @@ string16 GoogleURLTrackerInfoBarDelegate::GetLinkText() const { bool GoogleURLTrackerInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { - owner()->tab_contents()->OpenURL(google_util::AppendGoogleLocaleParam(GURL( + owner()->web_contents()->OpenURL(google_util::AppendGoogleLocaleParam(GURL( "https://www.google.com/support/chrome/bin/answer.py?answer=1618699")), GURL(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK); diff --git a/chrome/browser/history/history_tab_helper.cc b/chrome/browser/history/history_tab_helper.cc index e797cc3..f986502 100644 --- a/chrome/browser/history/history_tab_helper.cc +++ b/chrome/browser/history/history_tab_helper.cc @@ -48,7 +48,7 @@ HistoryTabHelper::CreateHistoryAddPageArgs( const content::FrameNavigateParams& params) { scoped_refptr<history::HistoryAddPageArgs> add_page_args( new history::HistoryAddPageArgs( - params.url, base::Time::Now(), tab_contents(), params.page_id, + params.url, base::Time::Now(), web_contents(), params.page_id, params.referrer.url, params.redirects, params.transition, history::SOURCE_BROWSED, details.did_replace_entry)); if (content::PageTransitionIsMainFrame(params.transition) && @@ -97,9 +97,9 @@ void HistoryTabHelper::DidNavigateAnyFrame( // about: URL to the history db and keep the data: URL hidden. This is what // the TabContents' URL getter does. scoped_refptr<history::HistoryAddPageArgs> add_page_args( - CreateHistoryAddPageArgs(tab_contents()->GetURL(), details, params)); - if (!tab_contents()->GetDelegate() || - !tab_contents()->GetDelegate()->ShouldAddNavigationToHistory( + CreateHistoryAddPageArgs(web_contents()->GetURL(), details, params)); + if (!web_contents()->GetDelegate() || + !web_contents()->GetDelegate()->ShouldAddNavigationToHistory( *add_page_args, details.type)) return; @@ -147,7 +147,7 @@ void HistoryTabHelper::OnThumbnail(const GURL& url, const ThumbnailScore& score, const SkBitmap& bitmap) { Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); if (profile->IsOffTheRecord()) return; @@ -161,7 +161,7 @@ void HistoryTabHelper::OnThumbnail(const GURL& url, HistoryService* HistoryTabHelper::GetHistoryService() { Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); if (profile->IsOffTheRecord()) return NULL; diff --git a/chrome/browser/infobars/infobar_delegate.cc b/chrome/browser/infobars/infobar_delegate.cc index 754577d..9622d35 100644 --- a/chrome/browser/infobars/infobar_delegate.cc +++ b/chrome/browser/infobars/infobar_delegate.cc @@ -8,8 +8,8 @@ #include "build/build_config.h" #include "chrome/browser/infobars/infobar_tab_helper.h" #include "content/browser/tab_contents/navigation_entry.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/navigation_details.h" +#include "content/public/browser/web_contents.h" // InfoBarDelegate ------------------------------------------------------------ @@ -84,7 +84,7 @@ InfoBarDelegate::InfoBarDelegate(InfoBarTabHelper* infobar_helper) void InfoBarDelegate::StoreActiveEntryUniqueID( InfoBarTabHelper* infobar_helper) { NavigationEntry* active_entry = - infobar_helper->tab_contents()->GetController().GetActiveEntry(); + infobar_helper->web_contents()->GetController().GetActiveEntry(); contents_unique_id_ = active_entry ? active_entry->GetUniqueID() : 0; } diff --git a/chrome/browser/infobars/infobar_tab_helper.cc b/chrome/browser/infobars/infobar_tab_helper.cc index 12fa355..ec9cad6 100644 --- a/chrome/browser/infobars/infobar_tab_helper.cc +++ b/chrome/browser/infobars/infobar_tab_helper.cc @@ -56,7 +56,7 @@ void InfoBarTabHelper::AddInfoBar(InfoBarDelegate* delegate) { registrar_.Add( this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>( - &tab_contents()->GetController())); + &web_contents()->GetController())); } } @@ -122,7 +122,7 @@ void InfoBarTabHelper::RemoveInfoBarInternal(InfoBarDelegate* delegate, registrar_.Remove( this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>( - &tab_contents()->GetController())); + &web_contents()->GetController())); } } @@ -179,7 +179,7 @@ void InfoBarTabHelper::Observe(int type, const content::NotificationDetails& details) { switch (type) { case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { - DCHECK(&tab_contents()->GetController() == + DCHECK(&web_contents()->GetController() == content::Source<NavigationController>(source).ptr()); content::LoadCommittedDetails& committed_details = diff --git a/chrome/browser/infobars/infobar_tab_helper.h b/chrome/browser/infobars/infobar_tab_helper.h index 133a341..f4e78f1 100644 --- a/chrome/browser/infobars/infobar_tab_helper.h +++ b/chrome/browser/infobars/infobar_tab_helper.h @@ -58,8 +58,8 @@ class InfoBarTabHelper : public content::WebContentsObserver, const content::NotificationDetails& details) OVERRIDE; // Helper functions for infobars: - TabContents* tab_contents() { - return content::WebContentsObserver::tab_contents(); + content::WebContents* web_contents() { + return content::WebContentsObserver::web_contents(); } private: diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc index 19c2552..517e7db3 100644 --- a/chrome/browser/notifications/balloon_host.cc +++ b/chrome/browser/notifications/balloon_host.cc @@ -51,7 +51,7 @@ gfx::NativeView BalloonHost::GetNativeViewOfHost() { return NULL; } -TabContents* BalloonHost::GetAssociatedTabContents() const { +content::WebContents* BalloonHost::GetAssociatedWebContents() const { return NULL; } diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h index 8a51a68..6c8e0cd 100644 --- a/chrome/browser/notifications/balloon_host.h +++ b/chrome/browser/notifications/balloon_host.h @@ -36,7 +36,7 @@ class BalloonHost : public content::WebContentsDelegate, // ExtensionFunctionDispatcher::Delegate overrides. virtual Browser* GetBrowser() OVERRIDE; virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; - virtual TabContents* GetAssociatedTabContents() const OVERRIDE; + virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; const string16& GetSource() const; diff --git a/chrome/browser/plugin_installer_infobar_delegate.cc b/chrome/browser/plugin_installer_infobar_delegate.cc index 01f054b..daaf1b9 100644 --- a/chrome/browser/plugin_installer_infobar_delegate.cc +++ b/chrome/browser/plugin_installer_infobar_delegate.cc @@ -73,7 +73,7 @@ bool PluginInstallerInfoBarDelegate::LinkClicked( url = google_util::AppendGoogleLocaleParam(GURL( "https://www.google.com/support/chrome/bin/answer.py?answer=142064")); } - owner()->tab_contents()->OpenURL( + owner()->web_contents()->OpenURL( url, GURL(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK); diff --git a/chrome/browser/plugin_observer.cc b/chrome/browser/plugin_observer.cc index 0ddab66..726355a 100644 --- a/chrome/browser/plugin_observer.cc +++ b/chrome/browser/plugin_observer.cc @@ -73,7 +73,7 @@ bool PluginInfoBarDelegate::Cancel() { } bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { - owner()->tab_contents()->OpenURL( + owner()->web_contents()->OpenURL( google_util::AppendGoogleLocaleParam(GURL(GetLearnMoreURL())), GURL(), (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, content::PAGE_TRANSITION_LINK); @@ -167,8 +167,8 @@ bool BlockedPluginInfoBarDelegate::Accept() { bool BlockedPluginInfoBarDelegate::Cancel() { content::RecordAction( UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); - content_settings_->AddExceptionForURL(owner()->tab_contents()->GetURL(), - owner()->tab_contents()->GetURL(), + content_settings_->AddExceptionForURL(owner()->web_contents()->GetURL(), + owner()->web_contents()->GetURL(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), CONTENT_SETTING_ALLOW); @@ -260,7 +260,7 @@ string16 OutdatedPluginInfoBarDelegate::GetButtonLabel( bool OutdatedPluginInfoBarDelegate::Accept() { content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update")); - owner()->tab_contents()->OpenURL(update_url_, GURL(), NEW_FOREGROUND_TAB, + owner()->web_contents()->OpenURL(update_url_, GURL(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); return false; } diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index d26ce9e..678c413 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -50,6 +50,7 @@ using content::DevToolsAgentHost; using content::DevToolsAgentHostRegistry; using content::DevToolsClientHost; using content::DevToolsManager; +using content::WebContents; // Prerender tests work as follows: // @@ -1744,7 +1745,7 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderFavicon) { ASSERT_TRUE(prerender_contents != NULL); ui_test_utils::WindowedNotificationObserver favicon_update_watcher( chrome::NOTIFICATION_FAVICON_UPDATED, - content::Source<TabContents>(prerender_contents->prerender_contents()-> + content::Source<WebContents>(prerender_contents->prerender_contents()-> tab_contents())); NavigateToDestURL(); favicon_update_watcher.Wait(); diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc index 282cf79..218eb4b 100644 --- a/chrome/browser/prerender/prerender_manager.cc +++ b/chrome/browser/prerender/prerender_manager.cc @@ -50,6 +50,7 @@ #include "content/public/browser/web_contents_delegate.h" using content::BrowserThread; +using content::WebContents; namespace prerender { @@ -520,9 +521,9 @@ void PrerenderManager::DeleteOldEntries() { MaybeStopSchedulingPeriodicCleanups(); } -PrerenderContents* PrerenderManager::GetEntryButNotSpecifiedTC( +PrerenderContents* PrerenderManager::GetEntryButNotSpecifiedWC( const GURL& url, - TabContents *tc) { + WebContents* wc) { DCHECK(CalledOnValidThread()); DeleteOldEntries(); DeletePendingDeleteEntries(); @@ -532,8 +533,8 @@ PrerenderContents* PrerenderManager::GetEntryButNotSpecifiedTC( PrerenderContents* prerender_contents = it->contents_; if (prerender_contents->MatchesURL(url, NULL)) { if (!prerender_contents->prerender_contents() || - !tc || - prerender_contents->prerender_contents()->tab_contents() != tc) { + !wc || + prerender_contents->prerender_contents()->tab_contents() != wc) { prerender_list_.erase(it); return prerender_contents; } @@ -544,17 +545,17 @@ PrerenderContents* PrerenderManager::GetEntryButNotSpecifiedTC( } PrerenderContents* PrerenderManager::GetEntry(const GURL& url) { - return GetEntryButNotSpecifiedTC(url, NULL); + return GetEntryButNotSpecifiedWC(url, NULL); } -bool PrerenderManager::MaybeUsePrerenderedPage(TabContents* tab_contents, +bool PrerenderManager::MaybeUsePrerenderedPage(WebContents* web_contents, const GURL& url, const GURL& opener_url) { DCHECK(CalledOnValidThread()); RecordNavigation(url); scoped_ptr<PrerenderContents> prerender_contents( - GetEntryButNotSpecifiedTC(url, tab_contents)); + GetEntryButNotSpecifiedWC(url, web_contents)); if (prerender_contents.get() == NULL) return false; @@ -578,22 +579,22 @@ bool PrerenderManager::MaybeUsePrerenderedPage(TabContents* tab_contents, } // If we are just in the control group (which can be detected by noticing - // that prerendering hasn't even started yet), record that |tab_contents| now + // that prerendering hasn't even started yet), record that |web_contents| now // would be showing a prerendered contents, but otherwise, don't do anything. if (!prerender_contents->prerendering_has_started()) { - MarkTabContentsAsWouldBePrerendered(tab_contents); + MarkWebContentsAsWouldBePrerendered(web_contents); return false; } if (prerender_contents->starting_page_id() <= - tab_contents->GetMaxPageID()) { + web_contents->GetMaxPageID()) { prerender_contents.release()->Destroy(FINAL_STATUS_PAGE_ID_CONFLICT); return false; } // Don't use prerendered pages if debugger is attached to the tab. // See http://crbug.com/98541 - if (content::DevToolsAgentHostRegistry::IsDebuggerAttached(tab_contents)) { + if (content::DevToolsAgentHostRegistry::IsDebuggerAttached(web_contents)) { prerender_contents.release()->Destroy(FINAL_STATUS_DEVTOOLS_ATTACHED); return false; } @@ -607,7 +608,7 @@ bool PrerenderManager::MaybeUsePrerenderedPage(TabContents* tab_contents, } // If the session storage namespaces don't match, cancel the prerender. - RenderViewHost* old_render_view_host = tab_contents->GetRenderViewHost(); + RenderViewHost* old_render_view_host = web_contents->GetRenderViewHost(); RenderViewHost* new_render_view_host = prerender_contents->prerender_contents()->tab_contents()-> GetRenderViewHost(); @@ -624,7 +625,7 @@ bool PrerenderManager::MaybeUsePrerenderedPage(TabContents* tab_contents, // For bookkeeping purposes, we need to mark this TabContents to // reflect that it would have been prerendered. if (GetMode() == PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP) { - MarkTabContentsAsWouldBePrerendered(tab_contents); + MarkWebContentsAsWouldBePrerendered(web_contents); prerender_contents.release()->Destroy(FINAL_STATUS_NO_USE_GROUP); return false; } @@ -656,11 +657,11 @@ bool PrerenderManager::MaybeUsePrerenderedPage(TabContents* tab_contents, TabContentsWrapper* new_tab_contents = prerender_contents->ReleasePrerenderContents(); TabContentsWrapper* old_tab_contents = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents); DCHECK(new_tab_contents); DCHECK(old_tab_contents); - MarkTabContentsAsPrerendered(new_tab_contents->tab_contents()); + MarkWebContentsAsPrerendered(new_tab_contents->tab_contents()); // Merge the browsing history. new_tab_contents->tab_contents()->GetController().CopyStateFromAndPrune( @@ -809,20 +810,20 @@ void PrerenderManager::DeletePendingDeleteEntries() { // static void PrerenderManager::RecordPerceivedPageLoadTime( base::TimeDelta perceived_page_load_time, - TabContents* tab_contents, + WebContents* web_contents, const GURL& url) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); PrerenderManager* prerender_manager = PrerenderManagerFactory::GetForProfile( - Profile::FromBrowserContext(tab_contents->GetBrowserContext())); + Profile::FromBrowserContext(web_contents->GetBrowserContext())); if (!prerender_manager) return; if (!prerender_manager->is_enabled()) return; bool was_prerender = - prerender_manager->IsTabContentsPrerendered(tab_contents); + prerender_manager->IsWebContentsPrerendered(web_contents); bool was_complete_prerender = was_prerender || - prerender_manager->WouldTabContentsBePrerendered(tab_contents); + prerender_manager->WouldWebContentsBePrerendered(web_contents); prerender_manager->histograms_->RecordPerceivedPageLoadTime( perceived_page_load_time, was_prerender, was_complete_prerender, url); } @@ -951,8 +952,8 @@ void PrerenderManager::PostCleanupTask() { weak_factory_.GetWeakPtr())); } -bool PrerenderManager::IsTabContentsPrerendering( - TabContents* tab_contents) const { +bool PrerenderManager::IsWebContentsPrerendering( + WebContents* web_contents) const { DCHECK(CalledOnValidThread()); for (std::list<PrerenderContentsData>::const_iterator it = prerender_list_.begin(); @@ -961,7 +962,7 @@ bool PrerenderManager::IsTabContentsPrerendering( TabContentsWrapper* prerender_tab_contents_wrapper = it->contents_->prerender_contents(); if (prerender_tab_contents_wrapper && - prerender_tab_contents_wrapper->tab_contents() == tab_contents) { + prerender_tab_contents_wrapper->tab_contents() == web_contents) { return true; } } @@ -974,41 +975,41 @@ bool PrerenderManager::IsTabContentsPrerendering( TabContentsWrapper* prerender_tab_contents_wrapper = (*it)->prerender_contents(); if (prerender_tab_contents_wrapper && - prerender_tab_contents_wrapper->tab_contents() == tab_contents) + prerender_tab_contents_wrapper->tab_contents() == web_contents) return true; } return false; } -void PrerenderManager::MarkTabContentsAsPrerendered(TabContents* tab_contents) { +void PrerenderManager::MarkWebContentsAsPrerendered(WebContents* web_contents) { DCHECK(CalledOnValidThread()); - prerendered_tab_contents_set_.insert(tab_contents); + prerendered_tab_contents_set_.insert(web_contents); } -void PrerenderManager::MarkTabContentsAsWouldBePrerendered( - TabContents* tab_contents) { +void PrerenderManager::MarkWebContentsAsWouldBePrerendered( + WebContents* web_contents) { DCHECK(CalledOnValidThread()); - would_be_prerendered_tab_contents_set_.insert(tab_contents); + would_be_prerendered_tab_contents_set_.insert(web_contents); } -void PrerenderManager::MarkTabContentsAsNotPrerendered( - TabContents* tab_contents) { +void PrerenderManager::MarkWebContentsAsNotPrerendered( + WebContents* web_contents) { DCHECK(CalledOnValidThread()); - prerendered_tab_contents_set_.erase(tab_contents); - would_be_prerendered_tab_contents_set_.erase(tab_contents); + prerendered_tab_contents_set_.erase(web_contents); + would_be_prerendered_tab_contents_set_.erase(web_contents); } -bool PrerenderManager::IsTabContentsPrerendered( - TabContents* tab_contents) const { +bool PrerenderManager::IsWebContentsPrerendered( + content::WebContents* web_contents) const { DCHECK(CalledOnValidThread()); - return prerendered_tab_contents_set_.count(tab_contents) > 0; + return prerendered_tab_contents_set_.count(web_contents) > 0; } -bool PrerenderManager::WouldTabContentsBePrerendered( - TabContents* tab_contents) const { +bool PrerenderManager::WouldWebContentsBePrerendered( + WebContents* web_contents) const { DCHECK(CalledOnValidThread()); - return would_be_prerendered_tab_contents_set_.count(tab_contents) > 0; + return would_be_prerendered_tab_contents_set_.count(web_contents) > 0; } bool PrerenderManager::HasRecentlyBeenNavigatedTo(const GURL& url) { diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h index c1a0904..e823f9b 100644 --- a/chrome/browser/prerender/prerender_manager.h +++ b/chrome/browser/prerender/prerender_manager.h @@ -32,12 +32,16 @@ namespace base { class DictionaryValue; } +namespace content { +class WebContents; +} + #if defined(COMPILER_GCC) namespace __gnu_cxx { template <> -struct hash<TabContents*> { - std::size_t operator()(TabContents* value) const { +struct hash<content::WebContents*> { + std::size_t operator()(content::WebContents* value) const { return reinterpret_cast<std::size_t>(value); } }; @@ -118,13 +122,13 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, // Cancels all active prerenders. void CancelAllPrerenders(); - // For a given TabContents that wants to navigate to the URL supplied, + // For a given WebContents that wants to navigate to the URL supplied, // determines whether a prerendered version of the URL can be used, - // and substitutes the prerendered RVH into the TabContents. |opener_url| is - // set to the window.opener url that the TabContents should have set and + // and substitutes the prerendered RVH into the WebContents. |opener_url| is + // set to the window.opener url that the WebContents should have set and // will be empty if there is no opener set. Returns whether or not a // prerendered RVH could be used or not. - bool MaybeUsePrerenderedPage(TabContents* tab_contents, + bool MaybeUsePrerenderedPage(content::WebContents* web_contents, const GURL& url, const GURL& opener_url); @@ -139,7 +143,7 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, // This must be called on the UI thread. static void RecordPerceivedPageLoadTime( base::TimeDelta perceived_page_load_time, - TabContents* tab_contents, + content::WebContents* web_contents, const GURL& url); // Returns whether prerendering is currently enabled for this manager. @@ -159,17 +163,17 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, static bool IsControlGroup(); static bool IsNoUseGroup(); - // Query the list of current prerender pages to see if the given tab contents + // Query the list of current prerender pages to see if the given web contents // is prerendering a page. - bool IsTabContentsPrerendering(TabContents* tab_contents) const; + bool IsWebContentsPrerendering(content::WebContents* web_contents) const; - // Maintaining and querying the set of TabContents belonging to this + // Maintaining and querying the set of WebContents belonging to this // PrerenderManager that are currently showing prerendered pages. - void MarkTabContentsAsPrerendered(TabContents* tab_contents); - void MarkTabContentsAsWouldBePrerendered(TabContents* tab_contents); - void MarkTabContentsAsNotPrerendered(TabContents* tab_contents); - bool IsTabContentsPrerendered(TabContents* tab_contents) const; - bool WouldTabContentsBePrerendered(TabContents* tab_contents) const; + void MarkWebContentsAsPrerendered(content::WebContents* web_contents); + void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents); + void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); + bool IsWebContentsPrerendered(content::WebContents* web_contents) const; + bool WouldWebContentsBePrerendered(content::WebContents* web_contents) const; bool IsOldRenderViewHost(const RenderViewHost* render_view_host) const; // Checks whether navigation to the provided URL has occurred in a visible @@ -279,11 +283,11 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, PrerenderContents* GetEntry(const GURL& url); // Identical to GetEntry, with one exception: - // The TabContents specified indicates the TC in which to swap the - // prerendering into. If the TabContents specified is the one + // The WebContents specified indicates the WC in which to swap the + // prerendering into. If the WebContents specified is the one // to doing the prerendered itself, will return NULL. - PrerenderContents* GetEntryButNotSpecifiedTC(const GURL& url, - TabContents* tc); + PrerenderContents* GetEntryButNotSpecifiedWC(const GURL& url, + content::WebContents* wc); // Starts scheduling periodic cleanups. void StartSchedulingPeriodicCleanups(); @@ -389,11 +393,11 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, std::list<PrerenderContents*> pending_delete_list_; // Set of TabContents which are currently displaying a prerendered page. - base::hash_set<TabContents*> prerendered_tab_contents_set_; + base::hash_set<content::WebContents*> prerendered_tab_contents_set_; // Set of TabContents which would be displaying a prerendered page // (for the control group). - base::hash_set<TabContents*> would_be_prerendered_tab_contents_set_; + base::hash_set<content::WebContents*> would_be_prerendered_tab_contents_set_; scoped_ptr<PrerenderContents::Factory> prerender_contents_factory_; diff --git a/chrome/browser/prerender/prerender_tab_helper.cc b/chrome/browser/prerender/prerender_tab_helper.cc index 9e3107d..09e6337 100644 --- a/chrome/browser/prerender/prerender_tab_helper.cc +++ b/chrome/browser/prerender/prerender_tab_helper.cc @@ -189,9 +189,9 @@ void PrerenderTabHelper::ProvisionalChangeToMainFrameUrl( PrerenderManager* prerender_manager = MaybeGetPrerenderManager(); if (!prerender_manager) return; - if (prerender_manager->IsTabContentsPrerendering(tab_contents())) + if (prerender_manager->IsWebContentsPrerendering(web_contents())) return; - prerender_manager->MarkTabContentsAsNotPrerendered(tab_contents()); + prerender_manager->MarkWebContentsAsNotPrerendered(web_contents()); MaybeUsePrerenderedPage(url, opener_url); } @@ -213,7 +213,7 @@ void PrerenderTabHelper::DidStopLoading() { // Compute the PPLT metric and report it in a histogram, if needed. if (!pplt_load_start_.is_null() && !IsPrerendering()) { PrerenderManager::RecordPerceivedPageLoadTime( - base::TimeTicks::Now() - pplt_load_start_, tab_contents(), url_); + base::TimeTicks::Now() - pplt_load_start_, web_contents(), url_); } // Reset the PPLT metric. @@ -244,7 +244,7 @@ void PrerenderTabHelper::DidStartProvisionalLoadForFrame( PrerenderManager* PrerenderTabHelper::MaybeGetPrerenderManager() const { return PrerenderManagerFactory::GetForProfile( - Profile::FromBrowserContext(tab_contents()->GetBrowserContext())); + Profile::FromBrowserContext(web_contents()->GetBrowserContext())); } bool PrerenderTabHelper::MaybeUsePrerenderedPage(const GURL& url, @@ -252,8 +252,8 @@ bool PrerenderTabHelper::MaybeUsePrerenderedPage(const GURL& url, PrerenderManager* prerender_manager = MaybeGetPrerenderManager(); if (!prerender_manager) return false; - DCHECK(!prerender_manager->IsTabContentsPrerendering(tab_contents())); - return prerender_manager->MaybeUsePrerenderedPage(tab_contents(), + DCHECK(!prerender_manager->IsWebContentsPrerendering(web_contents())); + return prerender_manager->MaybeUsePrerenderedPage(web_contents(), url, opener_url); } @@ -262,7 +262,7 @@ bool PrerenderTabHelper::IsPrerendering() { PrerenderManager* prerender_manager = MaybeGetPrerenderManager(); if (!prerender_manager) return false; - return prerender_manager->IsTabContentsPrerendering(tab_contents()); + return prerender_manager->IsWebContentsPrerendering(web_contents()); } void PrerenderTabHelper::PrerenderSwappedIn() { @@ -271,7 +271,7 @@ void PrerenderTabHelper::PrerenderSwappedIn() { if (pplt_load_start_.is_null()) { // If we have already finished loading, report a 0 PPLT. PrerenderManager::RecordPerceivedPageLoadTime(base::TimeDelta(), - tab_contents(), url_); + web_contents(), url_); } else { // If we have not finished loading yet, rebase the start time to now. pplt_load_start_ = base::TimeTicks::Now(); diff --git a/chrome/browser/printing/background_printing_manager.cc b/chrome/browser/printing/background_printing_manager.cc index 7547d035..46b076d 100644 --- a/chrome/browser/printing/background_printing_manager.cc +++ b/chrome/browser/printing/background_printing_manager.cc @@ -18,6 +18,7 @@ #include "content/public/browser/notification_source.h" using content::BrowserThread; +using content::WebContents; namespace printing { @@ -48,10 +49,10 @@ void BackgroundPrintingManager::OwnPrintPreviewTab( TabContents* preview_contents = preview_tab->tab_contents(); if (!registrar_.IsRegistered( this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(preview_contents))) { - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(preview_contents)); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(preview_contents))) { + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(preview_contents)); } // If a tab that is printing crashes, the user cannot destroy it since it is @@ -96,10 +97,10 @@ void BackgroundPrintingManager::Observe( OnPrintJobReleased(content::Source<TabContentsWrapper>(source).ptr()); break; } - case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: { + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { OnTabContentsDestroyed( TabContentsWrapper::GetCurrentWrapperForContents( - content::Source<TabContents>(source).ptr())); + content::Source<WebContents>(source).ptr())); break; } default: { @@ -134,8 +135,8 @@ void BackgroundPrintingManager::OnPrintJobReleased( void BackgroundPrintingManager::OnTabContentsDestroyed( TabContentsWrapper* preview_tab) { // Always need to remove this notification since the tab is gone. - registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(preview_tab->tab_contents())); + registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(preview_tab->tab_contents())); if (!HasPrintPreviewTab(preview_tab)) { NOTREACHED(); diff --git a/chrome/browser/printing/print_preview_message_handler.cc b/chrome/browser/printing/print_preview_message_handler.cc index f3c316a..99fd50c 100644 --- a/chrome/browser/printing/print_preview_message_handler.cc +++ b/chrome/browser/printing/print_preview_message_handler.cc @@ -81,7 +81,7 @@ TabContentsWrapper* PrintPreviewMessageHandler::GetPrintPreviewTab() { } TabContentsWrapper* PrintPreviewMessageHandler::tab_contents_wrapper() { - return TabContentsWrapper::GetCurrentWrapperForContents(tab_contents()); + return TabContentsWrapper::GetCurrentWrapperForContents(web_contents()); } PrintPreviewUI* PrintPreviewMessageHandler::OnFailure(int document_cookie) { diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc index 3dcc4b1..84dad6e 100644 --- a/chrome/browser/printing/print_preview_tab_controller.cc +++ b/chrome/browser/printing/print_preview_tab_controller.cc @@ -36,6 +36,8 @@ #include "content/public/browser/notification_types.h" #include "webkit/plugins/webplugininfo.h" +using content::WebContents; + namespace { void EnableInternalPDFPluginForTab(TabContentsWrapper* preview_tab) { @@ -208,8 +210,8 @@ void PrintPreviewTabController::Observe( content::Source<content::RenderProcessHost>(source).ptr()); break; } - case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: { - TabContents* tab = content::Source<TabContents>(source).ptr(); + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { + WebContents* tab = content::Source<WebContents>(source).ptr(); TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents(tab); OnTabContentsDestroyed(wrapper); @@ -406,8 +408,8 @@ void PrintPreviewTabController::SetInitiatorTabURLAndTitle( void PrintPreviewTabController::AddObservers(TabContentsWrapper* tab) { TabContents* contents = tab->tab_contents(); - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(contents)); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(contents)); registrar_.Add( this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>(&contents->GetController())); @@ -426,8 +428,8 @@ void PrintPreviewTabController::AddObservers(TabContentsWrapper* tab) { void PrintPreviewTabController::RemoveObservers(TabContentsWrapper* tab) { TabContents* contents = tab->tab_contents(); - registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(contents)); + registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(contents)); registrar_.Remove( this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>(&contents->GetController())); diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index 5dbd665..aaa5af3 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -140,9 +140,9 @@ void PrintViewManager::PrintPreviewDone() { } void PrintViewManager::PreviewPrintingRequestCancelled() { - if (!tab_contents()) + if (!web_contents()) return; - RenderViewHost* rvh = tab_contents()->GetRenderViewHost(); + RenderViewHost* rvh = web_contents()->GetRenderViewHost(); rvh->Send(new PrintMsg_PreviewPrintingRequestCancelled(rvh->routing_id())); } @@ -170,7 +170,7 @@ void PrintViewManager::RenderViewGone(base::TerminationStatus status) { } string16 PrintViewManager::RenderSourceName() { - string16 name(tab_contents()->GetTitle()); + string16 name(web_contents()->GetTitle()); if (name.empty()) name = l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE); return name; @@ -211,7 +211,7 @@ void PrintViewManager::OnDidPrintPage( if (params.data_size && params.data_size >= 350*1024*1024) { NOTREACHED() << "size:" << params.data_size; TerminatePrintJob(true); - tab_contents()->Stop(); + web_contents()->Stop(); return; } #endif @@ -227,7 +227,7 @@ void PrintViewManager::OnDidPrintPage( if (metafile_must_be_valid) { if (!shared_buf.Map(params.data_size)) { NOTREACHED() << "couldn't map"; - tab_contents()->Stop(); + web_contents()->Stop(); return; } } @@ -236,7 +236,7 @@ void PrintViewManager::OnDidPrintPage( if (metafile_must_be_valid) { if (!metafile->InitFromData(shared_buf.memory(), params.data_size)) { NOTREACHED() << "Invalid metafile header"; - tab_contents()->Stop(); + web_contents()->Stop(); return; } } @@ -256,7 +256,7 @@ void PrintViewManager::OnPrintingFailed(int cookie) { content::NotificationService::current()->Notify( chrome::NOTIFICATION_PRINT_JOB_RELEASED, - content::Source<TabContents>(tab_contents()), + content::Source<TabContentsWrapper>(tab_), content::NotificationService::NoDetails()); } @@ -265,7 +265,7 @@ void PrintViewManager::OnScriptedPrintPreview(bool source_is_modifiable, BrowserThread::CurrentlyOn(BrowserThread::UI); ScriptedPrintPreviewClosureMap& map = g_scripted_print_preview_closure_map.Get(); - content::RenderProcessHost* rph = tab_contents()->GetRenderProcessHost(); + content::RenderProcessHost* rph = web_contents()->GetRenderProcessHost(); // This should always be 0 once we get modal window.print(). if (map.count(rph) != 0) { @@ -393,9 +393,9 @@ bool PrintViewManager::RenderAllMissingPagesNow() { return false; // We can't print if there is no renderer. - if (!tab_contents() || - !tab_contents()->GetRenderViewHost() || - !tab_contents()->GetRenderViewHost()->IsRenderViewLive()) { + if (!web_contents() || + !web_contents()->GetRenderViewHost() || + !web_contents()->GetRenderViewHost()->IsRenderViewLive()) { return false; } @@ -444,8 +444,8 @@ bool PrintViewManager::CreateNewPrintJob(PrintJobWorkerOwner* job) { DisconnectFromCurrentPrintJob(); // We can't print if there is no renderer. - if (!tab_contents()->GetRenderViewHost() || - !tab_contents()->GetRenderViewHost()->IsRenderViewLive()) { + if (!web_contents()->GetRenderViewHost() || + !web_contents()->GetRenderViewHost()->IsRenderViewLive()) { return false; } @@ -486,9 +486,9 @@ void PrintViewManager::DisconnectFromCurrentPrintJob() { } void PrintViewManager::PrintingDone(bool success) { - if (!print_job_.get() || !tab_contents()) + if (!print_job_.get() || !web_contents()) return; - RenderViewHost* rvh = tab_contents()->GetRenderViewHost(); + RenderViewHost* rvh = web_contents()->GetRenderViewHost(); rvh->Send(new PrintMsg_PrintingDone(rvh->routing_id(), success)); } @@ -594,7 +594,7 @@ bool PrintViewManager::OpportunisticallyCreatePrintJob(int cookie) { bool PrintViewManager::PrintNowInternal(IPC::Message* message) { // Don't print / print preview interstitials. - if (tab_contents()->ShowingInterstitialPage()) + if (web_contents()->ShowingInterstitialPage()) return false; return Send(message); } diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index 5be29d0..7883184 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -42,6 +42,8 @@ #include "chrome/browser/chromeos/boot_times_loader.h" #endif +using content::WebContents; + // Are we in the process of restoring? static bool restoring = false; @@ -248,14 +250,14 @@ void TabLoader::Observe(int type, render_widget_hosts_loading_.insert(render_widget_host); break; } - case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: { - TabContents* tab_contents = content::Source<TabContents>(source).ptr(); + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { + WebContents* web_contents = content::Source<WebContents>(source).ptr(); if (!got_first_paint_) { RenderWidgetHost* render_widget_host = - GetRenderWidgetHost(&tab_contents->GetController()); + GetRenderWidgetHost(&web_contents->GetController()); render_widget_hosts_loading_.erase(render_widget_host); } - HandleTabClosedOrLoaded(&tab_contents->GetController()); + HandleTabClosedOrLoaded(&web_contents->GetController()); break; } case content::NOTIFICATION_LOAD_STOP: { @@ -326,8 +328,8 @@ void TabLoader::OnOnlineStateChanged(bool online) { } void TabLoader::RemoveTab(NavigationController* tab) { - registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab->tab_contents())); + registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab->tab_contents())); registrar_.Remove(this, content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>(tab)); registrar_.Remove(this, content::NOTIFICATION_LOAD_START, @@ -360,8 +362,8 @@ RenderWidgetHost* TabLoader::GetRenderWidgetHost(NavigationController* tab) { } void TabLoader::RegisterForNotifications(NavigationController* controller) { - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(controller->tab_contents())); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(controller->tab_contents())); registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>(controller)); registrar_.Add(this, content::NOTIFICATION_LOAD_START, diff --git a/chrome/browser/sidebar/sidebar_manager.cc b/chrome/browser/sidebar/sidebar_manager.cc index caf9e8e..07271d0 100644 --- a/chrome/browser/sidebar/sidebar_manager.cc +++ b/chrome/browser/sidebar/sidebar_manager.cc @@ -17,6 +17,8 @@ #include "content/public/browser/notification_service.h" #include "googleurl/src/gurl.h" +using content::WebContents; + struct SidebarManager::SidebarStateForTab { // Sidebars linked to this tab. ContentIdToSidebarHostMap content_id_to_sidebar_host; @@ -52,7 +54,7 @@ SidebarContainer* SidebarManager::GetActiveSidebarContainerFor( } SidebarContainer* SidebarManager::GetSidebarContainerFor( - TabContents* tab, const std::string& content_id) { + WebContents* tab, const std::string& content_id) { DCHECK(!content_id.empty()); TabToSidebarHostMap::iterator it = tab_to_sidebar_host_.find(tab); if (it == tab_to_sidebar_host_.end()) @@ -165,7 +167,7 @@ void SidebarManager::CollapseSidebar(TabContents* tab, host->Collapse(); } -void SidebarManager::HideSidebar(TabContents* tab, +void SidebarManager::HideSidebar(WebContents* tab, const std::string& content_id) { DCHECK(!content_id.empty()); TabToSidebarHostMap::iterator it = tab_to_sidebar_host_.find(tab); @@ -231,8 +233,8 @@ SidebarManager::~SidebarManager() { void SidebarManager::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - if (type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED) { - HideAllSidebars(content::Source<TabContents>(source).ptr()); + if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { + HideAllSidebars(content::Source<WebContents>(source).ptr()); } else { NOTREACHED() << "Got a notification we didn't register for!"; } @@ -245,7 +247,7 @@ void SidebarManager::UpdateSidebar(SidebarContainer* host) { content::Details<SidebarContainer>(host)); } -void SidebarManager::HideAllSidebars(TabContents* tab) { +void SidebarManager::HideAllSidebars(WebContents* tab) { TabToSidebarHostMap::iterator tab_it = tab_to_sidebar_host_.find(tab); if (tab_it == tab_to_sidebar_host_.end()) return; @@ -276,21 +278,21 @@ SidebarContainer* SidebarManager::FindSidebarContainerFor( } void SidebarManager::RegisterSidebarContainerFor( - TabContents* tab, SidebarContainer* sidebar_host) { + WebContents* tab, SidebarContainer* sidebar_host) { DCHECK(!GetSidebarContainerFor(tab, sidebar_host->content_id())); // If it's a first sidebar for this tab, register destroy notification. if (tab_to_sidebar_host_.find(tab) == tab_to_sidebar_host_.end()) { registrar_.Add(this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab)); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab)); } BindSidebarHost(tab, sidebar_host); } void SidebarManager::UnregisterSidebarContainerFor( - TabContents* tab, const std::string& content_id) { + WebContents* tab, const std::string& content_id) { SidebarContainer* host = GetSidebarContainerFor(tab, content_id); DCHECK(host); if (!host) @@ -301,8 +303,8 @@ void SidebarManager::UnregisterSidebarContainerFor( // If there's no more sidebars linked to this tab, unsubscribe. if (tab_to_sidebar_host_.find(tab) == tab_to_sidebar_host_.end()) { registrar_.Remove(this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab)); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab)); } // Issue tab closing event post unbound. @@ -311,7 +313,7 @@ void SidebarManager::UnregisterSidebarContainerFor( delete host; } -void SidebarManager::BindSidebarHost(TabContents* tab, +void SidebarManager::BindSidebarHost(WebContents* tab, SidebarContainer* sidebar_host) { const std::string& content_id = sidebar_host->content_id(); @@ -324,7 +326,7 @@ void SidebarManager::BindSidebarHost(TabContents* tab, sidebar_host_to_tab_[sidebar_host] = tab; } -void SidebarManager::UnbindSidebarHost(TabContents* tab, +void SidebarManager::UnbindSidebarHost(WebContents* tab, SidebarContainer* sidebar_host) { const std::string& content_id = sidebar_host->content_id(); diff --git a/chrome/browser/sidebar/sidebar_manager.h b/chrome/browser/sidebar/sidebar_manager.h index ea44564..f059347 100644 --- a/chrome/browser/sidebar/sidebar_manager.h +++ b/chrome/browser/sidebar/sidebar_manager.h @@ -19,6 +19,10 @@ class SidebarContainer; class SkBitmap; class TabContents; +namespace content { +class WebContents; +} + /////////////////////////////////////////////////////////////////////////////// // SidebarManager // @@ -43,7 +47,7 @@ class SidebarManager : public content::NotificationObserver, // Returns SidebarContainer registered for |tab| and |content_id| or NULL if // there is no such SidebarContainer registered. - SidebarContainer* GetSidebarContainerFor(TabContents* tab, + SidebarContainer* GetSidebarContainerFor(content::WebContents* tab, const std::string& content_id); // Returns sidebar's TabContents registered for |tab| and |content_id|. @@ -69,7 +73,7 @@ class SidebarManager : public content::NotificationObserver, // Hides sidebar identified by |tab| and |content_id| (removes sidebar's // mini tab). - void HideSidebar(TabContents* tab, const std::string& content_id); + void HideSidebar(content::WebContents* tab, const std::string& content_id); // Navigates sidebar identified by |tab| and |content_id| to |url|. void NavigateSidebar(TabContents* tab, @@ -105,25 +109,27 @@ class SidebarManager : public content::NotificationObserver, virtual void UpdateSidebar(SidebarContainer* host) OVERRIDE; // Hides all sidebars registered for |tab|. - void HideAllSidebars(TabContents* tab); + void HideAllSidebars(content::WebContents* tab); // Returns SidebarContainer corresponding to |sidebar_contents|. SidebarContainer* FindSidebarContainerFor(TabContents* sidebar_contents); // Registers new SidebarContainer for |tab|. There must be no // other SidebarContainers registered for the RenderViewHost at the moment. - void RegisterSidebarContainerFor(TabContents* tab, + void RegisterSidebarContainerFor(content::WebContents* tab, SidebarContainer* container); // Unregisters SidebarContainer identified by |tab| and |content_id|. - void UnregisterSidebarContainerFor(TabContents* tab, + void UnregisterSidebarContainerFor(content::WebContents* tab, const std::string& content_id); // Records the link between |tab| and |sidebar_host|. - void BindSidebarHost(TabContents* tab, SidebarContainer* sidebar_host); + void BindSidebarHost(content::WebContents* tab, + SidebarContainer* sidebar_host); // Forgets the link between |tab| and |sidebar_host|. - void UnbindSidebarHost(TabContents* tab, SidebarContainer* sidebar_host); + void UnbindSidebarHost(content::WebContents* tab, + SidebarContainer* sidebar_host); content::NotificationRegistrar registrar_; @@ -137,10 +143,12 @@ class SidebarManager : public content::NotificationObserver, // SidebarManager start listening to SidebarContainers when they are put // into these maps and removes them when they are closing. struct SidebarStateForTab; - typedef std::map<TabContents*, SidebarStateForTab> TabToSidebarHostMap; + typedef std::map<content::WebContents*, SidebarStateForTab> + TabToSidebarHostMap; TabToSidebarHostMap tab_to_sidebar_host_; - typedef std::map<SidebarContainer*, TabContents*> SidebarHostToTabMap; + typedef std::map<SidebarContainer*, content::WebContents*> + SidebarHostToTabMap; SidebarHostToTabMap sidebar_host_to_tab_; DISALLOW_COPY_AND_ASSIGN(SidebarManager); diff --git a/chrome/browser/speech/speech_input_bubble_controller.cc b/chrome/browser/speech/speech_input_bubble_controller.cc index f71f742..d7a87e8 100644 --- a/chrome/browser/speech/speech_input_bubble_controller.cc +++ b/chrome/browser/speech/speech_input_bubble_controller.cc @@ -14,6 +14,7 @@ #include "ui/gfx/rect.h" using content::BrowserThread; +using content::WebContents; namespace speech_input { @@ -112,11 +113,11 @@ void SpeechInputBubbleController::UpdateTabContentsSubscription( } if (action == BUBBLE_ADDED) { - registrar_->Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents)); + registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab_contents)); } else { - registrar_->Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents)); + registrar_->Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab_contents)); } } @@ -124,12 +125,12 @@ void SpeechInputBubbleController::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - if (type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED) { + if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { // Cancel all bubbles and active recognition sessions for this tab. - TabContents* tab_contents = content::Source<TabContents>(source).ptr(); + WebContents* web_contents = content::Source<WebContents>(source).ptr(); BubbleCallerIdMap::iterator iter = bubbles_.begin(); while (iter != bubbles_.end()) { - if (iter->second->tab_contents() == tab_contents) { + if (iter->second->tab_contents() == web_contents) { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( &SpeechInputBubbleController::InvokeDelegateButtonClicked, diff --git a/chrome/browser/sync/glue/session_change_processor.cc b/chrome/browser/sync/glue/session_change_processor.cc index cee05f9..a80a1a9 100644 --- a/chrome/browser/sync/glue/session_change_processor.cc +++ b/chrome/browser/sync/glue/session_change_processor.cc @@ -164,7 +164,7 @@ void SessionChangeProcessor::Observe( ExtensionTabHelper* extension_tab_helper = content::Source<ExtensionTabHelper>(source).ptr(); if (!extension_tab_helper || - extension_tab_helper->tab_contents()->GetBrowserContext() != + extension_tab_helper->web_contents()->GetBrowserContext() != profile_) { return; } diff --git a/chrome/browser/tab_contents/insecure_content_infobar_delegate.cc b/chrome/browser/tab_contents/insecure_content_infobar_delegate.cc index 9c3be0a..18b1632 100644 --- a/chrome/browser/tab_contents/insecure_content_infobar_delegate.cc +++ b/chrome/browser/tab_contents/insecure_content_infobar_delegate.cc @@ -78,7 +78,7 @@ string16 InsecureContentInfoBarDelegate::GetLinkText() const { bool InsecureContentInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { - owner()->tab_contents()->OpenURL(OpenURLParams( + owner()->web_contents()->OpenURL(OpenURLParams( google_util::AppendGoogleLocaleParam(GURL( "https://www.google.com/support/chrome/bin/answer.py?answer=1342714")), content::Referrer(), diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc index c29f585..86280cf 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -163,7 +163,7 @@ TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow( prerender::PrerenderManager* prerender_manager = prerender::PrerenderManagerFactory::GetForProfile(profile); if (prerender_manager && - prerender_manager->IsTabContentsPrerendering(base_tab_contents)) { + prerender_manager->IsWebContentsPrerendering(base_tab_contents)) { return NULL; } diff --git a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc index 8b0d2e5..3a42b7a 100644 --- a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc +++ b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc @@ -26,6 +26,7 @@ #include "chrome/common/chrome_switches.h" #include "content/browser/ssl/ssl_client_auth_handler.h" #include "content/browser/tab_contents/tab_contents.h" +#include "content/browser/tab_contents/tab_contents_view.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" #include "grit/generated_resources.h" @@ -98,7 +99,8 @@ string16 SSLCertAddedInfoBarDelegate::GetButtonLabel( } bool SSLCertAddedInfoBarDelegate::Accept() { - ShowCertificateViewer(owner()->tab_contents()->GetDialogRootWindow(), cert_); + ShowCertificateViewer( + owner()->web_contents()->GetView()->GetTopLevelNativeWindow(), cert_); return false; // Hiding the infobar just as the dialog opens looks weird. } diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index b58cf7b..9c8ba6b 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -34,6 +34,7 @@ #include "content/public/browser/web_contents_delegate.h" using content::UserMetricsAction; +using content::WebContents; namespace { @@ -69,7 +70,7 @@ TabStripModel::TabStripModel(TabStripModelDelegate* delegate, Profile* profile) order_controller_(NULL) { DCHECK(delegate_); registrar_.Add(this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllBrowserContextsAndSources()); registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, @@ -374,7 +375,7 @@ int TabStripModel::GetIndexOfTabContents( return kNoTab; } -int TabStripModel::GetWrapperIndex(const TabContents* contents) const { +int TabStripModel::GetWrapperIndex(const WebContents* contents) const { int index = 0; TabContentsDataVector::const_iterator iter = contents_data_.begin(); for (; iter != contents_data_.end(); ++iter, ++index) { @@ -1001,11 +1002,11 @@ void TabStripModel::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { switch (type) { - case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: { + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { // Sometimes, on qemu, it seems like a TabContents object can be destroyed // while we still have a reference to it. We need to break this reference // here so we don't crash later. - int index = GetWrapperIndex(content::Source<TabContents>(source).ptr()); + int index = GetWrapperIndex(content::Source<WebContents>(source).ptr()); if (index != TabStripModel::kNoTab) { // Note that we only detach the contents here, not close it - it's // already been closed. We just want to undo our bookkeeping. diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h index 6ed57f1..4ef4c75 100644 --- a/chrome/browser/tabs/tab_strip_model.h +++ b/chrome/browser/tabs/tab_strip_model.h @@ -22,6 +22,10 @@ class TabContentsWrapper; class TabStripModelDelegate; class TabStripModelOrderController; +namespace content { +class WebContents; +} + //////////////////////////////////////////////////////////////////////////////// // // TabStripModel @@ -262,13 +266,13 @@ class TabStripModel : public content::NotificationObserver { // TabStripModel::kNoTab if the TabContents is not in this TabStripModel. int GetIndexOfTabContents(const TabContentsWrapper* contents) const; - // Returns the index of the specified TabContents wrapper given its raw - // TabContents, or TabStripModel::kNoTab if the TabContents is not in this + // Returns the index of the specified WebContents wrapper given its raw + // WebContents, or TabStripModel::kNoTab if the TabContents is not in this // TabStripModel. Note: This is only needed in rare cases where the wrapper // is not already present (such as implementing WebContentsDelegate methods, // which don't know about the wrapper. Returns NULL if |contents| is not // associated with any wrapper in the model. - int GetWrapperIndex(const TabContents* contents) const; + int GetWrapperIndex(const content::WebContents* contents) const; // Returns the index of the specified NavigationController, or kNoTab if it is // not in this TabStripModel. diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index b592a34..140bcc7 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -41,6 +41,7 @@ #include "testing/gtest/include/gtest/gtest.h" using content::BrowserThread; +using content::WebContents; using testing::_; namespace { @@ -54,8 +55,8 @@ class DeleteTabContentsOnDestroyedObserver : source_(source), tab_to_delete_(tab_to_delete) { registrar_.Add(this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(source->tab_contents())); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(source->tab_contents())); } virtual void Observe(int type, diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc index fc3ab53..1c54df5 100644 --- a/chrome/browser/task_manager/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager/task_manager_resource_providers.cc @@ -66,6 +66,7 @@ #endif // defined(OS_WIN) using content::BrowserThread; +using content::WebContents; namespace { @@ -251,7 +252,7 @@ bool TaskManagerTabContentsResource::IsPrerendering() const { prerender::PrerenderManagerFactory::GetForProfile( tab_contents_->profile()); return prerender_manager && - prerender_manager->IsTabContentsPrerendering( + prerender_manager->IsWebContentsPrerendering( tab_contents_->tab_contents()); } @@ -395,7 +396,7 @@ void TaskManagerTabContentsResourceProvider::StartUpdating() { // resource. This is an attempt at mitigating a crasher that seem to // indicate a resource is still referencing a deleted TabContents // (http://crbug.com/7321). - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllBrowserContextsAndSources()); registrar_.Add(this, chrome::NOTIFICATION_INSTANT_COMMITTED, content::NotificationService::AllBrowserContextsAndSources()); @@ -416,7 +417,7 @@ void TaskManagerTabContentsResourceProvider::StopUpdating() { this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED, content::NotificationService::AllBrowserContextsAndSources()); registrar_.Remove( - this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, + this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, content::NotificationService::AllBrowserContextsAndSources()); registrar_.Remove( this, chrome::NOTIFICATION_INSTANT_COMMITTED, @@ -499,6 +500,10 @@ void TaskManagerTabContentsResourceProvider::Observe(int type, TabContentsWrapper* tab_contents; if (type == chrome::NOTIFICATION_INSTANT_COMMITTED) { tab_contents = content::Source<TabContentsWrapper>(source).ptr(); + } else if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { + WebContents* web_contents = content::Source<WebContents>(source).ptr(); + tab_contents = TabContentsWrapper::GetCurrentWrapperForContents( + web_contents); } else { tab_contents = TabContentsWrapper::GetCurrentWrapperForContents( content::Source<TabContents>(source).ptr()); @@ -514,7 +519,7 @@ void TaskManagerTabContentsResourceProvider::Observe(int type, Remove(tab_contents); Add(tab_contents); break; - case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: // If this DCHECK is triggered, it could explain http://crbug.com/7321 . DCHECK(resources_.find(tab_contents) == resources_.end()) << "TAB_CONTENTS_DESTROYED with no associated " diff --git a/chrome/browser/translate/options_menu_model.cc b/chrome/browser/translate/options_menu_model.cc index ed0b568..fcf5097 100644 --- a/chrome/browser/translate/options_menu_model.cc +++ b/chrome/browser/translate/options_menu_model.cc @@ -10,11 +10,13 @@ #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/translate/translate_infobar_delegate.h" -#include "content/browser/tab_contents/tab_contents.h" +#include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "ui/base/l10n/l10n_util.h" +using content::WebContents; + namespace { const char kAboutGoogleTranslateUrl[] = @@ -37,7 +39,7 @@ OptionsMenuModel::OptionsMenuModel( // Populate the menu. // Incognito mode does not get any preferences related items. - if (!translate_delegate->owner()->tab_contents()-> + if (!translate_delegate->owner()->web_contents()-> GetBrowserContext()->IsOffTheRecord()) { AddCheckItem(IDC_TRANSLATE_OPTIONS_ALWAYS, l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_ALWAYS, @@ -94,9 +96,9 @@ bool OptionsMenuModel::IsCommandIdEnabled(int command_id) const { // we don't report errors that happened on secure URLs. DCHECK(translate_infobar_delegate_ != NULL); DCHECK(translate_infobar_delegate_->owner() != NULL); - DCHECK(translate_infobar_delegate_->owner()->tab_contents() != NULL); + DCHECK(translate_infobar_delegate_->owner()->web_contents() != NULL); NavigationEntry* entry = translate_infobar_delegate_->owner()-> - tab_contents()->GetController().GetActiveEntry(); + web_contents()->GetController().GetActiveEntry(); // Delegate and tab contents should never be NULL, but active entry // can be NULL when running tests. We want to return false if NULL. return (entry != NULL) && !entry->GetURL().SchemeIsSecure(); @@ -134,12 +136,12 @@ void OptionsMenuModel::ExecuteCommand(int command_id) { break; case IDC_TRANSLATE_OPTIONS_ABOUT: { - TabContents* tab_contents = - translate_infobar_delegate_->owner()->tab_contents(); - if (tab_contents) { + WebContents* web_contents = + translate_infobar_delegate_->owner()->web_contents(); + if (web_contents) { GURL about_url = google_util::AppendGoogleLocaleParam( GURL(kAboutGoogleTranslateUrl)); - tab_contents->OpenURL( + web_contents->OpenURL( about_url, GURL(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); } diff --git a/chrome/browser/translate/translate_infobar_delegate.cc b/chrome/browser/translate/translate_infobar_delegate.cc index 0a00819..1fd2271 100644 --- a/chrome/browser/translate/translate_infobar_delegate.cc +++ b/chrome/browser/translate/translate_infobar_delegate.cc @@ -111,29 +111,29 @@ void TranslateInfoBarDelegate::SetTargetLanguage(size_t language_index) { void TranslateInfoBarDelegate::Translate() { const std::string& original_language_code = GetOriginalLanguageCode(); - if (!owner()->tab_contents()->GetBrowserContext()->IsOffTheRecord()) { + if (!owner()->web_contents()->GetBrowserContext()->IsOffTheRecord()) { prefs_.ResetTranslationDeniedCount(original_language_code); prefs_.IncrementTranslationAcceptedCount(original_language_code); } - TranslateManager::GetInstance()->TranslatePage(owner()->tab_contents(), + TranslateManager::GetInstance()->TranslatePage(owner()->web_contents(), GetLanguageCodeAt(original_language_index()), GetLanguageCodeAt(target_language_index())); } void TranslateInfoBarDelegate::RevertTranslation() { - TranslateManager::GetInstance()->RevertTranslation(owner()->tab_contents()); + TranslateManager::GetInstance()->RevertTranslation(owner()->web_contents()); RemoveSelf(); } void TranslateInfoBarDelegate::ReportLanguageDetectionError() { TranslateManager::GetInstance()-> - ReportLanguageDetectionError(owner()->tab_contents()); + ReportLanguageDetectionError(owner()->web_contents()); } void TranslateInfoBarDelegate::TranslationDeclined() { const std::string& original_language_code = GetOriginalLanguageCode(); - if (!owner()->tab_contents()->GetBrowserContext()->IsOffTheRecord()) { + if (!owner()->web_contents()->GetBrowserContext()->IsOffTheRecord()) { prefs_.ResetTranslationAcceptedCount(original_language_code); prefs_.IncrementTranslationDeniedCount(original_language_code); } @@ -144,7 +144,7 @@ void TranslateInfoBarDelegate::TranslationDeclined() { // happens when a load stops. That could happen multiple times, including // after the user already declined the translation.) TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( - owner()->tab_contents())->translate_tab_helper(); + owner()->web_contents())->translate_tab_helper(); helper->language_state().set_translation_declined(true); } @@ -260,7 +260,7 @@ void TranslateInfoBarDelegate::MessageInfoBarButtonPressed() { return; } // This is the "Try again..." case. - TranslateManager::GetInstance()->TranslatePage(owner()->tab_contents(), + TranslateManager::GetInstance()->TranslatePage(owner()->web_contents(), GetOriginalLanguageCode(), GetTargetLanguageCode()); } @@ -270,13 +270,13 @@ bool TranslateInfoBarDelegate::ShouldShowMessageInfoBarButton() { bool TranslateInfoBarDelegate::ShouldShowNeverTranslateButton() { DCHECK_EQ(BEFORE_TRANSLATE, type_); - return !owner()->tab_contents()->GetBrowserContext()->IsOffTheRecord() && + return !owner()->web_contents()->GetBrowserContext()->IsOffTheRecord() && (prefs_.GetTranslationDeniedCount(GetOriginalLanguageCode()) >= 3); } bool TranslateInfoBarDelegate::ShouldShowAlwaysTranslateButton() { DCHECK_EQ(BEFORE_TRANSLATE, type_); - return !owner()->tab_contents()->GetBrowserContext()->IsOffTheRecord() && + return !owner()->web_contents()->GetBrowserContext()->IsOffTheRecord() && (prefs_.GetTranslationAcceptedCount(GetOriginalLanguageCode()) >= 3); } @@ -399,6 +399,6 @@ TranslateInfoBarDelegate* std::string TranslateInfoBarDelegate::GetPageHost() { NavigationEntry* entry = - owner()->tab_contents()->GetController().GetActiveEntry(); + owner()->web_contents()->GetController().GetActiveEntry(); return entry ? entry->GetURL().HostNoBrackets() : std::string(); } diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 038cfba..dcbcb63 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -48,6 +48,8 @@ #include "net/url_request/url_request_status.h" #include "ui/base/resource/resource_bundle.h" +using content::WebContents; + namespace { // The list of languages the Google translation server supports. @@ -548,30 +550,30 @@ void TranslateManager::InitiateTranslationPosted( InitiateTranslation(tab, GetLanguageCode(page_lang)); } -void TranslateManager::TranslatePage(TabContents* tab_contents, +void TranslateManager::TranslatePage(WebContents* web_contents, const std::string& source_lang, const std::string& target_lang) { - NavigationEntry* entry = tab_contents->GetController().GetActiveEntry(); + NavigationEntry* entry = web_contents->GetController().GetActiveEntry(); if (!entry) { NOTREACHED(); return; } TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents); InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); - ShowInfoBar(tab_contents, TranslateInfoBarDelegate::CreateDelegate( + ShowInfoBar(web_contents, TranslateInfoBarDelegate::CreateDelegate( TranslateInfoBarDelegate::TRANSLATING, infobar_helper, wrapper->profile()->GetPrefs(), source_lang, target_lang)); if (!translate_script_.empty()) { - DoTranslatePage(tab_contents, translate_script_, source_lang, target_lang); + DoTranslatePage(web_contents, translate_script_, source_lang, target_lang); return; } // The script is not available yet. Queue that request and query for the // script. Once it is downloaded we'll do the translate. - RenderViewHost* rvh = tab_contents->GetRenderViewHost(); + RenderViewHost* rvh = web_contents->GetRenderViewHost(); PendingRequest request; request.render_process_id = rvh->process()->GetID(); request.render_view_id = rvh->routing_id(); @@ -582,24 +584,24 @@ void TranslateManager::TranslatePage(TabContents* tab_contents, RequestTranslateScript(); } -void TranslateManager::RevertTranslation(TabContents* tab_contents) { - NavigationEntry* entry = tab_contents->GetController().GetActiveEntry(); +void TranslateManager::RevertTranslation(WebContents* web_contents) { + NavigationEntry* entry = web_contents->GetController().GetActiveEntry(); if (!entry) { NOTREACHED(); return; } - tab_contents->GetRenderViewHost()->Send(new ChromeViewMsg_RevertTranslation( - tab_contents->GetRenderViewHost()->routing_id(), entry->GetPageID())); + web_contents->GetRenderViewHost()->Send(new ChromeViewMsg_RevertTranslation( + web_contents->GetRenderViewHost()->routing_id(), entry->GetPageID())); TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( - tab_contents)->translate_tab_helper(); + web_contents)->translate_tab_helper(); helper->language_state().set_current_language( helper->language_state().original_language()); } -void TranslateManager::ReportLanguageDetectionError(TabContents* tab_contents) { +void TranslateManager::ReportLanguageDetectionError(WebContents* web_contents) { UMA_HISTOGRAM_COUNTS("Translate.ReportLanguageDetectionError", 1); - GURL page_url = tab_contents->GetController().GetActiveEntry()->GetURL(); + GURL page_url = web_contents->GetController().GetActiveEntry()->GetURL(); // Report option should be disabled for secure URLs. DCHECK(!page_url.SchemeIsSecure()); std::string report_error_url(kReportLanguageDetectionErrorURL); @@ -608,14 +610,14 @@ void TranslateManager::ReportLanguageDetectionError(TabContents* tab_contents) { report_error_url += "&sl="; TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( - tab_contents)->translate_tab_helper(); + web_contents)->translate_tab_helper(); report_error_url += helper->language_state().original_language(); report_error_url += "&hl="; report_error_url += GetLanguageCode(g_browser_process->GetApplicationLocale()); // Open that URL in a new tab so that the user can tell us more. Profile* profile = - Profile::FromBrowserContext(tab_contents->GetBrowserContext()); + Profile::FromBrowserContext(web_contents->GetBrowserContext()); Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser) { NOTREACHED(); @@ -625,7 +627,7 @@ void TranslateManager::ReportLanguageDetectionError(TabContents* tab_contents) { content::PAGE_TRANSITION_AUTO_BOOKMARK); } -void TranslateManager::DoTranslatePage(TabContents* tab, +void TranslateManager::DoTranslatePage(WebContents* tab, const std::string& translate_script, const std::string& source_lang, const std::string& target_lang) { @@ -776,7 +778,7 @@ void TranslateManager::RequestTranslateScript() { translate_script_request_pending_->Start(); } -void TranslateManager::ShowInfoBar(TabContents* tab, +void TranslateManager::ShowInfoBar(content::WebContents* tab, TranslateInfoBarDelegate* infobar) { DCHECK(infobar != NULL); TranslateInfoBarDelegate* old_infobar = GetTranslateInfoBarDelegate(tab); @@ -821,7 +823,7 @@ std::string TranslateManager::GetTargetLanguage(PrefService* prefs) { // static TranslateInfoBarDelegate* TranslateManager::GetTranslateInfoBarDelegate( - TabContents* tab) { + WebContents* tab) { TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents(tab); if (!wrapper) diff --git a/chrome/browser/translate/translate_manager.h b/chrome/browser/translate/translate_manager.h index 60dcb1c..54687a9 100644 --- a/chrome/browser/translate/translate_manager.h +++ b/chrome/browser/translate/translate_manager.h @@ -27,6 +27,10 @@ class PrefService; class TabContents; class TranslateInfoBarDelegate; +namespace content { +class WebContents; +} + // The TranslateManager class is responsible for showing an info-bar when a page // in a language different than the user language is loaded. It triggers the // page translation the user requests. @@ -53,18 +57,18 @@ class TranslateManager : public content::NotificationObserver, // Translates the page contents from |source_lang| to |target_lang|. // The actual translation might be performed asynchronously if the translate // script is not yet available. - void TranslatePage(TabContents* tab_contents, + void TranslatePage(content::WebContents* web_contents, const std::string& source_lang, const std::string& target_lang); - // Reverts the contents of the page in |tab_contents| to its original + // Reverts the contents of the page in |web_contents| to its original // language. - void RevertTranslation(TabContents* tab_contents); + void RevertTranslation(content::WebContents* web_contents); // Reports to the Google translate server that a page language was incorrectly // detected. This call is initiated by the user selecting the "report" menu // under options in the translate infobar. - void ReportLanguageDetectionError(TabContents* tab_contents); + void ReportLanguageDetectionError(content::WebContents* web_contents); // Clears the translate script, so it will be fetched next time we translate. void ClearTranslateScript() { translate_script_.clear(); } @@ -139,7 +143,7 @@ class TranslateManager : public content::NotificationObserver, const std::string& page_lang); // Sends a translation request to the RenderView of |tab_contents|. - void DoTranslatePage(TabContents* tab_contents, + void DoTranslatePage(content::WebContents* web_contents, const std::string& translate_script, const std::string& source_lang, const std::string& target_lang); @@ -161,7 +165,8 @@ class TranslateManager : public content::NotificationObserver, // Shows the specified translate |infobar| in the given |tab|. If a current // translate infobar is showing, it just replaces it with the new one. - void ShowInfoBar(TabContents* tab, TranslateInfoBarDelegate* infobar); + void ShowInfoBar(content::WebContents* tab, + TranslateInfoBarDelegate* infobar); // Returns the language to translate to. The language returned is the // first language found in the following list that is supported by the @@ -173,7 +178,7 @@ class TranslateManager : public content::NotificationObserver, // Returns the translate info bar showing in |tab| or NULL if none is showing. static TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( - TabContents* tab); + content::WebContents* tab); content::NotificationRegistrar notification_registrar_; diff --git a/chrome/browser/ui/auto_login_prompter.cc b/chrome/browser/ui/auto_login_prompter.cc index 3aba710..e2c6688 100644 --- a/chrome/browser/ui/auto_login_prompter.cc +++ b/chrome/browser/ui/auto_login_prompter.cc @@ -41,6 +41,7 @@ #include "ui/base/resource/resource_bundle.h" using content::BrowserThread; +using content::WebContents; // AutoLoginRedirector -------------------------------------------------------- @@ -219,17 +220,17 @@ bool AutoLoginInfoBarDelegate::Cancel() { // AutoLoginPrompter ---------------------------------------------------------- AutoLoginPrompter::AutoLoginPrompter( - TabContents* tab_contents, + WebContents* web_contents, const std::string& username, const std::string& args) - : tab_contents_(tab_contents), + : web_contents_(web_contents), username_(username), args_(args) { registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &tab_contents_->GetController())); - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents_)); + &web_contents_->GetController())); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents_)); } AutoLoginPrompter::~AutoLoginPrompter() { @@ -327,13 +328,13 @@ void AutoLoginPrompter::Observe(int type, const content::NotificationDetails& details) { if (type == content::NOTIFICATION_LOAD_STOP) { TabContentsWrapper* wrapper = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents_); // |wrapper| is NULL for TabContents hosted in HTMLDialog. if (wrapper) { InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); Profile* profile = wrapper->profile(); infobar_helper->AddInfoBar(new AutoLoginInfoBarDelegate( - infobar_helper, &tab_contents_->GetController(), + infobar_helper, &web_contents_->GetController(), profile->GetTokenService(), profile->GetPrefs(), username_, args_)); } diff --git a/chrome/browser/ui/auto_login_prompter.h b/chrome/browser/ui/auto_login_prompter.h index 11900ff..ca05b42 100644 --- a/chrome/browser/ui/auto_login_prompter.h +++ b/chrome/browser/ui/auto_login_prompter.h @@ -10,7 +10,10 @@ #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" -class TabContents; +namespace content { +class WebContents; +} + namespace net { class URLRequest; } @@ -21,7 +24,7 @@ class URLRequest; // tokens that would allow a one-click login. class AutoLoginPrompter : public content::NotificationObserver { public: - AutoLoginPrompter(TabContents* tab_contents, + AutoLoginPrompter(content::WebContents* web_contents, const std::string& username, const std::string& args); @@ -46,7 +49,7 @@ class AutoLoginPrompter : public content::NotificationObserver { const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; - TabContents* tab_contents_; + content::WebContents* web_contents_; const std::string username_; const std::string args_; content::NotificationRegistrar registrar_; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 1109ccf..4ed9a7b 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -209,6 +209,7 @@ using base::TimeDelta; using content::PluginService; using content::UserMetricsAction; +using content::WebContents; /////////////////////////////////////////////////////////////////////////////// @@ -347,7 +348,7 @@ Browser::Browser(Type type, Profile* profile) this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, content::Source<ThemeService>( ThemeServiceFactory::GetForProfile(profile_))); - registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED, + registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, content::NotificationService::AllSources()); PrefService* local_state = g_browser_process->local_state(); @@ -4028,10 +4029,10 @@ void Browser::OnInstallApplication(TabContentsWrapper* source, /////////////////////////////////////////////////////////////////////////////// // Browser, SearchEngineTabHelperDelegate implementation: -void Browser::ConfirmSetDefaultSearchProvider(TabContents* tab_contents, +void Browser::ConfirmSetDefaultSearchProvider(WebContents* web_contents, TemplateURL* template_url, Profile* profile) { - window()->ConfirmSetDefaultSearchProvider(tab_contents, template_url, + window()->ConfirmSetDefaultSearchProvider(web_contents, template_url, profile); } @@ -4212,9 +4213,9 @@ void Browser::Observe(int type, break; } - case chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED: { - TabContents* tab_contents = content::Source<TabContents>(source).ptr(); - if (tab_contents == GetSelectedTabContents()) { + case chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED: { + WebContents* web_contents = content::Source<WebContents>(source).ptr(); + if (web_contents == GetSelectedTabContents()) { LocationBar* location_bar = window()->GetLocationBar(); if (location_bar) location_bar->UpdateContentSettingsIcons(); diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 90e3cfd..5ab8217 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -1023,9 +1023,10 @@ class Browser : public TabHandlerDelegate, TabContentsWrapper* new_tab_contents) OVERRIDE; // Overridden from SearchEngineTabHelperDelegate: - virtual void ConfirmSetDefaultSearchProvider(TabContents* tab_contents, - TemplateURL* template_url, - Profile* profile) OVERRIDE; + virtual void ConfirmSetDefaultSearchProvider( + content::WebContents* web_contents, + TemplateURL* template_url, + Profile* profile) OVERRIDE; virtual void ConfirmAddSearchProvider(const TemplateURL* template_url, Profile* profile) OVERRIDE; diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 1435f07..32a4e1d0 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -1311,7 +1311,7 @@ string16 LearnMoreInfoBar::GetLinkText() const { } bool LearnMoreInfoBar::LinkClicked(WindowOpenDisposition disposition) { - owner()->tab_contents()->OpenURL(learn_more_url_, GURL(), disposition, + owner()->web_contents()->OpenURL(learn_more_url_, GURL(), disposition, content::PAGE_TRANSITION_LINK); return false; } diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index ad0703a..6acc870 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -35,6 +35,8 @@ #include "content/public/browser/notification_service.h" #include "net/http/http_util.h" +using content::WebContents; + namespace { // Returns true if the specified Browser can open tabs. Not all Browsers support @@ -585,7 +587,7 @@ void Navigate(NavigateParams* params) { content::NotificationService::current()->Notify( content::NOTIFICATION_TAB_ADDED, content::Source<content::WebContentsDelegate>(params->browser), - content::Details<TabContents>(params->target_contents->tab_contents())); + content::Details<WebContents>(params->target_contents->tab_contents())); } } diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h index 598b9ff..fcf0ed9 100644 --- a/chrome/browser/ui/browser_window.h +++ b/chrome/browser/ui/browser_window.h @@ -29,6 +29,10 @@ class ToolbarView; #endif struct NativeWebKeyboardEvent; +namespace content { +class WebContents; +} + namespace gfx { class Rect; class Size; @@ -202,9 +206,10 @@ class BrowserWindow { // Shows a confirmation dialog box for setting the default search engine // described by |template_url|. Takes ownership of |template_url|. - virtual void ConfirmSetDefaultSearchProvider(TabContents* tab_contents, - TemplateURL* template_url, - Profile* profile) { + virtual void ConfirmSetDefaultSearchProvider( + content::WebContents* web_contents, + TemplateURL* template_url, + Profile* profile) { // TODO(levin): Implement this for non-Windows platforms and make it pure. // http://crbug.com/38475 } diff --git a/chrome/browser/ui/certificate_dialogs.cc b/chrome/browser/ui/certificate_dialogs.cc index 006a953..406b48c 100644 --- a/chrome/browser/ui/certificate_dialogs.cc +++ b/chrome/browser/ui/certificate_dialogs.cc @@ -19,6 +19,7 @@ #include "ui/base/l10n/l10n_util.h" using content::BrowserThread; +using content::WebContents; namespace { @@ -61,7 +62,7 @@ std::string GetBase64String(net::X509Certificate::OSCertHandle cert) { class Exporter : public SelectFileDialog::Listener { public: - Exporter(TabContents* tab_contents, gfx::NativeWindow parent, + Exporter(WebContents* web_contents, gfx::NativeWindow parent, net::X509Certificate::OSCertHandle cert); ~Exporter(); @@ -76,7 +77,7 @@ class Exporter : public SelectFileDialog::Listener { net::X509Certificate::OSCertHandles cert_chain_list_; }; -Exporter::Exporter(TabContents* tab_contents, +Exporter::Exporter(WebContents* web_contents, gfx::NativeWindow parent, net::X509Certificate::OSCertHandle cert) : select_file_dialog_(SelectFileDialog::Create(this)) { @@ -92,7 +93,7 @@ Exporter::Exporter(TabContents* tab_contents, ShowCertSelectFileDialog(select_file_dialog_.get(), SelectFileDialog::SELECT_SAVEAS_FILE, suggested_path, - tab_contents, + web_contents, parent, NULL); } @@ -144,7 +145,7 @@ void Exporter::FileSelectionCanceled(void* params) { void ShowCertSelectFileDialog(SelectFileDialog* select_file_dialog, SelectFileDialog::Type type, const FilePath& suggested_path, - TabContents* tab_contents, + WebContents* web_contents, gfx::NativeWindow parent, void* params) { SelectFileDialog::FileTypeInfo file_type_info; @@ -170,12 +171,12 @@ void ShowCertSelectFileDialog(SelectFileDialog* select_file_dialog, select_file_dialog->SelectFile( type, string16(), suggested_path, &file_type_info, 1, - FILE_PATH_LITERAL("crt"), tab_contents, + FILE_PATH_LITERAL("crt"), web_contents, parent, params); } -void ShowCertExportDialog(TabContents* tab_contents, +void ShowCertExportDialog(WebContents* web_contents, gfx::NativeWindow parent, net::X509Certificate::OSCertHandle cert) { - new Exporter(tab_contents, parent, cert); + new Exporter(web_contents, parent, cert); } diff --git a/chrome/browser/ui/certificate_dialogs.h b/chrome/browser/ui/certificate_dialogs.h index 3afa67d..fda553d 100644 --- a/chrome/browser/ui/certificate_dialogs.h +++ b/chrome/browser/ui/certificate_dialogs.h @@ -12,11 +12,11 @@ void ShowCertSelectFileDialog(SelectFileDialog* select_file_dialog, SelectFileDialog::Type type, const FilePath& suggested_path, - TabContents* tab_contents, + content::WebContents* web_contents, gfx::NativeWindow parent, void* params); -void ShowCertExportDialog(TabContents* tab_contents, +void ShowCertExportDialog(content::WebContents* web_contents, gfx::NativeWindow parent, net::X509Certificate::OSCertHandle cert); diff --git a/chrome/browser/ui/cocoa/base_bubble_controller.mm b/chrome/browser/ui/cocoa/base_bubble_controller.mm index 986364e..8fad883 100644 --- a/chrome/browser/ui/cocoa/base_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/base_bubble_controller.mm @@ -27,7 +27,7 @@ namespace BaseBubbleControllerInternal { class Bridge : public content::NotificationObserver { public: explicit Bridge(BaseBubbleController* controller) : controller_(controller) { - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_HIDDEN, + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_HIDDEN, content::NotificationService::AllSources()); } diff --git a/chrome/browser/ui/cocoa/download/download_started_animation_mac.mm b/chrome/browser/ui/cocoa/download/download_started_animation_mac.mm index 86029cc..83c37d2 100644 --- a/chrome/browser/ui/cocoa/download/download_started_animation_mac.mm +++ b/chrome/browser/ui/cocoa/download/download_started_animation_mac.mm @@ -13,30 +13,32 @@ #include "chrome/browser/tab_contents/tab_contents_view_mac.h" #import "chrome/browser/ui/cocoa/animatable_image.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/web_contents.h" #include "grit/theme_resources.h" #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" #include "third_party/skia/include/utils/mac/SkCGUtils.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" -class DownloadAnimationTabObserver; +class DownloadAnimationWebObserver; + +using content::WebContents; // A class for managing the Core Animation download animation. -// Should be instantiated using +startAnimationWithTabContents:. +// Should be instantiated using +startAnimationWithWebContents:. @interface DownloadStartedAnimationMac : NSObject { @private - // The observer for the TabContents we are drawing on. - scoped_ptr<DownloadAnimationTabObserver> observer_; + // The observer for the WebContents we are drawing on. + scoped_ptr<DownloadAnimationWebObserver> observer_; CGFloat imageWidth_; AnimatableImage* animation_; }; -+ (void)startAnimationWithTabContents:(TabContents*)tabContents; ++ (void)startAnimationWithWebContents:(WebContents*)webContents; // Called by the Observer if the tab is hidden or closed. - (void)closeAnimation; @@ -45,18 +47,18 @@ class DownloadAnimationTabObserver; // A helper class to monitor tab hidden and closed notifications. If we receive // such a notification, we stop the animation. -class DownloadAnimationTabObserver : public content::NotificationObserver { +class DownloadAnimationWebObserver : public content::NotificationObserver { public: - DownloadAnimationTabObserver(DownloadStartedAnimationMac* owner, - TabContents* tab_contents) + DownloadAnimationWebObserver(DownloadStartedAnimationMac* owner, + WebContents* web_contents) : owner_(owner), - tab_contents_(tab_contents) { + web_contents_(web_contents) { registrar_.Add(this, - content::NOTIFICATION_TAB_CONTENTS_HIDDEN, - content::Source<TabContents>(tab_contents_)); + content::NOTIFICATION_WEB_CONTENTS_HIDDEN, + content::Source<WebContents>(web_contents_)); registrar_.Add(this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents_)); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents_)); } // Runs when a tab is hidden or destroyed. Let our owner know we should end @@ -73,17 +75,17 @@ class DownloadAnimationTabObserver : public content::NotificationObserver { DownloadStartedAnimationMac* owner_; // The tab we are observing. Weak. - TabContents* tab_contents_; + WebContents* web_contents_; // Used for registering to receive notifications and automatic clean up. content::NotificationRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(DownloadAnimationTabObserver); + DISALLOW_COPY_AND_ASSIGN(DownloadAnimationWebObserver); }; @implementation DownloadStartedAnimationMac -- (id)initWithTabContents:(TabContents*)tabContents { +- (id)initWithWebContents:(WebContents*)webContents { if ((self = [super init])) { // Load the image of the download arrow. ResourceBundle& bundle = ResourceBundle::GetSharedInstance(); @@ -94,7 +96,7 @@ class DownloadAnimationTabObserver : public content::NotificationObserver { // the bottom of the tab, assuming there is enough room. If there isn't // enough, don't show the animation and let the shelf speak for itself. gfx::Rect bounds; - tabContents->GetContainerBounds(&bounds); + webContents->GetContainerBounds(&bounds); imageWidth_ = [image size].width; CGFloat imageHeight = [image size].height; @@ -104,7 +106,7 @@ class DownloadAnimationTabObserver : public content::NotificationObserver { return nil; } - NSView* tabContentsView = tabContents->GetNativeView(); + NSView* tabContentsView = webContents->GetNativeView(); NSWindow* parentWindow = [tabContentsView window]; if (!parentWindow) { // The tab is no longer frontmost. @@ -132,7 +134,7 @@ class DownloadAnimationTabObserver : public content::NotificationObserver { [animation_ setEndOpacity:0.4]; [animation_ setDuration:0.6]; - observer_.reset(new DownloadAnimationTabObserver(self, tabContents)); + observer_.reset(new DownloadAnimationWebObserver(self, webContents)); // Set up to get notified about resize events on the parent window. NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; @@ -176,10 +178,10 @@ class DownloadAnimationTabObserver : public content::NotificationObserver { [self release]; } -+ (void)startAnimationWithTabContents:(TabContents*)contents { ++ (void)startAnimationWithWebContents:(WebContents*)contents { // Will be deleted when the animation window closes. DownloadStartedAnimationMac* controller = - [[self alloc] initWithTabContents:contents]; + [[self alloc] initWithWebContents:contents]; // The initializer can return nil. if (!controller) return; @@ -190,9 +192,9 @@ class DownloadAnimationTabObserver : public content::NotificationObserver { @end -void DownloadStartedAnimation::Show(TabContents* tab_contents) { - DCHECK(tab_contents); +void DownloadStartedAnimation::Show(WebContents* web_contents) { + DCHECK(web_contents); // Will be deleted when the animation is complete. - [DownloadStartedAnimationMac startAnimationWithTabContents:tab_contents]; + [DownloadStartedAnimationMac startAnimationWithWebContents:web_contents]; } diff --git a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm index 02e1b7ef..46ab573 100644 --- a/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm +++ b/chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm @@ -269,7 +269,7 @@ class InfobarBridge : public ExtensionInfoBarDelegate::DelegateObserver, InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { NSWindow* window = - [(NSView*)owner->tab_contents()->GetContentNativeView() window]; + [(NSView*)owner->web_contents()->GetContentNativeView() window]; ExtensionInfoBarController* controller = [[ExtensionInfoBarController alloc] initWithDelegate:this owner:owner diff --git a/chrome/browser/ui/collected_cookies_infobar_delegate.cc b/chrome/browser/ui/collected_cookies_infobar_delegate.cc index 75fad89..79782bc 100644 --- a/chrome/browser/ui/collected_cookies_infobar_delegate.cc +++ b/chrome/browser/ui/collected_cookies_infobar_delegate.cc @@ -41,6 +41,6 @@ string16 CollectedCookiesInfoBarDelegate::GetButtonLabel( } bool CollectedCookiesInfoBarDelegate::Accept() { - owner()->tab_contents()->GetController().Reload(true); + owner()->web_contents()->GetController().Reload(true); return true; } diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc index 4c2c374..d276893 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -25,12 +25,14 @@ #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/user_metrics.h" +#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" #include "grit/generated_resources.h" #include "net/base/net_util.h" #include "ui/base/l10n/l10n_util.h" using content::UserMetricsAction; +using content::WebContents; using content_settings::SettingInfo; using content_settings::SettingSource; using content_settings::SETTING_SOURCE_USER; @@ -538,8 +540,8 @@ ContentSettingBubbleModel::ContentSettingBubbleModel( : tab_contents_(tab_contents), profile_(profile), content_type_(content_type) { - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents->tab_contents())); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab_contents->tab_contents())); registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, content::Source<Profile>(profile_)); } @@ -572,9 +574,9 @@ void ContentSettingBubbleModel::Observe( const content::NotificationSource& source, const content::NotificationDetails& details) { switch (type) { - case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: DCHECK(source == - content::Source<TabContents>(tab_contents_->tab_contents())); + content::Source<WebContents>(tab_contents_->tab_contents())); tab_contents_ = NULL; break; case chrome::NOTIFICATION_PROFILE_DESTROYED: diff --git a/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc b/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc index d10da39..c2376ee 100644 --- a/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/content_setting_bubble_gtk.cc @@ -17,10 +17,10 @@ #include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/common/content_settings.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/plugin_service.h" +#include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/ui_resources.h" #include "ui/base/gtk/gtk_hig_constants.h" @@ -29,6 +29,7 @@ #include "ui/gfx/gtk_util.h" using content::PluginService; +using content::WebContents; namespace { @@ -54,15 +55,15 @@ ContentSettingBubbleGtk::ContentSettingBubbleGtk( BubbleDelegateGtk* delegate, ContentSettingBubbleModel* content_setting_bubble_model, Profile* profile, - TabContents* tab_contents) + WebContents* web_contents) : anchor_(anchor), profile_(profile), - tab_contents_(tab_contents), + web_contents_(web_contents), delegate_(delegate), content_setting_bubble_model_(content_setting_bubble_model), bubble_(NULL) { - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents)); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents)); BuildBubble(); } @@ -84,9 +85,9 @@ void ContentSettingBubbleGtk::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - DCHECK(type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED); - DCHECK(source == content::Source<TabContents>(tab_contents_)); - tab_contents_ = NULL; + DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED); + DCHECK(source == content::Source<WebContents>(web_contents_)); + web_contents_ = NULL; } void ContentSettingBubbleGtk::BuildBubble() { diff --git a/chrome/browser/ui/gtk/content_setting_bubble_gtk.h b/chrome/browser/ui/gtk/content_setting_bubble_gtk.h index e5fde35..e45123c 100644 --- a/chrome/browser/ui/gtk/content_setting_bubble_gtk.h +++ b/chrome/browser/ui/gtk/content_setting_bubble_gtk.h @@ -18,7 +18,10 @@ class ContentSettingBubbleModel; class Profile; -class TabContents; + +namespace content { +class WebContents; +} // ContentSettingBubbleGtk is used when the user turns on different kinds of // content blocking (e.g. "block images"). An icon appears in the location bar, @@ -31,7 +34,7 @@ class ContentSettingBubbleGtk : public BubbleDelegateGtk, GtkWidget* anchor, BubbleDelegateGtk* delegate, ContentSettingBubbleModel* content_setting_bubble_model, - Profile* profile, TabContents* tab_contents); + Profile* profile, content::WebContents* web_contents); virtual ~ContentSettingBubbleGtk(); // Dismisses the bubble. @@ -66,10 +69,10 @@ class ContentSettingBubbleGtk : public BubbleDelegateGtk, // The active profile. Profile* profile_; - // The active tab contents. - TabContents* tab_contents_; + // The active web contents. + content::WebContents* web_contents_; - // A registrar for listening for TAB_CONTENTS_DESTROYED notifications. + // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. content::NotificationRegistrar registrar_; // Pass on delegate messages to this. diff --git a/chrome/browser/ui/gtk/download/download_started_animation_gtk.cc b/chrome/browser/ui/gtk/download/download_started_animation_gtk.cc index 7f0dbe4..b23d499 100644 --- a/chrome/browser/ui/gtk/download/download_started_animation_gtk.cc +++ b/chrome/browser/ui/gtk/download/download_started_animation_gtk.cc @@ -7,16 +7,18 @@ #include <gtk/gtk.h> #include "base/message_loop.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/web_contents.h" #include "grit/theme_resources.h" #include "ui/base/animation/linear_animation.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" #include "ui/gfx/rect.h" +using content::WebContents; + namespace { // How long to spend moving downwards and fading out after waiting. @@ -33,7 +35,7 @@ const double kMoveFraction = 1.0 / 3.0; class DownloadStartedAnimationGtk : public ui::LinearAnimation, public content::NotificationObserver { public: - explicit DownloadStartedAnimationGtk(TabContents* tab_contents); + explicit DownloadStartedAnimationGtk(WebContents* web_contents); // DownloadStartedAnimation will delete itself, but this is public so // that we can use DeleteSoon(). @@ -63,14 +65,14 @@ class DownloadStartedAnimationGtk : public ui::LinearAnimation, int height_; // The content area holding us. - TabContents* tab_contents_; + WebContents* web_contents_; // The content area at the start of the animation. We store this so that the // download shelf's resizing of the content area doesn't cause the animation // to move around. This means that once started, the animation won't move // with the parent window, but it's so fast that this shouldn't cause too // much heartbreak. - gfx::Rect tab_contents_bounds_; + gfx::Rect web_contents_bounds_; // A scoped container for notification registries. content::NotificationRegistrar registrar_; @@ -79,10 +81,10 @@ class DownloadStartedAnimationGtk : public ui::LinearAnimation, }; DownloadStartedAnimationGtk::DownloadStartedAnimationGtk( - TabContents* tab_contents) + WebContents* web_contents) : ui::LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL), popup_(NULL), - tab_contents_(tab_contents) { + web_contents_(web_contents) { static GdkPixbuf* kDownloadImage = NULL; if (!kDownloadImage) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); @@ -94,18 +96,18 @@ DownloadStartedAnimationGtk::DownloadStartedAnimationGtk( // If we're too small to show the download image, then don't bother - // the shelf will be enough. - tab_contents_->GetContainerBounds(&tab_contents_bounds_); - if (tab_contents_bounds_.height() < height_) + web_contents_->GetContainerBounds(&web_contents_bounds_); + if (web_contents_bounds_.height() < height_) return; registrar_.Add( this, - content::NOTIFICATION_TAB_CONTENTS_HIDDEN, - content::Source<TabContents>(tab_contents_)); + content::NOTIFICATION_WEB_CONTENTS_HIDDEN, + content::Source<WebContents>(web_contents_)); registrar_.Add( this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents_)); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents_)); // TODO(estade): don't show up on the wrong virtual desktop. @@ -135,7 +137,7 @@ DownloadStartedAnimationGtk::~DownloadStartedAnimationGtk() { } void DownloadStartedAnimationGtk::Reposition() { - if (!tab_contents_) + if (!web_contents_) return; DCHECK(popup_); @@ -143,33 +145,33 @@ void DownloadStartedAnimationGtk::Reposition() { // Align the image with the bottom left of the web contents (so that it // points to the newly created download). gtk_window_move(GTK_WINDOW(popup_), - tab_contents_bounds_.x(), - static_cast<int>(tab_contents_bounds_.bottom() - + web_contents_bounds_.x(), + static_cast<int>(web_contents_bounds_.bottom() - height_ - height_ * (1 - GetCurrentValue()))); } void DownloadStartedAnimationGtk::Close() { - if (!tab_contents_) + if (!web_contents_) return; DCHECK(popup_); registrar_.Remove( this, - content::NOTIFICATION_TAB_CONTENTS_HIDDEN, - content::Source<TabContents>(tab_contents_)); + content::NOTIFICATION_WEB_CONTENTS_HIDDEN, + content::Source<WebContents>(web_contents_)); registrar_.Remove( this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents_)); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents_)); - tab_contents_ = NULL; + web_contents_ = NULL; gtk_widget_destroy(popup_); MessageLoop::current()->DeleteSoon(FROM_HERE, this); } void DownloadStartedAnimationGtk::AnimateToState(double state) { - if (!tab_contents_) + if (!web_contents_) return; if (state >= 1.0) { @@ -196,7 +198,7 @@ void DownloadStartedAnimationGtk::Observe( } // namespace // static -void DownloadStartedAnimation::Show(TabContents* tab_contents) { +void DownloadStartedAnimation::Show(WebContents* web_contents) { // The animation will delete itself. - new DownloadStartedAnimationGtk(tab_contents); + new DownloadStartedAnimationGtk(web_contents); } diff --git a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc index 1e82093..c2feff4 100644 --- a/chrome/browser/ui/gtk/infobars/infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/infobar_gtk.cc @@ -53,7 +53,7 @@ const int InfoBarGtk::kEndOfLabelSpacing = 6; InfoBarGtk::InfoBarGtk(InfoBarTabHelper* owner, InfoBarDelegate* delegate) : InfoBar(owner, delegate), theme_service_(GtkThemeService::GetFrom(Profile::FromBrowserContext( - owner->tab_contents()->GetBrowserContext()))), + owner->web_contents()->GetBrowserContext()))), signals_(new ui::GtkSignalRegistrar) { DCHECK(delegate); // Create |hbox_| and pad the sides. diff --git a/chrome/browser/ui/gtk/tab_contents_container_gtk.cc b/chrome/browser/ui/gtk/tab_contents_container_gtk.cc index f60ad93..3675ca3 100644 --- a/chrome/browser/ui/gtk/tab_contents_container_gtk.cc +++ b/chrome/browser/ui/gtk/tab_contents_container_gtk.cc @@ -13,10 +13,13 @@ #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/web_contents.h" #include "ui/base/gtk/gtk_expanded_container.h" #include "ui/base/gtk/gtk_floating_container.h" #include "ui/gfx/native_widget_types.h" +using content::WebContents; + TabContentsContainerGtk::TabContentsContainerGtk(StatusBubbleGtk* status_bubble) : tab_(NULL), preview_(NULL), @@ -65,8 +68,8 @@ void TabContentsContainerGtk::Init() { void TabContentsContainerGtk::SetTab(TabContentsWrapper* tab) { HideTab(tab_); if (tab_) { - registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_->tab_contents())); + registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab_->tab_contents())); } tab_ = tab; @@ -78,8 +81,8 @@ void TabContentsContainerGtk::SetTab(TabContentsWrapper* tab) { } else if (tab_) { // Otherwise we actually have to add it to the widget hierarchy. PackTab(tab); - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_->tab_contents())); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab_->tab_contents())); } } @@ -96,8 +99,8 @@ void TabContentsContainerGtk::SetPreview(TabContentsWrapper* preview) { preview_ = preview; PackTab(preview); - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(preview_->tab_contents())); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(preview_->tab_contents())); } void TabContentsContainerGtk::RemovePreview() { @@ -110,8 +113,8 @@ void TabContentsContainerGtk::RemovePreview() { if (preview_widget) gtk_container_remove(GTK_CONTAINER(expanded_), preview_widget); - registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(preview_->tab_contents())); + registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(preview_->tab_contents())); preview_ = NULL; } @@ -173,13 +176,13 @@ void TabContentsContainerGtk::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - DCHECK(type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED); + DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED); - TabContentsDestroyed(content::Source<TabContents>(source).ptr()); + WebContentsDestroyed(content::Source<WebContents>(source).ptr()); } -void TabContentsContainerGtk::TabContentsDestroyed(TabContents* contents) { - // Sometimes, a TabContents is destroyed before we know about it. This allows +void TabContentsContainerGtk::WebContentsDestroyed(WebContents* contents) { + // Sometimes, a WebContents is destroyed before we know about it. This allows // us to clean up our state in case this happens. if (preview_ && contents == preview_->tab_contents()) PopPreview(); diff --git a/chrome/browser/ui/gtk/tab_contents_container_gtk.h b/chrome/browser/ui/gtk/tab_contents_container_gtk.h index 732d8ea..377d509 100644 --- a/chrome/browser/ui/gtk/tab_contents_container_gtk.h +++ b/chrome/browser/ui/gtk/tab_contents_container_gtk.h @@ -17,9 +17,12 @@ #include "ui/base/gtk/owned_widget_gtk.h" class StatusBubbleGtk; -class TabContents; class TabContentsWrapper; +namespace content { +class WebContents; +} + typedef struct _GtkFloatingContainer GtkFloatingContainer; class TabContentsContainerGtk : public content::NotificationObserver, @@ -56,10 +59,10 @@ class TabContentsContainerGtk : public content::NotificationObserver, virtual GtkWidget* GetWidgetForViewID(ViewID id) OVERRIDE; private: - // Called when a TabContents is destroyed. This gives us a chance to clean - // up our internal state if the TabContents is somehow destroyed before we + // Called when a WebContents is destroyed. This gives us a chance to clean + // up our internal state if the WebContents is somehow destroyed before we // get notified. - void TabContentsDestroyed(TabContents* contents); + void WebContentsDestroyed(content::WebContents* contents); // Handler for |floating_|'s "set-floating-position" signal. During this // callback, we manually set the position of the status bubble. diff --git a/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc index bdea30f..b41c088 100644 --- a/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc @@ -23,6 +23,8 @@ #include "content/public/browser/notification_types.h" #include "ui/gfx/screen.h" +using content::WebContents; + namespace { // Delay, in ms, during dragging before we bring a window to front. @@ -161,8 +163,8 @@ DraggedTabData DraggedTabControllerGtk::InitDraggedTabData(TabGtk* tab) { source_model_index, pinned, mini); registrar_.Add( this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(dragged_tab_data.contents_->tab_contents())); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(dragged_tab_data.contents_->tab_contents())); return dragged_tab_data; } @@ -223,8 +225,8 @@ void DraggedTabControllerGtk::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - DCHECK(type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED); - TabContents* destroyed_contents = content::Source<TabContents>(source).ptr(); + DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED); + WebContents* destroyed_contents = content::Source<WebContents>(source).ptr(); for (size_t i = 0; i < drag_data_->size(); ++i) { if (drag_data_->get(i)->contents_->tab_contents() == destroyed_contents) { // One of the tabs we're dragging has been destroyed. Cancel the drag. @@ -845,8 +847,8 @@ void DraggedTabControllerGtk::CleanUpDraggedTabs() { for (size_t i = 0; i < drag_data_->size(); ++i) { if (drag_data_->get(i)->contents_) { registrar_.Remove( - this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>( + this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>( drag_data_->get(i)->contents_->tab_contents())); } source_tabstrip_->DestroyDraggedTab(drag_data_->get(i)->tab_); diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc index 497f79d..54e33fa 100644 --- a/chrome/browser/ui/panels/panel.cc +++ b/chrome/browser/ui/panels/panel.cc @@ -27,6 +27,8 @@ #include "ui/gfx/screen.h" #endif +using content::WebContents; + // static const Extension* Panel::GetExtensionFromBrowser(Browser* browser) { // Find the extension. When we create a panel from an extension, the extension @@ -372,7 +374,7 @@ void Panel::DisableInactiveFrame() { NOTIMPLEMENTED(); } -void Panel::ConfirmSetDefaultSearchProvider(TabContents* tab_contents, +void Panel::ConfirmSetDefaultSearchProvider(WebContents* web_contents, TemplateURL* template_url, Profile* profile) { NOTIMPLEMENTED(); diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h index 547ccff..f59ad84 100644 --- a/chrome/browser/ui/panels/panel.h +++ b/chrome/browser/ui/panels/panel.h @@ -126,9 +126,10 @@ class Panel : public BrowserWindow, virtual bool IsTabStripEditable() const OVERRIDE; virtual bool IsToolbarVisible() const OVERRIDE; virtual void DisableInactiveFrame() OVERRIDE; - virtual void ConfirmSetDefaultSearchProvider(TabContents* tab_contents, - TemplateURL* template_url, - Profile* profile) OVERRIDE; + virtual void ConfirmSetDefaultSearchProvider( + content::WebContents* web_contents, + TemplateURL* template_url, + Profile* profile) OVERRIDE; virtual void ConfirmAddSearchProvider(const TemplateURL* template_url, Profile* profile) OVERRIDE; virtual void ToggleBookmarkBar() OVERRIDE; diff --git a/chrome/browser/ui/search_engines/search_engine_tab_helper.cc b/chrome/browser/ui/search_engines/search_engine_tab_helper.cc index a58e08e..b9f4529 100644 --- a/chrome/browser/ui/search_engines/search_engine_tab_helper.cc +++ b/chrome/browser/ui/search_engines/search_engine_tab_helper.cc @@ -11,9 +11,11 @@ #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h" #include "chrome/common/render_messages.h" -#include "content/browser/tab_contents/tab_contents.h" +#include "content/public/browser/web_contents.h" #include "content/public/common/frame_navigate_params.h" +using content::WebContents; + namespace { // Returns true if the entry's transition type is FORM_SUBMIT. @@ -24,9 +26,9 @@ bool IsFormSubmit(const NavigationEntry* entry) { } // namespace -SearchEngineTabHelper::SearchEngineTabHelper(TabContents* tab_contents) - : content::WebContentsObserver(tab_contents) { - DCHECK(tab_contents); +SearchEngineTabHelper::SearchEngineTabHelper(WebContents* web_contents) + : content::WebContentsObserver(web_contents) { + DCHECK(web_contents); } SearchEngineTabHelper::~SearchEngineTabHelper() { @@ -59,8 +61,8 @@ void SearchEngineTabHelper::OnPageHasOSDD( // Make sure page_id is the current page and other basic checks. DCHECK(doc_url.is_valid()); Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); - if (!tab_contents()->IsActiveEntry(page_id)) + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); + if (!web_contents()->IsActiveEntry(page_id)) return; if (!profile->GetTemplateURLFetcher()) return; @@ -86,7 +88,7 @@ void SearchEngineTabHelper::OnPageHasOSDD( return; } - const NavigationController& controller = tab_contents()->GetController(); + const NavigationController& controller = web_contents()->GetController(); const NavigationEntry* entry = controller.GetLastCommittedEntry(); DCHECK(entry); @@ -122,7 +124,7 @@ void SearchEngineTabHelper::OnPageHasOSDD( keyword, doc_url, base_entry->favicon().url(), - new TemplateURLFetcherUICallbacks(this, tab_contents()), + new TemplateURLFetcherUICallbacks(this, web_contents()), provider_type); } @@ -132,11 +134,11 @@ void SearchEngineTabHelper::GenerateKeywordIfNecessary( return; Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); if (profile->IsOffTheRecord()) return; - const NavigationController& controller = tab_contents()->GetController(); + const NavigationController& controller = web_contents()->GetController(); int last_index = controller.last_committed_entry_index(); // When there was no previous page, the last index will be 0. This is // normally due to a form submit that opened in a new tab. diff --git a/chrome/browser/ui/search_engines/search_engine_tab_helper.h b/chrome/browser/ui/search_engines/search_engine_tab_helper.h index 0cdbc3b..2c8ec06 100644 --- a/chrome/browser/ui/search_engines/search_engine_tab_helper.h +++ b/chrome/browser/ui/search_engines/search_engine_tab_helper.h @@ -17,7 +17,7 @@ class SearchEngineTabHelperDelegate; // functionality. class SearchEngineTabHelper : public content::WebContentsObserver { public: - explicit SearchEngineTabHelper(TabContents* tab_contents); + explicit SearchEngineTabHelper(content::WebContents* web_contents); virtual ~SearchEngineTabHelper(); SearchEngineTabHelperDelegate* delegate() const { return delegate_; } diff --git a/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h b/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h index fe7278b..b50732e 100644 --- a/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h +++ b/chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h @@ -7,18 +7,22 @@ #pragma once class Profile; -class TabContents; class TemplateURL; +namespace content { +class WebContents; +} + // Objects implement this interface to get notified about changes in the // SearchEngineTabHelper and to provide necessary functionality. class SearchEngineTabHelperDelegate { public: // Shows a confirmation dialog box for setting the default search engine // described by |template_url|. Takes ownership of |template_url|. - virtual void ConfirmSetDefaultSearchProvider(TabContents* tab_contents, - TemplateURL* template_url, - Profile* profile) = 0; + virtual void ConfirmSetDefaultSearchProvider( + content::WebContents* tab_contents, + TemplateURL* template_url, + Profile* profile) = 0; // Shows a confirmation dialog box for adding a search engine described by // |template_url|. Takes ownership of |template_url|. diff --git a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc index bc7ec8c..9aa4e0e 100644 --- a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc +++ b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.cc @@ -9,18 +9,20 @@ #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" #include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/web_contents.h" + +using content::WebContents; TemplateURLFetcherUICallbacks::TemplateURLFetcherUICallbacks( SearchEngineTabHelper* tab_helper, - TabContents* tab_contents) + WebContents* web_contents) : source_(tab_helper), - tab_contents_(tab_contents) { + web_contents_(web_contents) { registrar_.Add(this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents_)); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents_)); } TemplateURLFetcherUICallbacks::~TemplateURLFetcherUICallbacks() { @@ -30,10 +32,10 @@ void TemplateURLFetcherUICallbacks::ConfirmSetDefaultSearchProvider( TemplateURL* template_url, Profile* profile) { scoped_ptr<TemplateURL> owned_template_url(template_url); - if (!source_ || !source_->delegate() || !tab_contents_) + if (!source_ || !source_->delegate() || !web_contents_) return; - source_->delegate()->ConfirmSetDefaultSearchProvider(tab_contents_, + source_->delegate()->ConfirmSetDefaultSearchProvider(web_contents_, owned_template_url.release(), profile); } @@ -52,8 +54,8 @@ void TemplateURLFetcherUICallbacks::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - DCHECK(type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED); - DCHECK(source == content::Source<TabContents>(tab_contents_)); + DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED); + DCHECK(source == content::Source<WebContents>(web_contents_)); source_ = NULL; - tab_contents_ = NULL; + web_contents_ = NULL; } diff --git a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h index c3ac514..76a25f8 100644 --- a/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h +++ b/chrome/browser/ui/search_engines/template_url_fetcher_ui_callbacks.h @@ -13,14 +13,17 @@ #include "content/public/browser/notification_registrar.h" class SearchEngineTabHelper; -class TabContents; + +namespace content { +class WebContents; +} // Callbacks which display UI for the TemplateURLFetcher. class TemplateURLFetcherUICallbacks : public TemplateURLFetcherCallbacks, public content::NotificationObserver { public: TemplateURLFetcherUICallbacks(SearchEngineTabHelper* tab_helper, - TabContents* tab_contents); + content::WebContents* tab_contents); virtual ~TemplateURLFetcherUICallbacks(); // TemplateURLFetcherCallback implementation. @@ -39,8 +42,8 @@ class TemplateURLFetcherUICallbacks : public TemplateURLFetcherCallbacks, // originating tab is closed. If NULL, the engine is not added. SearchEngineTabHelper* source_; - // The TabContents where this request originated. - TabContents* tab_contents_; + // The WebContents where this request originated. + content::WebContents* web_contents_; // Handles registering for our notifications. content::NotificationRegistrar registrar_; diff --git a/chrome/browser/ui/select_file_dialog.cc b/chrome/browser/ui/select_file_dialog.cc index ddca99c..25774c6 100644 --- a/chrome/browser/ui/select_file_dialog.cc +++ b/chrome/browser/ui/select_file_dialog.cc @@ -17,6 +17,8 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +using content::WebContents; + SelectFileDialog::FileTypeInfo::FileTypeInfo() : include_all_files(false) {} SelectFileDialog::FileTypeInfo::~FileTypeInfo() {} @@ -47,7 +49,7 @@ void SelectFileDialog::SelectFile(Type type, const FileTypeInfo* file_types, int file_type_index, const FilePath::StringType& default_extension, - TabContents* source_contents, + WebContents* source_contents, gfx::NativeWindow owning_window, void* params) { DCHECK(listener_); diff --git a/chrome/browser/ui/select_file_dialog.h b/chrome/browser/ui/select_file_dialog.h index 89051ac..f2a795e 100644 --- a/chrome/browser/ui/select_file_dialog.h +++ b/chrome/browser/ui/select_file_dialog.h @@ -14,7 +14,9 @@ #include "base/string16.h" #include "ui/gfx/native_widget_types.h" -class TabContents; +namespace content { +class WebContents; +} // This function is declared extern such that it is accessible for unit tests // in /chrome/browser/ui/views/select_file_dialog_win_unittest.cc @@ -135,7 +137,7 @@ class SelectFileDialog const FileTypeInfo* file_types, int file_type_index, const FilePath::StringType& default_extension, - TabContents* source_contents, + content::WebContents* source_contents, gfx::NativeWindow owning_window, void* params); bool HasMultipleFileTypeChoices(); diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index d72c9ea..e0b33d1 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -173,6 +173,10 @@ const TabContentsWrapper* TabContentsWrapper::GetCurrentWrapperForContents( return wrapper ? *wrapper : NULL; } +WebContents* TabContentsWrapper::web_contents() const { + return tab_contents_.get(); +} + Profile* TabContentsWrapper::profile() const { return Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); } diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h index 40c3b31..4499647 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h @@ -96,6 +96,7 @@ class TabContentsWrapper : public content::WebContentsObserver { // Returns the TabContents that this wraps. TabContents* tab_contents() const { return tab_contents_.get(); } + content::WebContents* web_contents() const; // Returns the Profile that is associated with this TabContentsWrapper. Profile* profile() const; diff --git a/chrome/browser/ui/views/content_setting_bubble_contents.cc b/chrome/browser/ui/views/content_setting_bubble_contents.cc index b74cb2b..3eddf90 100644 --- a/chrome/browser/ui/views/content_setting_bubble_contents.cc +++ b/chrome/browser/ui/views/content_setting_bubble_contents.cc @@ -50,6 +50,7 @@ const int kMaxContentsWidth = 500; const int kMinMultiLineContentsWidth = 250; using content::PluginService; +using content::WebContents; class ContentSettingBubbleContents::Favicon : public views::ImageView { public: @@ -108,18 +109,18 @@ gfx::NativeCursor ContentSettingBubbleContents::Favicon::GetCursor( ContentSettingBubbleContents::ContentSettingBubbleContents( ContentSettingBubbleModel* content_setting_bubble_model, Profile* profile, - TabContents* tab_contents, + WebContents* web_contents, views::View* anchor_view, views::BubbleBorder::ArrowLocation arrow_location) : BubbleDelegateView(anchor_view, arrow_location), content_setting_bubble_model_(content_setting_bubble_model), profile_(profile), - tab_contents_(tab_contents), + web_contents_(web_contents), custom_link_(NULL), manage_link_(NULL), close_button_(NULL) { - registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents)); + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents)); } ContentSettingBubbleContents::~ContentSettingBubbleContents() { @@ -336,7 +337,7 @@ void ContentSettingBubbleContents::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - DCHECK(type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED); - DCHECK(source == content::Source<TabContents>(tab_contents_)); - tab_contents_ = NULL; + DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED); + DCHECK(source == content::Source<WebContents>(web_contents_)); + web_contents_ = NULL; } diff --git a/chrome/browser/ui/views/content_setting_bubble_contents.h b/chrome/browser/ui/views/content_setting_bubble_contents.h index 386684d..1006c3c 100644 --- a/chrome/browser/ui/views/content_setting_bubble_contents.h +++ b/chrome/browser/ui/views/content_setting_bubble_contents.h @@ -29,7 +29,10 @@ class ContentSettingBubbleModel; class Profile; -class TabContents; + +namespace content { +class WebContents; +} namespace views { class TextButton; @@ -44,7 +47,7 @@ class ContentSettingBubbleContents : public views::BubbleDelegateView, ContentSettingBubbleContents( ContentSettingBubbleModel* content_setting_bubble_model, Profile* profile, - TabContents* tab_contents, + content::WebContents* web_contents, views::View* anchor_view, views::BubbleBorder::ArrowLocation arrow_location); virtual ~ContentSettingBubbleContents(); @@ -81,10 +84,10 @@ class ContentSettingBubbleContents : public views::BubbleDelegateView, // The active profile. Profile* profile_; - // The active tab contents. - TabContents* tab_contents_; + // The active web contents. + content::WebContents* web_contents_; - // A registrar for listening for TAB_CONTENTS_DESTROYED notifications. + // A registrar for listening for WEB_CONTENTS_DESTROYED notifications. content::NotificationRegistrar registrar_; // Some of our controls, so we can tell what's been clicked when we get a diff --git a/chrome/browser/ui/views/default_search_view.cc b/chrome/browser/ui/views/default_search_view.cc index 4267dc8..5245317 100644 --- a/chrome/browser/ui/views/default_search_view.cc +++ b/chrome/browser/ui/views/default_search_view.cc @@ -15,7 +15,7 @@ #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/views/constrained_window_views.h" -#include "content/browser/tab_contents/tab_contents.h" +#include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "grit/theme_resources.h" @@ -30,6 +30,8 @@ #include "ui/views/widget/widget.h" #include "ui/views/window/dialog_client_view.h" +using content::WebContents; + namespace { // Returns a short name and logo resource id for the given host. @@ -113,7 +115,7 @@ views::View* CreateProviderChoiceButton( } // namespace // static -void DefaultSearchView::Show(TabContents* tab_contents, +void DefaultSearchView::Show(WebContents* web_contents, TemplateURL* proposed_default_turl, Profile* profile) { TemplateURLService* template_url_service = @@ -121,7 +123,7 @@ void DefaultSearchView::Show(TabContents* tab_contents, if (template_url_service->CanMakeDefault(proposed_default_turl) && !proposed_default_turl->url()->GetHost().empty()) { // When the window closes, it will delete itself. - new DefaultSearchView(tab_contents, proposed_default_turl, + new DefaultSearchView(web_contents, proposed_default_turl, template_url_service, profile->GetPrefs()); } else { delete proposed_default_turl; @@ -187,7 +189,7 @@ const views::Widget* DefaultSearchView::GetWidget() const { return View::GetWidget(); } -DefaultSearchView::DefaultSearchView(TabContents* tab_contents, +DefaultSearchView::DefaultSearchView(WebContents* web_contents, TemplateURL* proposed_default_turl, TemplateURLService* template_url_service, PrefService* prefs) @@ -200,7 +202,7 @@ DefaultSearchView::DefaultSearchView(TabContents* tab_contents, // Show the dialog. new ConstrainedWindowViews( - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents), this); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents), this); } void DefaultSearchView::SetupControls(PrefService* prefs) { diff --git a/chrome/browser/ui/views/default_search_view.h b/chrome/browser/ui/views/default_search_view.h index 1d2bc65..c07e571 100644 --- a/chrome/browser/ui/views/default_search_view.h +++ b/chrome/browser/ui/views/default_search_view.h @@ -13,10 +13,13 @@ class PrefService; class Profile; -class TabContents; class TemplateURL; class TemplateURLService; +namespace content { +class WebContents; +} + namespace gfx { class Canvas; } @@ -34,7 +37,7 @@ class DefaultSearchView : public views::View, public views::DialogDelegate { public: // Takes ownership of |proposed_default_turl|. - static void Show(TabContents* tab_contents, + static void Show(content::WebContents* web_contents, TemplateURL* proposed_default_turl, Profile* profile); @@ -61,7 +64,7 @@ class DefaultSearchView : public views::View, private: // Takes ownership of |proposed_default_turl|. - DefaultSearchView(TabContents* tab_contents, + DefaultSearchView(content::WebContents* web_contents, TemplateURL* proposed_default_turl, TemplateURLService* template_url_service, PrefService* prefs); diff --git a/chrome/browser/ui/views/download/download_started_animation_views.cc b/chrome/browser/ui/views/download/download_started_animation_views.cc index 603640f..ec1a005 100644 --- a/chrome/browser/ui/views/download/download_started_animation_views.cc +++ b/chrome/browser/ui/views/download/download_started_animation_views.cc @@ -4,11 +4,11 @@ #include "chrome/browser/download/download_started_animation.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/web_contents.h" #include "grit/theme_resources.h" #include "ui/base/animation/linear_animation.h" #include "ui/base/resource/resource_bundle.h" @@ -16,6 +16,8 @@ #include "ui/views/controls/image_view.h" #include "ui/views/widget/widget.h" +using content::WebContents; + // How long to spend moving downwards and fading out after waiting. static const int kMoveTimeMs = 600; @@ -38,7 +40,7 @@ class DownloadStartedAnimationWin : public ui::LinearAnimation, public content::NotificationObserver, public views::ImageView { public: - explicit DownloadStartedAnimationWin(TabContents* tab_contents); + explicit DownloadStartedAnimationWin(WebContents* web_contents); private: // Move the animation to wherever it should currently be. @@ -59,14 +61,14 @@ class DownloadStartedAnimationWin : public ui::LinearAnimation, views::Widget* popup_; // The content area holding us. - TabContents* tab_contents_; + WebContents* web_contents_; // The content area at the start of the animation. We store this so that the // download shelf's resizing of the content area doesn't cause the animation // to move around. This means that once started, the animation won't move // with the parent window, but it's so fast that this shouldn't cause too // much heartbreak. - gfx::Rect tab_contents_bounds_; + gfx::Rect web_contents_bounds_; // A scoped container for notification registries. content::NotificationRegistrar registrar_; @@ -75,10 +77,10 @@ class DownloadStartedAnimationWin : public ui::LinearAnimation, }; DownloadStartedAnimationWin::DownloadStartedAnimationWin( - TabContents* tab_contents) + WebContents* web_contents) : ui::LinearAnimation(kMoveTimeMs, kFrameRateHz, NULL), popup_(NULL), - tab_contents_(tab_contents) { + web_contents_(web_contents) { static SkBitmap* kDownloadImage = NULL; if (!kDownloadImage) { kDownloadImage = ResourceBundle::GetSharedInstance().GetBitmapNamed( @@ -87,18 +89,18 @@ DownloadStartedAnimationWin::DownloadStartedAnimationWin( // If we're too small to show the download image, then don't bother - // the shelf will be enough. - tab_contents_->GetContainerBounds(&tab_contents_bounds_); - if (tab_contents_bounds_.height() < kDownloadImage->height()) + web_contents_->GetContainerBounds(&web_contents_bounds_); + if (web_contents_bounds_.height() < kDownloadImage->height()) return; registrar_.Add( this, - content::NOTIFICATION_TAB_CONTENTS_HIDDEN, - content::Source<TabContents>(tab_contents_)); + content::NOTIFICATION_WEB_CONTENTS_HIDDEN, + content::Source<WebContents>(web_contents_)); registrar_.Add( this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents_)); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents_)); SetImage(kDownloadImage); @@ -107,7 +109,7 @@ DownloadStartedAnimationWin::DownloadStartedAnimationWin( views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); params.transparent = true; params.accept_events = false; - params.parent = tab_contents_->GetNativeView(); + params.parent = web_contents_->GetNativeView(); popup_->Init(params); popup_->SetOpacity(0x00); popup_->SetContentsView(this); @@ -118,35 +120,35 @@ DownloadStartedAnimationWin::DownloadStartedAnimationWin( } void DownloadStartedAnimationWin::Reposition() { - if (!tab_contents_) + if (!web_contents_) return; // Align the image with the bottom left of the web contents (so that it // points to the newly created download). gfx::Size size = GetPreferredSize(); int x = base::i18n::IsRTL() ? - tab_contents_bounds_.right() - size.width() : tab_contents_bounds_.x(); + web_contents_bounds_.right() - size.width() : web_contents_bounds_.x(); popup_->SetBounds(gfx::Rect( x, - static_cast<int>(tab_contents_bounds_.bottom() - + static_cast<int>(web_contents_bounds_.bottom() - size.height() - size.height() * (1 - GetCurrentValue())), size.width(), size.height())); } void DownloadStartedAnimationWin::Close() { - if (!tab_contents_) + if (!web_contents_) return; registrar_.Remove( this, - content::NOTIFICATION_TAB_CONTENTS_HIDDEN, - content::Source<TabContents>(tab_contents_)); + content::NOTIFICATION_WEB_CONTENTS_HIDDEN, + content::Source<WebContents>(web_contents_)); registrar_.Remove( this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents_)); - tab_contents_ = NULL; + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(web_contents_)); + web_contents_ = NULL; popup_->Close(); } @@ -177,8 +179,8 @@ void DownloadStartedAnimationWin::Observe( } // namespace // static -void DownloadStartedAnimation::Show(TabContents* tab_contents) { +void DownloadStartedAnimation::Show(WebContents* web_contents) { // The animation will delete itself when it's finished or when the tab // contents is hidden or destroyed. - new DownloadStartedAnimationWin(tab_contents); + new DownloadStartedAnimationWin(web_contents); } diff --git a/chrome/browser/ui/views/extensions/extension_dialog.cc b/chrome/browser/ui/views/extensions/extension_dialog.cc index 53c74ed1..00f3012 100644 --- a/chrome/browser/ui/views/extensions/extension_dialog.cc +++ b/chrome/browser/ui/views/extensions/extension_dialog.cc @@ -49,7 +49,7 @@ ExtensionDialog* ExtensionDialog::Show( ExtensionHost* host = CreateExtensionHost(url, browser); if (!host) return NULL; - host->set_associated_tab_contents(tab_contents); + host->set_associated_web_contents(tab_contents); ExtensionDialog* dialog = new ExtensionDialog(host, observer); dialog->set_title(title); diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 2c34dae..41fe555 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -140,6 +140,7 @@ using base::TimeDelta; using content::UserMetricsAction; +using content::WebContents; using views::ColumnSet; using views::GridLayout; @@ -1030,11 +1031,11 @@ void BrowserView::DisableInactiveFrame() { #endif // No tricks are needed to get the right behavior on Linux. } -void BrowserView::ConfirmSetDefaultSearchProvider(TabContents* tab_contents, +void BrowserView::ConfirmSetDefaultSearchProvider(WebContents* web_contents, TemplateURL* template_url, Profile* profile) { #if defined(OS_WIN) && !defined(USE_AURA) - DefaultSearchView::Show(tab_contents, template_url, profile); + DefaultSearchView::Show(web_contents, template_url, profile); #else // TODO(levin): Implement for other platforms. Right now this is behind // a command line flag which is off. http://crbug.com/38475 diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index ba32747..2982e14 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -291,9 +291,10 @@ class BrowserView : public BrowserWindow, virtual bool IsTabStripEditable() const OVERRIDE; virtual bool IsToolbarVisible() const OVERRIDE; virtual void DisableInactiveFrame() OVERRIDE; - virtual void ConfirmSetDefaultSearchProvider(TabContents* tab_contents, - TemplateURL* template_url, - Profile* profile) OVERRIDE; + virtual void ConfirmSetDefaultSearchProvider( + content::WebContents* web_contents, + TemplateURL* template_url, + Profile* profile) OVERRIDE; virtual void ConfirmAddSearchProvider(const TemplateURL* template_url, Profile* profile) OVERRIDE; virtual void ToggleBookmarkBar() OVERRIDE; diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_container.cc b/chrome/browser/ui/views/tab_contents/tab_contents_container.cc index 8604952..e80cff9 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_container.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_container.cc @@ -15,6 +15,8 @@ #include "content/public/browser/notification_types.h" #include "ui/base/accessibility/accessible_view_state.h" +using content::WebContents; + //////////////////////////////////////////////////////////////////////////////// // TabContentsContainer, public: @@ -74,8 +76,8 @@ void TabContentsContainer::Observe( content::Details<RenderViewHostSwitchedDetails>(details).ptr(); RenderViewHostChanged(switched_details->old_host, switched_details->new_host); - } else if (type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED) { - TabContentsDestroyed(content::Source<TabContents>(source).ptr()); + } else if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { + TabContentsDestroyed(content::Source<WebContents>(source).ptr()); } else { NOTREACHED(); } @@ -167,8 +169,8 @@ void TabContentsContainer::AddObservers() { registrar_.Add( this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_contents_)); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab_contents_)); } void TabContentsContainer::RemoveObservers() { @@ -182,7 +184,7 @@ void TabContentsContainer::RenderViewHostChanged(RenderViewHost* old_host, native_container_->RenderViewHostChanged(old_host, new_host); } -void TabContentsContainer::TabContentsDestroyed(TabContents* contents) { +void TabContentsContainer::TabContentsDestroyed(WebContents* contents) { // Sometimes, a TabContents is destroyed before we know about it. This allows // us to clean up our state in case this happens. DCHECK(contents == tab_contents_); diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_container.h b/chrome/browser/ui/views/tab_contents/tab_contents_container.h index 58353e6..4bf1c04 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_container.h +++ b/chrome/browser/ui/views/tab_contents/tab_contents_container.h @@ -16,6 +16,10 @@ class RenderViewHost; class RenderWidgetHostView; class TabContents; +namespace content { +class WebContents; +} + class TabContentsContainer : public views::View, public content::NotificationObserver { public: @@ -68,10 +72,10 @@ class TabContentsContainer : public views::View, void RenderViewHostChanged(RenderViewHost* old_host, RenderViewHost* new_host); - // Called when a TabContents is destroyed. This gives us a chance to clean + // Called when a WebContents is destroyed. This gives us a chance to clean // up our internal state if the TabContents is somehow destroyed before we // get notified. - void TabContentsDestroyed(TabContents* contents); + void TabContentsDestroyed(content::WebContents* contents); // Called when the RenderWidgetHostView of the hosted TabContents has changed. void RenderWidgetHostViewChanged(RenderWidgetHostView* new_view); diff --git a/chrome/browser/ui/views/tabs/default_tab_drag_controller.cc b/chrome/browser/ui/views/tabs/default_tab_drag_controller.cc index 81ed65e..319400e 100644 --- a/chrome/browser/ui/views/tabs/default_tab_drag_controller.cc +++ b/chrome/browser/ui/views/tabs/default_tab_drag_controller.cc @@ -44,6 +44,7 @@ #endif using content::UserMetricsAction; +using content::WebContents; static const int kHorizontalMoveThreshold = 16; // Pixels. @@ -378,8 +379,8 @@ void DefaultTabDragController::InitTabDragData(BaseTab* tab, drag_data->pinned = source_tabstrip_->IsTabPinned(tab); registrar_.Add( this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(drag_data->contents->tab_contents())); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(drag_data->contents->tab_contents())); // We need to be the delegate so we receive messages about stuff, otherwise // our dragged TabContents may be replaced and subsequently @@ -485,8 +486,8 @@ void DefaultTabDragController::Observe( CHECK_NE(delegate, drag_data_[i].original_delegate); return; } - DCHECK_EQ(type, content::NOTIFICATION_TAB_CONTENTS_DESTROYED); - TabContents* destroyed_contents = content::Source<TabContents>(source).ptr(); + DCHECK_EQ(type, content::NOTIFICATION_WEB_CONTENTS_DESTROYED); + WebContents* destroyed_contents = content::Source<WebContents>(source).ptr(); for (size_t i = 0; i < drag_data_.size(); ++i) { if (drag_data_[i].contents->tab_contents() == destroyed_contents) { // One of the tabs we're dragging has been destroyed. Cancel the drag. diff --git a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc b/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc index fbe03da..ff5ca62 100644 --- a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc +++ b/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc @@ -43,6 +43,8 @@ #include "ui/aura/root_window_observer.h" #endif +using content::WebContents; + namespace { const int kDefaultKeyboardHeight = 300; @@ -120,7 +122,7 @@ class KeyboardWidget // Overridden from ExtensionFunctionDispatcher::Delegate. virtual Browser* GetBrowser() OVERRIDE; virtual gfx::NativeView GetNativeViewOfHost() OVERRIDE; - virtual TabContents* GetAssociatedTabContents() const OVERRIDE; + virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; #if defined(OS_CHROMEOS) // Overridden from input_method::InputMethodManager::VirtualKeyboardObserver. @@ -426,7 +428,7 @@ gfx::NativeView KeyboardWidget::GetNativeViewOfHost() { return dom_view_->native_view(); } -TabContents* KeyboardWidget::GetAssociatedTabContents() const { +content::WebContents* KeyboardWidget::GetAssociatedWebContents() const { return dom_view_->dom_contents() ? dom_view_->dom_contents()->tab_contents() : NULL; } diff --git a/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc index 45d11a2..20ca200 100644 --- a/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/change_picture_options_handler.cc @@ -23,6 +23,7 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/url_constants.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" #include "content/public/common/url_constants.h" #include "grit/generated_resources.h" diff --git a/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.cc index 0ad7b66c..5ac62a245d 100644 --- a/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.cc +++ b/chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.cc @@ -23,6 +23,7 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/url_constants.h" +#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" #include "content/public/common/url_constants.h" #include "grit/generated_resources.h" diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h index 06c97da0..565cd61 100644 --- a/chrome/common/chrome_notification_types.h +++ b/chrome/common/chrome_notification_types.h @@ -697,9 +697,9 @@ enum NotificationType { // details are None. NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED, - // Sent when content settings change for a tab. The source is a TabContents - // object, the details are None. - NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED, + // Sent when content settings change for a tab. The source is a + // content::WebContents object, the details are None. + NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, // Sync -------------------------------------------------------------------- diff --git a/content/browser/debugger/render_view_devtools_agent_host.cc b/content/browser/debugger/render_view_devtools_agent_host.cc index fd3574e..72ffe8f 100644 --- a/content/browser/debugger/render_view_devtools_agent_host.cc +++ b/content/browser/debugger/render_view_devtools_agent_host.cc @@ -46,13 +46,13 @@ bool DevToolsAgentHostRegistry::HasDevToolsAgentHost(RenderViewHost* rvh) { return it != g_instances.Get().end(); } -bool DevToolsAgentHostRegistry::IsDebuggerAttached(TabContents* tab_contents) { +bool DevToolsAgentHostRegistry::IsDebuggerAttached(WebContents* web_contents) { if (g_instances == NULL) return false; DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); if (!devtools_manager) return false; - RenderViewHostDelegate* delegate = tab_contents; + RenderViewHostDelegate* delegate = static_cast<TabContents*>(web_contents); for (Instances::iterator it = g_instances.Get().begin(); it != g_instances.Get().end(); ++it) { if (it->first->delegate() != delegate) diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc index ffc2cd7..b09be32 100644 --- a/content/browser/download/save_package.cc +++ b/content/browser/download/save_package.cc @@ -1150,6 +1150,11 @@ const FilePath::CharType* SavePackage::ExtensionForMimeType( return FILE_PATH_LITERAL(""); } +TabContents* SavePackage::tab_contents() const { + return + static_cast<TabContents*>(content::WebContentsObserver::web_contents()); +} + void SavePackage::GetSaveInfo() { // Can't use tab_contents_ in the file thread, so get the data that we need // before calling to it. diff --git a/content/browser/download/save_package.h b/content/browser/download/save_package.h index 5e36b70..e18a160 100644 --- a/content/browser/download/save_package.h +++ b/content/browser/download/save_package.h @@ -122,9 +122,7 @@ class CONTENT_EXPORT SavePackage SavePackageType save_type() const { return save_type_; } int tab_id() const { return tab_id_; } int id() const { return unique_id_; } - TabContents* tab_contents() const { - return content::WebContentsObserver::tab_contents(); - } + TabContents* tab_contents() const; void GetSaveInfo(); diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc index 0b34ede..125d12e3 100644 --- a/content/browser/tab_contents/interstitial_page.cc +++ b/content/browser/tab_contents/interstitial_page.cc @@ -34,6 +34,7 @@ #include "net/url_request/url_request_context_getter.h" using content::BrowserThread; +using content::WebContents; using WebKit::WebDragOperation; using WebKit::WebDragOperationsMask; @@ -205,8 +206,8 @@ void InterstitialPage::Show() { render_view_host_->NavigateToURL(GURL(data_url)); notification_registrar_.Add(this, - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(tab_)); + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(tab_)); notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>(&tab_->GetController())); notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, @@ -279,7 +280,7 @@ void InterstitialPage::Observe(int type, TakeActionOnResourceDispatcher(CANCEL); } break; - case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: + case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: case content::NOTIFICATION_NAV_ENTRY_COMMITTED: if (action_taken_ == NO_ACTION) { // We are navigating away from the interstitial or closing a tab with an diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 3ada454..327f407 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -112,6 +112,7 @@ using content::DevToolsManagerImpl; using content::DownloadItem; using content::DownloadManager; using content::UserMetricsAction; +using content::WebContents; using content::WebContentsObserver; namespace { @@ -244,8 +245,8 @@ TabContents::~TabContents() { // Notify any observer that have a reference on this tab contents. content::NotificationService::current()->Notify( - content::NOTIFICATION_TAB_CONTENTS_DESTROYED, - content::Source<TabContents>(this), + content::NOTIFICATION_WEB_CONTENTS_DESTROYED, + content::Source<WebContents>(this), content::NotificationService::NoDetails()); // TODO(brettw) this should be moved to the view. @@ -347,6 +348,10 @@ void TabContents::SetViewType(content::ViewType type) { view_type_ = type; } +content::ViewType TabContents::GetViewType() const { + return view_type_; +} + const GURL& TabContents::GetURL() const { // We may not have a navigation entry yet NavigationEntry* entry = controller_.GetActiveEntry(); @@ -572,8 +577,8 @@ void TabContents::WasHidden() { } content::NotificationService::current()->Notify( - content::NOTIFICATION_TAB_CONTENTS_HIDDEN, - content::Source<TabContents>(this), + content::NOTIFICATION_WEB_CONTENTS_HIDDEN, + content::Source<WebContents>(this), content::NotificationService::NoDetails()); } diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 26de662..04bc8fc 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -19,8 +19,6 @@ #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager.h" #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/navigation_entry.h" -#include "content/browser/tab_contents/page_navigator.h" #include "content/browser/tab_contents/render_view_host_manager.h" #include "content/common/content_export.h" #include "content/public/browser/web_contents.h" @@ -51,7 +49,6 @@ struct WebIntentData; class CONTENT_EXPORT TabContents : public NON_EXPORTED_BASE(content::WebContents), - public PageNavigator, public RenderViewHostDelegate, public RenderViewHostManager::Delegate, public content::JavaScriptDialogDelegate { @@ -136,6 +133,7 @@ class CONTENT_EXPORT TabContents virtual const NavigationController& GetController() const OVERRIDE; virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; virtual void SetViewType(content::ViewType type) OVERRIDE; + virtual content::ViewType GetViewType() const OVERRIDE; virtual content::RenderProcessHost* GetRenderProcessHost() const OVERRIDE; virtual RenderViewHost* GetRenderViewHost() const OVERRIDE; virtual RenderWidgetHostView* GetRenderWidgetHostView() const OVERRIDE; diff --git a/content/public/browser/DEPS b/content/public/browser/DEPS index 9e39647..ae8cc61 100644 --- a/content/public/browser/DEPS +++ b/content/public/browser/DEPS @@ -9,6 +9,7 @@ include_rules = [ "+content/browser/javascript_dialogs.h", "+content/browser/tab_contents/navigation_controller.h", "+content/browser/tab_contents/navigation_entry.h", + "+content/browser/tab_contents/page_navigator.h", "+content/browser/tab_contents/tab_contents.h", "+content/browser/webui/web_ui.h", ] diff --git a/content/public/browser/devtools_agent_host_registry.h b/content/public/browser/devtools_agent_host_registry.h index 567d32e..1d1e2c2 100644 --- a/content/public/browser/devtools_agent_host_registry.h +++ b/content/public/browser/devtools_agent_host_registry.h @@ -9,11 +9,11 @@ #include "content/common/content_export.h" class RenderViewHost; -class TabContents; namespace content { class DevToolsAgentHost; +class WebContents; class CONTENT_EXPORT DevToolsAgentHostRegistry { public: @@ -31,7 +31,7 @@ class CONTENT_EXPORT DevToolsAgentHostRegistry { int worker_process_id, int worker_route_id); - static bool IsDebuggerAttached(TabContents* tab_contents); + static bool IsDebuggerAttached(WebContents* web_contents); }; } // namespace content diff --git a/content/public/browser/notification_types.h b/content/public/browser/notification_types.h index 0fdaadf..912f2603 100644 --- a/content/public/browser/notification_types.h +++ b/content/public/browser/notification_types.h @@ -205,7 +205,7 @@ enum NotificationType { // Tabs -------------------------------------------------------------------- // Sent when a tab is added to a WebContentsDelegate. The source is the - // WebContentsDelegate and the details is the added TabContents. + // WebContentsDelegate and the details is the added content::WebContents. NOTIFICATION_TAB_ADDED, // This notification is sent after a tab has been appended to the tab_strip. @@ -248,15 +248,15 @@ enum NotificationType { // is a Details<TitleUpdatedDetails> that contains more information. NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED, - // This notification is sent when a TabContents is being hidden, e.g. due - // to switching away from this tab. The source is a Source<TabContents>. - NOTIFICATION_TAB_CONTENTS_HIDDEN, + // This notification is sent when a WebContents is being hidden, e.g. due + // to switching away from this tab. The source is a Source<WebContents>. + NOTIFICATION_WEB_CONTENTS_HIDDEN, - // This notification is sent when a TabContents is being destroyed. Any - // object holding a reference to a TabContents can listen to that + // This notification is sent when a WebContents is being destroyed. Any + // object holding a reference to a WebContents can listen to that // notification to properly reset the reference. The source is a - // Source<TabContents>. - NOTIFICATION_TAB_CONTENTS_DESTROYED, + // Source<WebContents>. + NOTIFICATION_WEB_CONTENTS_DESTROYED, // This notification is sent when a WebContentsDelegate is being // destroyed. The source is a Source<WebContentsDelegate>. diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h index 113e6a4..0aa3196 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -11,7 +11,9 @@ #include "base/string16.h" #include "content/browser/download/save_package.h" #include "content/browser/tab_contents/navigation_entry.h" +#include "content/browser/tab_contents/page_navigator.h" #include "content/browser/webui/web_ui.h" +#include "content/public/common/view_type.h" #include "content/common/content_export.h" #include "ui/gfx/native_widget_types.h" #include "webkit/glue/window_open_disposition.h" @@ -47,7 +49,7 @@ class WebContentsDelegate; struct RendererPreferences; // Describes what goes in the main content area of a tab. -class WebContents { +class WebContents : public PageNavigator { public: virtual ~WebContents() {} @@ -73,6 +75,10 @@ class WebContents { // Allows overriding the type of this tab. virtual void SetViewType(content::ViewType type) = 0; + virtual content::ViewType GetViewType() const = 0; + + // Gets the URL that is currently being displayed, if there is one. + virtual const GURL& GetURL() const = 0; // Return the currently active RenderProcessHost and RenderViewHost. Each of // these may change over time. diff --git a/content/public/browser/web_contents_observer.cc b/content/public/browser/web_contents_observer.cc index fb76750..ecbb3bf 100644 --- a/content/public/browser/web_contents_observer.cc +++ b/content/public/browser/web_contents_observer.cc @@ -24,6 +24,10 @@ WebContentsObserver::~WebContentsObserver() { tab_contents_->RemoveObserver(this); } +WebContents* WebContentsObserver::web_contents() const { + return tab_contents_; +} + void WebContentsObserver::Observe(WebContents* web_contents) { if (tab_contents_) tab_contents_->RemoveObserver(this); diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h index 253f6a6..cc44ca0 100644 --- a/content/public/browser/web_contents_observer.h +++ b/content/public/browser/web_contents_observer.h @@ -119,6 +119,8 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Channel::Listener, // Start observing a different WebContents; used with the default constructor. void Observe(WebContents* web_contents); + WebContents* web_contents() const; + // TODO(jam): remove me TabContents* tab_contents() const { return tab_contents_; } private: |