diff options
51 files changed, 286 insertions, 243 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index b865594..3278c5b 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -1150,7 +1150,7 @@ FindInPageNotificationObserver::FindInPageNotificationObserver( reply_with_json_(reply_with_json), reply_message_(reply_message) { registrar_.Add(this, chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, - content::Source<TabContents>(parent_tab)); + content::Source<WebContents>(parent_tab)); } FindInPageNotificationObserver::~FindInPageNotificationObserver() { @@ -1363,11 +1363,11 @@ void MetricEventDurationObserver::Observe( PageTranslatedObserver::PageTranslatedObserver(AutomationProvider* automation, IPC::Message* reply_message, - TabContents* tab_contents) + WebContents* web_contents) : automation_(automation->AsWeakPtr()), reply_message_(reply_message) { registrar_.Add(this, chrome::NOTIFICATION_PAGE_TRANSLATED, - content::Source<TabContents>(tab_contents)); + content::Source<WebContents>(web_contents)); } PageTranslatedObserver::~PageTranslatedObserver() {} @@ -1402,7 +1402,7 @@ TabLanguageDeterminedObserver::TabLanguageDeterminedObserver( tab_contents_(tab_contents), translate_bar_(translate_bar) { registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, - content::Source<TabContents>(tab_contents)); + content::Source<WebContents>(tab_contents)); } TabLanguageDeterminedObserver::~TabLanguageDeterminedObserver() {} diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index fea57b1..8fa92b3 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -74,14 +74,18 @@ namespace chromeos { } #endif // defined(OS_CHROMEOS) -namespace history { -class TopSites; -} - namespace IPC { class Message; } +namespace content { +class WebContents; +} + +namespace history { +class TopSites; +} + namespace policy { class BrowserPolicyConnector; } @@ -686,7 +690,7 @@ class PageTranslatedObserver : public content::NotificationObserver { public: PageTranslatedObserver(AutomationProvider* automation, IPC::Message* reply_message, - TabContents* tab_contents); + content::WebContents* web_contents); virtual ~PageTranslatedObserver(); // content::NotificationObserver interface. diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index ecb1134..7732c2dd 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -4103,7 +4103,7 @@ void TestingAutomationProvider::GetTranslateInfo( std::string language = helper->language_state().original_language(); if (!language.empty()) { observer->Observe(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, - content::Source<TabContents>(tab_contents), + content::Source<WebContents>(tab_contents), content::Details<std::string>(&language)); } } diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 97ffa2d..85ff76a 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -1630,7 +1630,7 @@ bool DetectTabLanguageFunction::RunImpl() { // The tab contents does not know its language yet. Let's wait until it // receives it, or until the tab is closed/navigates to some other page. registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, - content::Source<TabContents>(contents->tab_contents())); + content::Source<WebContents>(contents->tab_contents())); registrar_.Add( this, content::NOTIFICATION_TAB_CLOSING, content::Source<NavigationController>( diff --git a/chrome/browser/extensions/extension_webnavigation_api.cc b/chrome/browser/extensions/extension_webnavigation_api.cc index a74d742..87df8e5 100644 --- a/chrome/browser/extensions/extension_webnavigation_api.cc +++ b/chrome/browser/extensions/extension_webnavigation_api.cc @@ -416,8 +416,8 @@ void ExtensionWebNavigationEventRouter::Retargeting( ExtensionWebNavigationTabObserver* tab_observer = ExtensionWebNavigationTabObserver::Get(details->source_web_contents); if (!tab_observer) { - CHECK(details->source_web_contents->GetRenderViewHost()->delegate()-> - GetRenderViewType() != content::VIEW_TYPE_TAB_CONTENTS); + CHECK(details->source_web_contents->GetViewType() != + content::VIEW_TYPE_TAB_CONTENTS); return; } const FrameNavigationState& frame_navigation_state = diff --git a/chrome/browser/plugin_observer.cc b/chrome/browser/plugin_observer.cc index 726355a..61c3fb31 100644 --- a/chrome/browser/plugin_observer.cc +++ b/chrome/browser/plugin_observer.cc @@ -352,9 +352,9 @@ void PluginObserver::DidNotFindMissingPlugin(int placeholder_id, void PluginObserver::InstallMissingPlugin(PluginInstaller* installer) { if (installer->url_for_display()) { - tab_contents()->OpenURL(OpenURLParams( + web_contents()->OpenURL(OpenURLParams( installer->plugin_url(), - content::Referrer(tab_contents()->GetURL(), + content::Referrer(web_contents()->GetURL(), WebKit::WebReferrerPolicyDefault), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED, false)); } else { diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc index 243d3ab..263f3bc 100644 --- a/chrome/browser/prerender/prerender_contents.cc +++ b/chrome/browser/prerender/prerender_contents.cc @@ -38,6 +38,7 @@ #endif using content::DownloadItem; +using content::WebContents; namespace prerender { @@ -330,7 +331,7 @@ void PrerenderContents::StartPrerendering( // Register for redirect notifications sourced from |this|. notification_registrar_.Add( this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, - content::Source<RenderViewHostDelegate>(GetRenderViewHostDelegate())); + content::Source<WebContents>(GetWebContents())); // Register for new windows from any source. notification_registrar_.Add( @@ -424,8 +425,7 @@ void PrerenderContents::Observe(int type, // to be remembered for future matching, and if it redirects to // an https resource, it needs to be canceled. If a subresource // is redirected, nothing changes. - DCHECK(content::Source<RenderViewHostDelegate>(source).ptr() == - GetRenderViewHostDelegate()); + DCHECK(content::Source<WebContents>(source).ptr() == GetWebContents()); ResourceRedirectDetails* resource_redirect_details = content::Details<ResourceRedirectDetails>(details).ptr(); CHECK(resource_redirect_details); @@ -659,7 +659,7 @@ TabContentsWrapper* PrerenderContents::ReleasePrerenderContents() { return prerender_contents_.release(); } -RenderViewHostDelegate* PrerenderContents::GetRenderViewHostDelegate() { +WebContents* PrerenderContents::GetWebContents() { if (!prerender_contents_.get()) return NULL; return prerender_contents_->tab_contents(); diff --git a/chrome/browser/prerender/prerender_contents.h b/chrome/browser/prerender/prerender_contents.h index d2b887e..b6214ea 100644 --- a/chrome/browser/prerender/prerender_contents.h +++ b/chrome/browser/prerender/prerender_contents.h @@ -223,7 +223,7 @@ class PrerenderContents : public content::NotificationObserver, void OnUpdateFaviconURL(int32 page_id, const std::vector<FaviconURL>& urls); // Returns the RenderViewHost Delegate for this prerender. - RenderViewHostDelegate* GetRenderViewHostDelegate(); + content::WebContents* GetWebContents(); // Returns the ProcessMetrics for the render process, if it exists. base::ProcessMetrics* MaybeGetProcessMetrics(); diff --git a/chrome/browser/safe_browsing/browser_feature_extractor.cc b/chrome/browser/safe_browsing/browser_feature_extractor.cc index 85ce0e2b..dc182be 100644 --- a/chrome/browser/safe_browsing/browser_feature_extractor.cc +++ b/chrome/browser/safe_browsing/browser_feature_extractor.cc @@ -21,12 +21,13 @@ #include "chrome/browser/safe_browsing/client_side_detection_service.h" #include "chrome/common/safe_browsing/csd.pb.h" #include "content/browser/cancelable_request.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/web_contents.h" #include "content/public/common/page_transition_types.h" #include "googleurl/src/gurl.h" using content::BrowserThread; +using content::WebContents; namespace safe_browsing { @@ -107,7 +108,7 @@ static void AddNavigationFeatures(const std::string& feature_prefix, } BrowserFeatureExtractor::BrowserFeatureExtractor( - TabContents* tab, + WebContents* tab, ClientSideDetectionService* service) : tab_(tab), service_(service), diff --git a/chrome/browser/safe_browsing/browser_feature_extractor.h b/chrome/browser/safe_browsing/browser_feature_extractor.h index 9b6ec72..1009e57 100644 --- a/chrome/browser/safe_browsing/browser_feature_extractor.h +++ b/chrome/browser/safe_browsing/browser_feature_extractor.h @@ -28,7 +28,10 @@ #include "googleurl/src/gurl.h" class HistoryService; -class TabContents; + +namespace content { +class WebContents; +} namespace safe_browsing { class ClientPhishingRequest; @@ -69,7 +72,7 @@ class BrowserFeatureExtractor { // The caller keeps ownership of the tab and service objects and is // responsible for ensuring that they stay valid for the entire // lifetime of this object. - BrowserFeatureExtractor(TabContents* tab, + BrowserFeatureExtractor(content::WebContents* tab, ClientSideDetectionService* service); // The destructor will cancel any pending requests. @@ -146,7 +149,7 @@ class BrowserFeatureExtractor { // is set it will return true and false otherwise. bool GetHistoryService(HistoryService** history); - TabContents* tab_; + content::WebContents* tab_; ClientSideDetectionService* service_; CancelableRequestConsumer request_consumer_; base::WeakPtrFactory<BrowserFeatureExtractor> weak_factory_; diff --git a/chrome/browser/safe_browsing/client_side_detection_host.cc b/chrome/browser/safe_browsing/client_side_detection_host.cc index 765e0fe..e0f1109 100644 --- a/chrome/browser/safe_browsing/client_side_detection_host.cc +++ b/chrome/browser/safe_browsing/client_side_detection_host.cc @@ -25,13 +25,13 @@ #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_request_details.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/render_process_host.h" +#include "content/public/browser/web_contents.h" #include "content/public/common/frame_navigate_params.h" #include "googleurl/src/gurl.h" @@ -52,18 +52,18 @@ class ClientSideDetectionHost::ShouldClassifyUrlRequest ClientSideDetectionHost::ShouldClassifyUrlRequest> { public: ShouldClassifyUrlRequest(const content::FrameNavigateParams& params, - TabContents* tab_contents, + WebContents* web_contents, ClientSideDetectionService* csd_service, SafeBrowsingService* sb_service, ClientSideDetectionHost* host) : canceled_(false), params_(params), - tab_contents_(tab_contents), + web_contents_(web_contents), csd_service_(csd_service), sb_service_(sb_service), host_(host) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(tab_contents_); + DCHECK(web_contents_); DCHECK(csd_service_); DCHECK(sb_service_); DCHECK(host_); @@ -98,7 +98,7 @@ class ClientSideDetectionHost::ShouldClassifyUrlRequest } // Don't run the phishing classifier if the tab is incognito. - if (tab_contents_->GetBrowserContext()->IsOffTheRecord()) { + if (web_contents_->GetBrowserContext()->IsOffTheRecord()) { VLOG(1) << "Skipping phishing classification for URL: " << params_.url << " because we're browsing incognito."; UMA_HISTOGRAM_ENUMERATION("SBClientPhishing.PreClassificationCheckFail", @@ -125,7 +125,7 @@ class ClientSideDetectionHost::ShouldClassifyUrlRequest // Just to make sure we don't do anything stupid we reset all these // pointers except for the safebrowsing service class which may be // accessed by CheckCsdWhitelist(). - tab_contents_ = NULL; + web_contents_ = NULL; csd_service_ = NULL; host_ = NULL; } @@ -201,11 +201,11 @@ class ClientSideDetectionHost::ShouldClassifyUrlRequest } // Everything checks out, so start classification. - // |tab_contents_| is safe to call as we will be destructed + // |web_contents_| is safe to call as we will be destructed // before it is. VLOG(1) << "Instruct renderer to start phishing detection for URL: " << params_.url; - RenderViewHost* rvh = tab_contents_->GetRenderViewHost(); + RenderViewHost* rvh = web_contents_->GetRenderViewHost(); rvh->Send(new SafeBrowsingMsg_StartPhishingDetection( rvh->routing_id(), params_.url)); } @@ -214,7 +214,7 @@ class ClientSideDetectionHost::ShouldClassifyUrlRequest // written by the UI thread. bool canceled_; content::FrameNavigateParams params_; - TabContents* tab_contents_; + WebContents* web_contents_; ClientSideDetectionService* csd_service_; // We keep a ref pointer here just to make sure the service class stays alive // long enough. @@ -252,11 +252,11 @@ class CsdClient : public SafeBrowsingService::Client { // static ClientSideDetectionHost* ClientSideDetectionHost::Create( - TabContents* tab) { + WebContents* tab) { return new ClientSideDetectionHost(tab); } -ClientSideDetectionHost::ClientSideDetectionHost(TabContents* tab) +ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab) : content::WebContentsObserver(tab), csd_service_(NULL), weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), @@ -267,7 +267,7 @@ ClientSideDetectionHost::ClientSideDetectionHost(TabContents* tab) sb_service_ = g_browser_process->safe_browsing_service(); // Note: csd_service_ and sb_service_ will be NULL here in testing. registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED, - content::Source<RenderViewHostDelegate>(tab)); + content::Source<WebContents>(tab)); if (sb_service_) { sb_service_->AddObserver(this); } @@ -292,7 +292,7 @@ bool ClientSideDetectionHost::OnMessageReceived(const IPC::Message& message) { void ClientSideDetectionHost::DidNavigateMainFrame( const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) { - // TODO(noelutz): move this DCHECK to TabContents and fix all the unit tests + // TODO(noelutz): move this DCHECK to WebContents and fix all the unit tests // that don't call this method on the UI thread. // DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (details.is_in_page) { @@ -329,7 +329,7 @@ void ClientSideDetectionHost::DidNavigateMainFrame( // Notify the renderer if it should classify this URL. classification_request_ = new ShouldClassifyUrlRequest(params, - tab_contents(), + web_contents(), csd_service_, sb_service_, this); @@ -341,16 +341,16 @@ void ClientSideDetectionHost::OnSafeBrowsingHit( // Check that this notification is really for us and that it corresponds to // either a malware or phishing hit. In this case we store the unique page // ID for later. - if (tab_contents() && - tab_contents()->GetRenderProcessHost()->GetID() == + if (web_contents() && + web_contents()->GetRenderProcessHost()->GetID() == resource.render_process_host_id && - tab_contents()->GetRenderViewHost()->routing_id() == + web_contents()->GetRenderViewHost()->routing_id() == resource.render_view_id && (resource.threat_type == SafeBrowsingService::URL_PHISHING || resource.threat_type == SafeBrowsingService::URL_MALWARE) && - tab_contents()->GetController().GetActiveEntry()) { + web_contents()->GetController().GetActiveEntry()) { unsafe_unique_page_id_ = - tab_contents()->GetController().GetActiveEntry()->GetUniqueID(); + web_contents()->GetController().GetActiveEntry()->GetUniqueID(); // We also keep the resource around in order to be able to send the // malicious URL to the server. unsafe_resource_.reset(new SafeBrowsingService::UnsafeResource(resource)); @@ -413,7 +413,7 @@ void ClientSideDetectionHost::MaybeShowPhishingWarning(GURL phishing_url, VLOG(2) << "Received server phishing verdict for URL:" << phishing_url << " is_phishing:" << is_phishing; if (is_phishing) { - DCHECK(tab_contents()); + DCHECK(web_contents()); if (sb_service_) { SafeBrowsingService::UnsafeResource resource; resource.url = phishing_url; @@ -421,13 +421,13 @@ void ClientSideDetectionHost::MaybeShowPhishingWarning(GURL phishing_url, resource.is_subresource = false; resource.threat_type = SafeBrowsingService::CLIENT_SIDE_PHISHING_URL; resource.render_process_host_id = - tab_contents()->GetRenderProcessHost()->GetID(); + web_contents()->GetRenderProcessHost()->GetID(); resource.render_view_id = - tab_contents()->GetRenderViewHost()->routing_id(); + web_contents()->GetRenderViewHost()->routing_id(); if (!sb_service_->IsWhitelisted(resource)) { // We need to stop any pending navigations, otherwise the interstital // might not get created properly. - tab_contents()->GetController().DiscardNonCommittedEntries(); + web_contents()->GetController().DiscardNonCommittedEntries(); resource.client = new CsdClient(); // Will delete itself sb_service_->DoDisplayBlockingPage(resource); } @@ -471,11 +471,11 @@ void ClientSideDetectionHost::Observe( } bool ClientSideDetectionHost::DidShowSBInterstitial() { - if (unsafe_unique_page_id_ <= 0 || !tab_contents()) { + if (unsafe_unique_page_id_ <= 0 || !web_contents()) { return false; } const NavigationEntry* nav_entry = - tab_contents()->GetController().GetActiveEntry(); + web_contents()->GetController().GetActiveEntry(); return (nav_entry && nav_entry->GetUniqueID() == unsafe_unique_page_id_); } diff --git a/chrome/browser/safe_browsing/client_side_detection_host.h b/chrome/browser/safe_browsing/client_side_detection_host.h index 6943732..7e445e1 100644 --- a/chrome/browser/safe_browsing/client_side_detection_host.h +++ b/chrome/browser/safe_browsing/client_side_detection_host.h @@ -34,8 +34,8 @@ class ClientSideDetectionHost : public content::WebContentsObserver, public SafeBrowsingService::Observer { public: // The caller keeps ownership of the tab object and is responsible for - // ensuring that it stays valid until TabContentsDestroyed is called. - static ClientSideDetectionHost* Create(TabContents* tab); + // ensuring that it stays valid until WebContentsDestroyed is called. + static ClientSideDetectionHost* Create(content::WebContents* tab); virtual ~ClientSideDetectionHost(); // From content::WebContentsObserver. @@ -62,7 +62,7 @@ class ClientSideDetectionHost : public content::WebContentsObserver, class ShouldClassifyUrlRequest; friend class ShouldClassifyUrlRequest; - explicit ClientSideDetectionHost(TabContents* tab); + explicit ClientSideDetectionHost(content::WebContents* tab); // Verdict is an encoded ClientPhishingRequest protocol message. void OnPhishingDetectionDone(const std::string& verdict); diff --git a/chrome/browser/safe_browsing/malware_details.cc b/chrome/browser/safe_browsing/malware_details.cc index 983c1d9..4a34844 100644 --- a/chrome/browser/safe_browsing/malware_details.cc +++ b/chrome/browser/safe_browsing/malware_details.cc @@ -17,13 +17,14 @@ #include "chrome/common/safe_browsing/safebrowsing_messages.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/navigation_entry.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/web_contents.h" #include "net/base/io_buffer.h" #include "net/disk_cache/disk_cache.h" #include "net/url_request/url_request_context_getter.h" using content::BrowserThread; +using content::WebContents; using safe_browsing::ClientMalwareReportRequest; // Keep in sync with KMaxNodes in renderer/safe_browsing/malware_dom_details @@ -39,9 +40,9 @@ class MalwareDetailsFactoryImpl public: MalwareDetails* CreateMalwareDetails( SafeBrowsingService* sb_service, - TabContents* tab_contents, + WebContents* web_contents, const SafeBrowsingService::UnsafeResource& unsafe_resource) { - return new MalwareDetails(sb_service, tab_contents, unsafe_resource); + return new MalwareDetails(sb_service, web_contents, unsafe_resource); } private: @@ -60,22 +61,22 @@ static base::LazyInstance<MalwareDetailsFactoryImpl> /* static */ MalwareDetails* MalwareDetails::NewMalwareDetails( SafeBrowsingService* sb_service, - TabContents* tab_contents, + WebContents* web_contents, const SafeBrowsingService::UnsafeResource& resource) { // Set up the factory if this has not been done already (tests do that // before this method is called). if (!factory_) factory_ = g_malware_details_factory_impl.Pointer(); - return factory_->CreateMalwareDetails(sb_service, tab_contents, resource); + return factory_->CreateMalwareDetails(sb_service, web_contents, resource); } // Create a MalwareDetails for the given tab. Runs in the UI thread. MalwareDetails::MalwareDetails( SafeBrowsingService* sb_service, - TabContents* tab_contents, + content::WebContents* web_contents, const SafeBrowsingService::UnsafeResource& resource) - : content::WebContentsObserver(tab_contents), - profile_(Profile::FromBrowserContext(tab_contents->GetBrowserContext())), + : content::WebContentsObserver(web_contents), + profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), request_context_getter_(profile_->GetRequestContext()), sb_service_(sb_service), resource_(resource), @@ -161,13 +162,13 @@ void MalwareDetails::StartCollection() { report_->set_malware_url(resource_.url.spec()); } - GURL page_url = tab_contents()->GetURL(); + GURL page_url = web_contents()->GetURL(); if (IsPublicUrl(page_url)) { report_->set_page_url(page_url.spec()); } GURL referrer_url; - NavigationEntry* nav_entry = tab_contents()->GetController().GetActiveEntry(); + NavigationEntry* nav_entry = web_contents()->GetController().GetActiveEntry(); if (nav_entry) { referrer_url = nav_entry->GetReferrer().url; if (IsPublicUrl(referrer_url)) { @@ -210,7 +211,7 @@ void MalwareDetails::StartCollection() { // Get URLs of frames, scripts etc from the DOM. // OnReceivedMalwareDOMDetails will be called when the renderer replies. - RenderViewHost* view = tab_contents()->GetRenderViewHost(); + RenderViewHost* view = web_contents()->GetRenderViewHost(); view->Send(new SafeBrowsingMsg_GetMalwareDOMDetails(view->routing_id())); } diff --git a/chrome/browser/safe_browsing/malware_details.h b/chrome/browser/safe_browsing/malware_details.h index 8a40109..a195f8a 100644 --- a/chrome/browser/safe_browsing/malware_details.h +++ b/chrome/browser/safe_browsing/malware_details.h @@ -44,7 +44,7 @@ class MalwareDetails : public base::RefCountedThreadSafe<MalwareDetails>, // Constructs a new MalwareDetails instance, using the factory. static MalwareDetails* NewMalwareDetails( SafeBrowsingService* sb_service, - TabContents* tab_contents, + content::WebContents* web_contents, const SafeBrowsingService::UnsafeResource& resource); // Makes the passed |factory| the factory used to instanciate @@ -71,7 +71,7 @@ class MalwareDetails : public base::RefCountedThreadSafe<MalwareDetails>, friend class MalwareDetailsFactoryImpl; MalwareDetails(SafeBrowsingService* sb_service, - TabContents* tab_contents, + content::WebContents* web_contents, const SafeBrowsingService::UnsafeResource& resource); virtual ~MalwareDetails(); @@ -153,7 +153,7 @@ class MalwareDetailsFactory { virtual MalwareDetails* CreateMalwareDetails( SafeBrowsingService* sb_service, - TabContents* tab_contents, + content::WebContents* web_contents, const SafeBrowsingService::UnsafeResource& unsafe_resource) = 0; }; diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc index ebf3162..ff2cf92 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc @@ -26,6 +26,7 @@ #include "content/test/test_browser_thread.h" using content::BrowserThread; +using content::WebContents; // A SafeBrowingService class that allows us to inject the malicious URLs. class FakeSafeBrowsingService : public SafeBrowsingService { @@ -102,9 +103,9 @@ class TestSafeBrowsingServiceFactory : public SafeBrowsingServiceFactory { class FakeMalwareDetails : public MalwareDetails { public: FakeMalwareDetails(SafeBrowsingService* sb_service, - TabContents* tab_contents, + WebContents* web_contents, const SafeBrowsingService::UnsafeResource& unsafe_resource) - : MalwareDetails(sb_service, tab_contents, unsafe_resource) { } + : MalwareDetails(sb_service, web_contents, unsafe_resource) { } virtual ~FakeMalwareDetails() {} @@ -161,9 +162,9 @@ class TestMalwareDetailsFactory : public MalwareDetailsFactory { virtual MalwareDetails* CreateMalwareDetails( SafeBrowsingService* sb_service, - TabContents* tab_contents, + WebContents* web_contents, const SafeBrowsingService::UnsafeResource& unsafe_resource) { - details_ = new FakeMalwareDetails(sb_service, tab_contents, + details_ = new FakeMalwareDetails(sb_service, web_contents, unsafe_resource); return details_; } diff --git a/chrome/browser/tab_contents/thumbnail_generator.cc b/chrome/browser/tab_contents/thumbnail_generator.cc index b9c6eea..1cbdf18 100644 --- a/chrome/browser/tab_contents/thumbnail_generator.cc +++ b/chrome/browser/tab_contents/thumbnail_generator.cc @@ -50,6 +50,8 @@ // We'll likely revise the algorithm to improve quality of thumbnails this // service generates. +using content::WebContents; + namespace { static const int kThumbnailWidth = 212; @@ -360,12 +362,12 @@ void ThumbnailGenerator::Observe(int type, } void ThumbnailGenerator::WidgetHidden(RenderWidgetHost* widget) { - // tab_contents_ can be NULL, if StartThumbnailing() is not called, but + // web_contents() can be NULL, if StartThumbnailing() is not called, but // MonitorRenderer() is called. The use case is found in // chrome/test/base/ui_test_utils.cc. - if (!tab_contents()) + if (!web_contents()) return; - UpdateThumbnailIfNecessary(tab_contents()); + UpdateThumbnailIfNecessary(web_contents()); } void ThumbnailGenerator::TabContentsDisconnected(TabContents* contents) { @@ -446,10 +448,10 @@ SkBitmap ThumbnailGenerator::GetClippedBitmap(const SkBitmap& bitmap, } void ThumbnailGenerator::UpdateThumbnailIfNecessary( - TabContents* tab_contents) { - const GURL& url = tab_contents->GetURL(); + WebContents* web_contents) { + const GURL& url = web_contents->GetURL(); Profile* profile = - Profile::FromBrowserContext(tab_contents->GetBrowserContext()); + Profile::FromBrowserContext(web_contents->GetBrowserContext()); history::TopSites* top_sites = profile->GetTopSites(); // Skip if we don't need to update the thumbnail. if (!ShouldUpdateThumbnail(profile, top_sites, url)) @@ -458,7 +460,7 @@ void ThumbnailGenerator::UpdateThumbnailIfNecessary( const int options = ThumbnailGenerator::kClippedThumbnail; ThumbnailGenerator::ClipResult clip_result = ThumbnailGenerator::kNotClipped; SkBitmap thumbnail = GetThumbnailForRendererWithOptions( - tab_contents->GetRenderViewHost(), options, &clip_result); + web_contents->GetRenderViewHost(), options, &clip_result); // Failed to generate a thumbnail. Maybe the tab is in the background? if (thumbnail.isNull()) return; @@ -466,12 +468,12 @@ void ThumbnailGenerator::UpdateThumbnailIfNecessary( // Compute the thumbnail score. ThumbnailScore score; score.at_top = - (tab_contents->GetRenderViewHost()->last_scroll_offset().y() == 0); + (web_contents->GetRenderViewHost()->last_scroll_offset().y() == 0); score.boring_score = ThumbnailGenerator::CalculateBoringScore(&thumbnail); score.good_clipping = (clip_result == ThumbnailGenerator::kTallerThanWide || clip_result == ThumbnailGenerator::kNotClipped); - score.load_completed = (!load_interrupted_ && !tab_contents->IsLoading()); + score.load_completed = (!load_interrupted_ && !web_contents->IsLoading()); gfx::Image image(new SkBitmap(thumbnail)); top_sites->SetPageThumbnail(url, &image, score); diff --git a/chrome/browser/tab_contents/thumbnail_generator.h b/chrome/browser/tab_contents/thumbnail_generator.h index 79cb19c..7140357 100644 --- a/chrome/browser/tab_contents/thumbnail_generator.h +++ b/chrome/browser/tab_contents/thumbnail_generator.h @@ -115,7 +115,7 @@ class ThumbnailGenerator : public content::NotificationObserver, ClipResult* clip_result); // Update the thumbnail of the given tab contents if necessary. - void UpdateThumbnailIfNecessary(TabContents* tab_contents); + void UpdateThumbnailIfNecessary(content::WebContents* webb_contents); // Returns true if we should update the thumbnail of the given URL. static bool ShouldUpdateThumbnail(Profile* profile, diff --git a/chrome/browser/tabs/tab_finder.cc b/chrome/browser/tabs/tab_finder.cc index c4f0959..c77e184 100644 --- a/chrome/browser/tabs/tab_finder.cc +++ b/chrome/browser/tabs/tab_finder.cc @@ -28,11 +28,11 @@ using content::WebContents; class TabFinder::WebContentsObserverImpl : public content::WebContentsObserver { public: - WebContentsObserverImpl(TabContents* tab, TabFinder* finder); + WebContentsObserverImpl(WebContents* tab, TabFinder* finder); virtual ~WebContentsObserverImpl(); - TabContents* tab_contents() { - return content::WebContentsObserver::tab_contents(); + WebContents* web_contents() { + return content::WebContentsObserver::web_contents(); } // content::WebContentsObserver overrides: @@ -48,7 +48,7 @@ class TabFinder::WebContentsObserverImpl : public content::WebContentsObserver { }; TabFinder::WebContentsObserverImpl::WebContentsObserverImpl( - TabContents* tab, + WebContents* tab, TabFinder* finder) : content::WebContentsObserver(tab), finder_(finder) { @@ -60,7 +60,7 @@ TabFinder::WebContentsObserverImpl::~WebContentsObserverImpl() { void TabFinder::WebContentsObserverImpl::DidNavigateAnyFrame( const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) { - finder_->DidNavigateAnyFrame(tab_contents(), details, params); + finder_->DidNavigateAnyFrame(web_contents(), details, params); } void TabFinder::WebContentsObserverImpl::WebContentsDestroyed( @@ -122,7 +122,7 @@ void TabFinder::Observe(int type, // The tab was added to a browser. Query for its state now. TabContentsWrapper* tab = content::Source<TabContentsWrapper>(source).ptr(); - TrackTab(tab->tab_contents()); + TrackTab(tab->web_contents()); } TabFinder::TabFinder() { @@ -135,7 +135,7 @@ TabFinder::~TabFinder() { } void TabFinder::DidNavigateAnyFrame( - TabContents* source, + WebContents* source, const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) { CancelRequestsFor(source); @@ -145,17 +145,17 @@ void TabFinder::DidNavigateAnyFrame( FetchRedirectStart(source); } else if (params.redirects.size() > 1 || params.redirects[0] != details.entry->GetURL()) { - tab_contents_to_url_[source] = params.redirects[0]; + web_contents_to_url_[source] = params.redirects[0]; } } -bool TabFinder::TabMatchesURL(TabContents* tab_contents, const GURL& url) { +bool TabFinder::TabMatchesURL(WebContents* tab_contents, const GURL& url) { if (tab_contents->GetURL() == url) return true; - TabContentsToURLMap::const_iterator i = - tab_contents_to_url_.find(tab_contents); - return i != tab_contents_to_url_.end() && i->second == url; + WebContentsToURLMap::const_iterator i = + web_contents_to_url_.find(tab_contents); + return i != web_contents_to_url_.end() && i->second == url; } TabContents* TabFinder::FindTabInBrowser(Browser* browser, const GURL& url) { @@ -169,10 +169,10 @@ TabContents* TabFinder::FindTabInBrowser(Browser* browser, const GURL& url) { return NULL; } -void TabFinder::TrackTab(TabContents* tab) { +void TabFinder::TrackTab(WebContents* tab) { for (WebContentsObservers::const_iterator i = tab_contents_observers_.begin(); i != tab_contents_observers_.end(); ++i) { - if ((*i)->tab_contents() == tab) { + if ((*i)->web_contents() == tab) { // Already tracking the tab. return; } @@ -187,26 +187,26 @@ void TabFinder::TabDestroyed(WebContentsObserverImpl* observer) { tab_contents_observers_.erase(observer); } -void TabFinder::CancelRequestsFor(TabContents* tab_contents) { +void TabFinder::CancelRequestsFor(WebContents* web_contents) { Profile* profile = - Profile::FromBrowserContext(tab_contents->GetBrowserContext()); + Profile::FromBrowserContext(web_contents->GetBrowserContext()); if (profile->IsOffTheRecord()) return; - tab_contents_to_url_.erase(tab_contents); + web_contents_to_url_.erase(web_contents); HistoryService* history = profile->GetHistoryService( Profile::EXPLICIT_ACCESS); if (history) { CancelableRequestProvider::Handle request_handle; - if (callback_consumer_.GetFirstHandleForClientData(tab_contents, + if (callback_consumer_.GetFirstHandleForClientData(web_contents, &request_handle)) { history->CancelRequest(request_handle); } } } -void TabFinder::FetchRedirectStart(TabContents* tab) { +void TabFinder::FetchRedirectStart(WebContents* tab) { Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); if (profile->IsOffTheRecord()) return; @@ -234,9 +234,9 @@ void TabFinder::QueryRedirectsToComplete(HistoryService::Handle handle, bool success, history::RedirectList* redirects) { if (success && !redirects->empty()) { - TabContents* tab_contents = + WebContents* web_contents = callback_consumer_.GetClientDataForCurrentRequest(); - DCHECK(tab_contents); - tab_contents_to_url_[tab_contents] = redirects->back(); + DCHECK(web_contents); + web_contents_to_url_[web_contents] = redirects->back(); } } diff --git a/chrome/browser/tabs/tab_finder.h b/chrome/browser/tabs/tab_finder.h index b89ceb3..1338ce3 100644 --- a/chrome/browser/tabs/tab_finder.h +++ b/chrome/browser/tabs/tab_finder.h @@ -21,6 +21,7 @@ class GURL; class TabContents; namespace content { +class WebContents; struct FrameNavigateParams; struct LoadCommittedDetails; } @@ -55,7 +56,7 @@ class TabFinder : public content::NotificationObserver { class WebContentsObserverImpl; - typedef std::map<TabContents*, GURL> TabContentsToURLMap; + typedef std::map<content::WebContents*, GURL> WebContentsToURLMap; typedef std::set<WebContentsObserverImpl*> WebContentsObservers; TabFinder(); @@ -63,13 +64,13 @@ class TabFinder : public content::NotificationObserver { // Forwarded from WebContentsObserverImpl. void DidNavigateAnyFrame( - TabContents* source, + content::WebContents* source, const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params); // Returns true if the tab's current url is |url|, or the start of the // redirect chain for the tab is |url|. - bool TabMatchesURL(TabContents* tab_contents, const GURL& url); + bool TabMatchesURL(content::WebContents* web_contents, const GURL& url); // Returns the first tab in the specified browser that matches the specified // url. Returns NULL if there are no tabs matching the specified url. @@ -77,17 +78,17 @@ class TabFinder : public content::NotificationObserver { // If we're not currently tracking |tab| this creates a // WebContentsObserverImpl to listen for navigations. - void TrackTab(TabContents* tab); + void TrackTab(content::WebContents* tab); // Invoked when a TabContents is being destroyed. void TabDestroyed(WebContentsObserverImpl* observer); // Cancels any pending requests for the specified tabs redirect chain. - void CancelRequestsFor(TabContents* tab_contents); + void CancelRequestsFor(content::WebContents* web_contents); - // Starts the fetch for the redirect chain of the specified TabContents. + // Starts the fetch for the redirect chain of the specified WebContents. // QueryRedirectsToComplete is invoked when the redirect chain is retrieved. - void FetchRedirectStart(TabContents* tab); + void FetchRedirectStart(content::WebContents* tab); // Callback when we get the redirect list for a tab. void QueryRedirectsToComplete(CancelableRequestProvider::Handle handle, @@ -95,10 +96,10 @@ class TabFinder : public content::NotificationObserver { bool success, history::RedirectList* redirects); - // Maps from TabContents to the start of the redirect chain. - TabContentsToURLMap tab_contents_to_url_; + // Maps from WebContents to the start of the redirect chain. + WebContentsToURLMap web_contents_to_url_; - CancelableRequestConsumerTSimple<TabContents*> callback_consumer_; + CancelableRequestConsumerTSimple<content::WebContents*> callback_consumer_; content::NotificationRegistrar registrar_; diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index dcbcb63..61dcb77 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -302,7 +302,7 @@ void TranslateManager::Observe(int type, break; } case chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED: { - TabContents* tab = content::Source<TabContents>(source).ptr(); + WebContents* tab = content::Source<WebContents>(source).ptr(); // We may get this notifications multiple times. Make sure to translate // only once. TabContentsWrapper* wrapper = @@ -325,7 +325,7 @@ void TranslateManager::Observe(int type, // Only add translate infobar if it doesn't exist; if it already exists, // just update the state, the actual infobar would have received the same // notification and update the visual display accordingly. - TabContents* tab = content::Source<TabContents>(source).ptr(); + WebContents* tab = content::Source<WebContents>(source).ptr(); PageTranslatedDetails* page_translated_details = content::Details<PageTranslatedDetails>(details).ptr(); PageTranslated(tab, page_translated_details); @@ -440,7 +440,7 @@ void TranslateManager::OnURLFetchComplete(const content::URLFetcher* source) { } // static -bool TranslateManager::IsShowingTranslateInfobar(TabContents* tab) { +bool TranslateManager::IsShowingTranslateInfobar(WebContents* tab) { return GetTranslateInfoBarDelegate(tab) != NULL; } @@ -456,7 +456,7 @@ TranslateManager::TranslateManager() content::NotificationService::AllSources()); } -void TranslateManager::InitiateTranslation(TabContents* tab, +void TranslateManager::InitiateTranslation(WebContents* tab, const std::string& page_lang) { Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); PrefService* prefs = profile->GetOriginalProfile()->GetPrefs(); @@ -649,7 +649,7 @@ void TranslateManager::DoTranslatePage(WebContents* tab, translate_script, source_lang, target_lang)); } -void TranslateManager::PageTranslated(TabContents* tab, +void TranslateManager::PageTranslated(WebContents* tab, PageTranslatedDetails* details) { TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents(tab); @@ -681,7 +681,7 @@ void TranslateManager::PageTranslated(TabContents* tab, ShowInfoBar(tab, infobar); } -bool TranslateManager::IsAcceptLanguage(TabContents* tab, +bool TranslateManager::IsAcceptLanguage(WebContents* tab, const std::string& language) { Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); profile = profile->GetOriginalProfile(); diff --git a/chrome/browser/translate/translate_manager.h b/chrome/browser/translate/translate_manager.h index 54687a9..5e7f089 100644 --- a/chrome/browser/translate/translate_manager.h +++ b/chrome/browser/translate/translate_manager.h @@ -24,7 +24,6 @@ template <typename T> struct DefaultSingletonTraits; class GURL; struct PageTranslatedDetails; class PrefService; -class TabContents; class TranslateInfoBarDelegate; namespace content { @@ -88,7 +87,7 @@ class TranslateManager : public content::NotificationObserver, } // Convenience method to know if a tab is showing a translate infobar. - static bool IsShowingTranslateInfobar(TabContents* tab); + static bool IsShowingTranslateInfobar(content::WebContents* tab); // Returns true if the URL can be translated. static bool IsTranslatableURL(const GURL& url); @@ -134,7 +133,8 @@ class TranslateManager : public content::NotificationObserver, // Starts the translation process on |tab| containing the page in the // |page_lang| language. - void InitiateTranslation(TabContents* tab, const std::string& page_lang); + void InitiateTranslation(content::WebContents* tab, + const std::string& page_lang); // If the tab identified by |process_id| and |render_id| has been closed, this // does nothing, otherwise it calls InitiateTranslation. @@ -149,11 +149,12 @@ class TranslateManager : public content::NotificationObserver, const std::string& target_lang); // Shows the after translate or error infobar depending on the details. - void PageTranslated(TabContents* tab, PageTranslatedDetails* details); + void PageTranslated(content::WebContents* tab, + PageTranslatedDetails* details); // Returns true if the passed language has been configured by the user as an // accept language. - bool IsAcceptLanguage(TabContents* tab, const std::string& language); + bool IsAcceptLanguage(content::WebContents* tab, const std::string& language); // Initializes the |accept_languages_| language table based on the associated // preference in |prefs|. diff --git a/chrome/browser/translate/translate_tab_helper.cc b/chrome/browser/translate/translate_tab_helper.cc index 956f811..15c772d 100644 --- a/chrome/browser/translate/translate_tab_helper.cc +++ b/chrome/browser/translate/translate_tab_helper.cc @@ -10,6 +10,8 @@ #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" +using content::WebContents; + TranslateTabHelper::TranslateTabHelper(TabContents* tab_contents) : content::WebContentsObserver(tab_contents), language_state_(&tab_contents->GetController()) { @@ -44,7 +46,7 @@ void TranslateTabHelper::OnLanguageDetermined(const std::string& language, std::string lang = language; content::NotificationService::current()->Notify( chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, - content::Source<TabContents>(tab_contents()), + content::Source<WebContents>(web_contents()), content::Details<std::string>(&lang)); } @@ -57,6 +59,6 @@ void TranslateTabHelper::OnPageTranslated(int32 page_id, PageTranslatedDetails details(original_lang, translated_lang, error_type); content::NotificationService::current()->Notify( chrome::NOTIFICATION_PAGE_TRANSLATED, - content::Source<TabContents>(tab_contents()), + content::Source<WebContents>(web_contents()), content::Details<PageTranslatedDetails>(&details)); } diff --git a/chrome/browser/ui/alternate_error_tab_observer.cc b/chrome/browser/ui/alternate_error_tab_observer.cc index efd7d12..bc18f9a 100644 --- a/chrome/browser/ui/alternate_error_tab_observer.cc +++ b/chrome/browser/ui/alternate_error_tab_observer.cc @@ -7,18 +7,18 @@ #include "chrome/browser/google/google_util.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/web_contents.h" + +using content::WebContents; AlternateErrorPageTabObserver::AlternateErrorPageTabObserver( - TabContentsWrapper* wrapper) - : content::WebContentsObserver(wrapper->tab_contents()), - wrapper_(wrapper) { - PrefService* prefs = wrapper_->profile()->GetPrefs(); + WebContents* web_contents) + : content::WebContentsObserver(web_contents) { + PrefService* prefs = GetProfile()->GetPrefs(); if (prefs) { pref_change_registrar_.Init(prefs); pref_change_registrar_.Add(prefs::kAlternateErrorPagesEnabled, this); @@ -38,6 +38,10 @@ void AlternateErrorPageTabObserver::RegisterUserPrefs(PrefService* prefs) { PrefService::SYNCABLE_PREF); } +Profile* AlternateErrorPageTabObserver::GetProfile() const { + return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); +} + //////////////////////////////////////////////////////////////////////////////// // WebContentsObserver overrides @@ -54,14 +58,14 @@ void AlternateErrorPageTabObserver::Observe(int type, const content::NotificationDetails& details) { switch (type) { case chrome::NOTIFICATION_GOOGLE_URL_UPDATED: - UpdateAlternateErrorPageURL(tab_contents()->GetRenderViewHost()); + UpdateAlternateErrorPageURL(web_contents()->GetRenderViewHost()); break; case chrome::NOTIFICATION_PREF_CHANGED: { std::string* pref_name = content::Details<std::string>(details).ptr(); DCHECK(content::Source<PrefService>(source).ptr() == - wrapper_->profile()->GetPrefs()); + GetProfile()->GetPrefs()); if (*pref_name == prefs::kAlternateErrorPagesEnabled) { - UpdateAlternateErrorPageURL(tab_contents()->GetRenderViewHost()); + UpdateAlternateErrorPageURL(web_contents()->GetRenderViewHost()); } else { NOTREACHED() << "unexpected pref change notification" << *pref_name; } @@ -78,10 +82,10 @@ void AlternateErrorPageTabObserver::Observe(int type, GURL AlternateErrorPageTabObserver::GetAlternateErrorPageURL() const { GURL url; // Disable alternate error pages when in Incognito mode. - if (wrapper_->profile()->IsOffTheRecord()) + if (GetProfile()->IsOffTheRecord()) return url; - PrefService* prefs = wrapper_->profile()->GetPrefs(); + PrefService* prefs = GetProfile()->GetPrefs(); if (prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)) { url = google_util::AppendGoogleLocaleParam( GURL(google_util::kLinkDoctorBaseURL)); diff --git a/chrome/browser/ui/alternate_error_tab_observer.h b/chrome/browser/ui/alternate_error_tab_observer.h index fe5ecad..ecce0e1 100644 --- a/chrome/browser/ui/alternate_error_tab_observer.h +++ b/chrome/browser/ui/alternate_error_tab_observer.h @@ -10,18 +10,21 @@ #include "content/public/browser/notification_registrar.h" #include "content/public/browser/web_contents_observer.h" -class TabContentsWrapper; +class Profile; // Per-tab class to implement alternate error page functionality. class AlternateErrorPageTabObserver : public content::WebContentsObserver, public content::NotificationObserver { public: - explicit AlternateErrorPageTabObserver(TabContentsWrapper* wrapper); + explicit AlternateErrorPageTabObserver(content::WebContents* web_contents); virtual ~AlternateErrorPageTabObserver(); static void RegisterUserPrefs(PrefService* prefs); private: + // Helper to return the profile for this tab. + Profile* GetProfile() const; + // content::WebContentsObserver overrides: virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; @@ -39,9 +42,6 @@ class AlternateErrorPageTabObserver : public content::WebContentsObserver, // Send the alternate error page URL to the renderer. void UpdateAlternateErrorPageURL(RenderViewHost* rvh); - // Our owning TabContentsWrapper. - TabContentsWrapper* wrapper_; - content::NotificationRegistrar registrar_; PrefChangeRegistrar pref_change_registrar_; diff --git a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc index 1ced986..5776409 100644 --- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc +++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc @@ -42,22 +42,22 @@ BookmarkTabHelper::~BookmarkTabHelper() { } bool BookmarkTabHelper::ShouldShowBookmarkBar() { - if (tab_contents()->ShowingInterstitialPage()) + if (web_contents()->ShowingInterstitialPage()) return false; // See TabContents::GetWebUIForCurrentState() comment for more info. This case // is very similar, but for non-first loads, we want to use the committed // entry. This is so the bookmarks bar disappears at the same time the page // does. - if (tab_contents()->GetController().GetLastCommittedEntry()) { + if (web_contents()->GetController().GetLastCommittedEntry()) { // Not the first load, always use the committed Web UI. - return CanShowBookmarkBar(tab_contents()->GetCommittedWebUI()); + return CanShowBookmarkBar(web_contents()->GetCommittedWebUI()); } // When it's the first load, we know either the pending one or the committed // one will have the Web UI in it (see GetWebUIForCurrentState), and only one // of them will be valid, so we can just check both. - return CanShowBookmarkBar(tab_contents()->GetWebUI()); + return CanShowBookmarkBar(web_contents()->GetWebUI()); } void BookmarkTabHelper::DidNavigateMainFrame( @@ -101,10 +101,10 @@ BookmarkTabHelper::BookmarkDrag* void BookmarkTabHelper::UpdateStarredStateForCurrentURL() { Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); BookmarkModel* model = profile->GetBookmarkModel(); const bool old_state = is_starred_; - is_starred_ = (model && model->IsBookmarked(tab_contents()->GetURL())); + is_starred_ = (model && model->IsBookmarked(web_contents()->GetURL())); if (is_starred_ != old_state && delegate()) delegate()->URLStarredChanged(tab_contents_wrapper_, is_starred_); diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index a66b330..7c57661 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -60,6 +60,8 @@ #include "chrome/browser/browser_process.h" #endif +using content::WebContents; + namespace { const char* kBeforeUnloadHTML = @@ -788,7 +790,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageLanguageDetection) { TabContents* current_tab = browser()->GetSelectedTabContents(); TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); TranslateTabHelper* helper = wrapper->translate_tab_helper(); - content::Source<TabContents> source(current_tab); + content::Source<WebContents> source(current_tab); ui_test_utils::WindowedNotificationObserverWithDetails<std::string> en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, diff --git a/chrome/browser/ui/constrained_window_tab_helper.cc b/chrome/browser/ui/constrained_window_tab_helper.cc index b718fb3..cdc9f21e 100644 --- a/chrome/browser/ui/constrained_window_tab_helper.cc +++ b/chrome/browser/ui/constrained_window_tab_helper.cc @@ -70,7 +70,7 @@ void ConstrainedWindowTabHelper::WillClose(ConstrainedWindow* window) { } void ConstrainedWindowTabHelper::BlockTabContent(bool blocked) { - TabContents* contents = tab_contents(); + WebContents* contents = web_contents(); if (!contents) { // The TabContents has already disconnected. return; diff --git a/chrome/browser/ui/find_bar/find_bar_controller.cc b/chrome/browser/ui/find_bar/find_bar_controller.cc index c518060..605ae04 100644 --- a/chrome/browser/ui/find_bar/find_bar_controller.cc +++ b/chrome/browser/ui/find_bar/find_bar_controller.cc @@ -20,6 +20,8 @@ #include "content/public/browser/notification_source.h" #include "ui/gfx/rect.h" +using content::WebContents; + // The minimum space between the FindInPage window and the search result. static const int kMinFindWndDistanceFromSelection = 5; @@ -88,7 +90,7 @@ void FindBarController::ChangeTabContents(TabContentsWrapper* contents) { registrar_.Add(this, chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, - content::Source<TabContents>(tab_contents_->tab_contents())); + content::Source<WebContents>(tab_contents_->tab_contents())); registrar_.Add( this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, @@ -119,7 +121,7 @@ void FindBarController::Observe(int type, if (type == chrome::NOTIFICATION_FIND_RESULT_AVAILABLE) { // Don't update for notifications from TabContentses other than the one we // are actively tracking. - if (content::Source<TabContents>(source).ptr() == + if (content::Source<WebContents>(source).ptr() == tab_contents_->tab_contents()) { UpdateFindBarForCurrentResult(); if (find_tab_helper->find_result().final_update() && diff --git a/chrome/browser/ui/find_bar/find_tab_helper.cc b/chrome/browser/ui/find_bar/find_tab_helper.cc index 39ba133..da932d5 100644 --- a/chrome/browser/ui/find_bar/find_tab_helper.cc +++ b/chrome/browser/ui/find_bar/find_tab_helper.cc @@ -16,6 +16,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" using WebKit::WebFindOptions; +using content::WebContents; // static int FindTabHelper::find_request_id_counter_ = -1; @@ -39,7 +40,7 @@ void FindTabHelper::StartFinding(string16 search_string, // shortcut so unless we have something to search for we return early. if (search_string.empty() && find_text_.empty()) { Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); string16 last_search_prepopulate_text = FindBarState::GetLastPrepopulateText(profile); @@ -76,7 +77,7 @@ void FindTabHelper::StartFinding(string16 search_string, // Keep track of what the last search was across the tabs. Profile* profile = - Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); FindBarState* find_bar_state = profile->GetFindBarState(); find_bar_state->set_last_prepopulate_text(find_text_); @@ -84,7 +85,7 @@ void FindTabHelper::StartFinding(string16 search_string, options.forward = forward_direction; options.matchCase = case_sensitive; options.findNext = find_next; - tab_contents()->GetRenderViewHost()->Find(current_find_request_id_, + web_contents()->GetRenderViewHost()->Find(current_find_request_id_, find_text_, options); } @@ -119,7 +120,7 @@ void FindTabHelper::StopFinding( NOTREACHED(); action = content::STOP_FIND_ACTION_KEEP_SELECTION; } - tab_contents()->GetRenderViewHost()->StopFinding(action); + web_contents()->GetRenderViewHost()->StopFinding(action); } void FindTabHelper::HandleFindReply(int request_id, @@ -148,7 +149,7 @@ void FindTabHelper::HandleFindReply(int request_id, final_update); content::NotificationService::current()->Notify( chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, - content::Source<TabContents>(tab_contents()), + content::Source<WebContents>(web_contents()), content::Details<FindNotificationDetails>(&last_search_result_)); } } diff --git a/chrome/browser/ui/prefs/prefs_tab_helper.cc b/chrome/browser/ui/prefs/prefs_tab_helper.cc index c0f2b41..bcf0600 100644 --- a/chrome/browser/ui/prefs/prefs_tab_helper.cc +++ b/chrome/browser/ui/prefs/prefs_tab_helper.cc @@ -16,9 +16,10 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/pref_names.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/notification_details.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/web_contents.h" #include "grit/locale_settings.h" #include "grit/platform_locale_settings.h" #include "webkit/glue/webpreferences.h" @@ -212,9 +213,8 @@ const size_t kPerScriptFontDefaultsLength = arraysize(kPerScriptFontDefaults); } // namespace -PrefsTabHelper::PrefsTabHelper(TabContents* contents) - : content::WebContentsObserver(contents), - contents_(contents) { +PrefsTabHelper::PrefsTabHelper(WebContents* contents) + : content::WebContentsObserver(contents) { PrefService* prefs = GetProfile()->GetPrefs(); pref_change_registrar_.Init(prefs); if (prefs) { @@ -244,7 +244,7 @@ PrefsTabHelper::PrefsTabHelper(TabContents* contents) } renderer_preferences_util::UpdateFromSystemSettings( - tab_contents()->GetMutableRendererPrefs(), GetProfile()); + web_contents()->GetMutableRendererPrefs(), GetProfile()); registrar_.Add(this, chrome::NOTIFICATION_USER_STYLE_SHEET_UPDATED, content::NotificationService::AllSources()); @@ -426,19 +426,20 @@ void PrefsTabHelper::Observe(int type, } void PrefsTabHelper::UpdateWebPreferences() { - RenderViewHostDelegate* rvhd = tab_contents(); + RenderViewHostDelegate* rvhd = + web_contents()->GetRenderViewHost()->delegate(); WebPreferences prefs = rvhd->GetWebkitPrefs(); prefs.javascript_enabled = per_tab_prefs_->GetBoolean(prefs::kWebKitJavascriptEnabled); - tab_contents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); + web_contents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); } void PrefsTabHelper::UpdateRendererPreferences() { renderer_preferences_util::UpdateFromSystemSettings( - tab_contents()->GetMutableRendererPrefs(), GetProfile()); - tab_contents()->GetRenderViewHost()->SyncRendererPrefs(); + web_contents()->GetMutableRendererPrefs(), GetProfile()); + web_contents()->GetRenderViewHost()->SyncRendererPrefs(); } Profile* PrefsTabHelper::GetProfile() { - return Profile::FromBrowserContext(contents_->GetBrowserContext()); + return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); } diff --git a/chrome/browser/ui/prefs/prefs_tab_helper.h b/chrome/browser/ui/prefs/prefs_tab_helper.h index f5c5d35..a06f12d 100644 --- a/chrome/browser/ui/prefs/prefs_tab_helper.h +++ b/chrome/browser/ui/prefs/prefs_tab_helper.h @@ -18,7 +18,7 @@ struct WebPreferences; class PrefsTabHelper : public content::WebContentsObserver, public content::NotificationObserver { public: - explicit PrefsTabHelper(TabContents* contents); + explicit PrefsTabHelper(content::WebContents* contents); virtual ~PrefsTabHelper(); static void RegisterUserPrefs(PrefService* prefs); @@ -46,9 +46,6 @@ class PrefsTabHelper : public content::WebContentsObserver, Profile* GetProfile(); - // Our owning TabContents. - TabContents* contents_; - content::NotificationRegistrar registrar_; scoped_ptr<PrefService> per_tab_prefs_; diff --git a/chrome/browser/ui/sad_tab_observer.cc b/chrome/browser/ui/sad_tab_observer.cc index 9052eb3..b402211 100644 --- a/chrome/browser/ui/sad_tab_observer.cc +++ b/chrome/browser/ui/sad_tab_observer.cc @@ -39,7 +39,7 @@ void SadTabObserver::RenderViewGone(base::TerminationStatus status) { return; gfx::NativeView view = AcquireSadTab(status); - tab_contents()->GetView()->InstallOverlayView(view); + web_contents()->GetView()->InstallOverlayView(view); } void SadTabObserver::Observe(int type, @@ -48,7 +48,7 @@ void SadTabObserver::Observe(int type, switch (type) { case content::NOTIFICATION_TAB_CONTENTS_CONNECTED: if (HasSadTab()) { - tab_contents()->GetView()->RemoveOverlayView(); + web_contents()->GetView()->RemoveOverlayView(); ReleaseSadTab(); } break; @@ -73,12 +73,12 @@ gfx::NativeView SadTabObserver::AcquireSadTab(base::TerminationStatus status) { // and later re-parent it. // TODO(avi): This is a cheat. Can this be made cleaner? sad_tab_params.parent_widget = - static_cast<TabContentsViewViews*>(tab_contents()->GetView()); + static_cast<TabContentsViewViews*>(web_contents()->GetView()); sad_tab_params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; sad_tab_.reset(new views::Widget); sad_tab_->Init(sad_tab_params); - sad_tab_->SetContentsView(new SadTabView(tab_contents(), kind)); + sad_tab_->SetContentsView(new SadTabView(web_contents(), kind)); return sad_tab_->GetNativeView(); #elif defined(TOOLKIT_GTK) sad_tab_.reset(new SadTabGtk( diff --git a/chrome/browser/ui/snapshot_tab_helper.cc b/chrome/browser/ui/snapshot_tab_helper.cc index 998a3546..6953ad0 100644 --- a/chrome/browser/ui/snapshot_tab_helper.cc +++ b/chrome/browser/ui/snapshot_tab_helper.cc @@ -7,8 +7,8 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/render_messages.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/web_contents.h" using content::WebContents; @@ -41,6 +41,6 @@ bool SnapshotTabHelper::OnMessageReceived(const IPC::Message& message) { void SnapshotTabHelper::OnSnapshot(const SkBitmap& bitmap) { content::NotificationService::current()->Notify( chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, - content::Source<WebContents>(tab_contents()), + content::Source<WebContents>(web_contents()), content::Details<const SkBitmap>(&bitmap)); } diff --git a/chrome/browser/ui/tab_contents/core_tab_helper.cc b/chrome/browser/ui/tab_contents/core_tab_helper.cc index 000df30..c6a563b 100644 --- a/chrome/browser/ui/tab_contents/core_tab_helper.cc +++ b/chrome/browser/ui/tab_contents/core_tab_helper.cc @@ -7,14 +7,16 @@ #include "chrome/browser/renderer_host/web_cache_manager.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/tab_contents/tab_contents.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" -CoreTabHelper::CoreTabHelper(TabContentsWrapper* wrapper) - : content::WebContentsObserver(wrapper->tab_contents()), - delegate_(NULL), - wrapper_(wrapper) { +using content::WebContents; + +CoreTabHelper::CoreTabHelper(WebContents* web_contents) + : content::WebContentsObserver(web_contents), + delegate_(NULL) { } CoreTabHelper::~CoreTabHelper() { @@ -25,15 +27,15 @@ string16 CoreTabHelper::GetDefaultTitle() { } string16 CoreTabHelper::GetStatusText() const { - if (!tab_contents()->IsLoading() || - tab_contents()->GetLoadState().state == net::LOAD_STATE_IDLE) { + if (!web_contents()->IsLoading() || + web_contents()->GetLoadState().state == net::LOAD_STATE_IDLE) { return string16(); } - switch (tab_contents()->GetLoadState().state) { + switch (web_contents()->GetLoadState().state) { case net::LOAD_STATE_WAITING_FOR_DELEGATE: return l10n_util::GetStringFUTF16(IDS_LOAD_STATE_WAITING_FOR_DELEGATE, - tab_contents()->GetLoadState().param); + web_contents()->GetLoadState().param); case net::LOAD_STATE_WAITING_FOR_CACHE: return l10n_util::GetStringUTF16(IDS_LOAD_STATE_WAITING_FOR_CACHE); case net::LOAD_STATE_WAITING_FOR_APPCACHE: @@ -53,17 +55,17 @@ string16 CoreTabHelper::GetStatusText() const { case net::LOAD_STATE_SSL_HANDSHAKE: return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SSL_HANDSHAKE); case net::LOAD_STATE_SENDING_REQUEST: - if (tab_contents()->GetUploadSize()) { + if (web_contents()->GetUploadSize()) { return l10n_util::GetStringFUTF16Int( IDS_LOAD_STATE_SENDING_REQUEST_WITH_PROGRESS, - static_cast<int>((100 * tab_contents()->GetUploadPosition()) / - tab_contents()->GetUploadSize())); + static_cast<int>((100 * web_contents()->GetUploadPosition()) / + web_contents()->GetUploadSize())); } else { return l10n_util::GetStringUTF16(IDS_LOAD_STATE_SENDING_REQUEST); } case net::LOAD_STATE_WAITING_FOR_RESPONSE: return l10n_util::GetStringFUTF16(IDS_LOAD_STATE_WAITING_FOR_RESPONSE, - tab_contents()->GetLoadStateHost()); + web_contents()->GetLoadStateHost()); // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE case net::LOAD_STATE_IDLE: case net::LOAD_STATE_READING_RESPONSE: @@ -78,5 +80,5 @@ string16 CoreTabHelper::GetStatusText() const { void CoreTabHelper::DidBecomeSelected() { WebCacheManager::GetInstance()->ObserveActivity( - tab_contents()->GetRenderProcessHost()->GetID()); + web_contents()->GetRenderProcessHost()->GetID()); } diff --git a/chrome/browser/ui/tab_contents/core_tab_helper.h b/chrome/browser/ui/tab_contents/core_tab_helper.h index cd37ccd..b6d6366 100644 --- a/chrome/browser/ui/tab_contents/core_tab_helper.h +++ b/chrome/browser/ui/tab_contents/core_tab_helper.h @@ -9,12 +9,11 @@ #include "content/public/browser/web_contents_observer.h" class CoreTabHelperDelegate; -class TabContentsWrapper; // Per-tab class to handle functionality that is core to the operation of tabs. class CoreTabHelper : public content::WebContentsObserver { public: - explicit CoreTabHelper(TabContentsWrapper* wrapper); + explicit CoreTabHelper(content::WebContents* web_contents); virtual ~CoreTabHelper(); CoreTabHelperDelegate* delegate() const { return delegate_; } @@ -33,9 +32,6 @@ class CoreTabHelper : public content::WebContentsObserver { // Delegate for notifying our owner about stuff. Not owned by us. CoreTabHelperDelegate* delegate_; - // Our owning TabContentsWrapper. - TabContentsWrapper* wrapper_; - DISALLOW_COPY_AND_ASSIGN(CoreTabHelper); }; diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index e0b33d1..449cd5d 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -85,7 +85,7 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents) blocked_content_tab_helper_.reset(new BlockedContentTabHelper(this)); bookmark_tab_helper_.reset(new BookmarkTabHelper(this)); constrained_window_tab_helper_.reset(new ConstrainedWindowTabHelper(this)); - core_tab_helper_.reset(new CoreTabHelper(this)); + core_tab_helper_.reset(new CoreTabHelper(contents)); extension_tab_helper_.reset(new ExtensionTabHelper(this)); favicon_tab_helper_.reset(new FaviconTabHelper(contents)); find_tab_helper_.reset(new FindTabHelper(contents)); @@ -109,7 +109,7 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents) // Create the per-tab observers. alternate_error_page_tab_observer_.reset( - new AlternateErrorPageTabObserver(this)); + new AlternateErrorPageTabObserver(contents)); download_request_limiter_observer_.reset( new DownloadRequestLimiterObserver(contents)); webnavigation_observer_.reset( @@ -145,7 +145,7 @@ base::PropertyAccessor<TabContentsWrapper*>* } TabContentsWrapper* TabContentsWrapper::Clone() { - TabContents* new_contents = tab_contents()->Clone(); + TabContents* new_contents = web_contents()->Clone(); TabContentsWrapper* new_wrapper = new TabContentsWrapper(new_contents); // TODO(avi): Can we generalize this so that knowledge of the functionings of @@ -178,7 +178,7 @@ WebContents* TabContentsWrapper::web_contents() const { } Profile* TabContentsWrapper::profile() const { - return Profile::FromBrowserContext(tab_contents()->GetBrowserContext()); + return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); } //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc index ff295ff..e93e569 100644 --- a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc +++ b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc @@ -24,6 +24,8 @@ #include "ui/views/view.h" #include "ui/views/views_delegate.h" +using content::WebContents; + namespace { // The delay waited after sending an OS simulated event. @@ -350,7 +352,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_PasteWithoutTextChange) { // Press Ctrl-V to paste the content back, it should start finding even if the // content is not changed. - content::Source<TabContents> notification_source( + content::Source<WebContents> notification_source( browser()->GetSelectedTabContents()); ui_test_utils::WindowedNotificationObserverWithDetails <FindNotificationDetails> observer( diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc index cbf5dcc..3479e1e 100644 --- a/chrome/browser/ui/views/sad_tab_view.cc +++ b/chrome/browser/ui/views/sad_tab_view.cc @@ -11,7 +11,7 @@ #include "chrome/browser/ui/webui/bug_report_ui.h" #include "chrome/browser/userfeedback/proto/extension.pb.h" #include "chrome/common/url_constants.h" -#include "content/browser/tab_contents/tab_contents.h" +#include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -23,6 +23,8 @@ #include "ui/views/controls/link.h" #include "ui/views/layout/grid_layout.h" +using content::WebContents; + static const int kPadding = 20; static const float kMessageSize = 0.65f; static const SkColor kTextColor = SK_ColorWHITE; @@ -38,8 +40,8 @@ static const int kTitleFontSizeDelta = 2; static const int kMessageFontSizeDelta = 1; #endif -SadTabView::SadTabView(TabContents* tab_contents, Kind kind) - : tab_contents_(tab_contents), +SadTabView::SadTabView(WebContents* web_contents, Kind kind) + : web_contents_(web_contents), kind_(kind), painted_(false), base_font_(ResourceBundle::GetSharedInstance().GetFont( @@ -48,7 +50,7 @@ SadTabView::SadTabView(TabContents* tab_contents, Kind kind) help_link_(NULL), feedback_link_(NULL), reload_button_(NULL) { - DCHECK(tab_contents); + DCHECK(web_contents); // Sometimes the user will never see this tab, so keep track of the total // number of creation events to compare to display events. @@ -62,13 +64,13 @@ SadTabView::SadTabView(TabContents* tab_contents, Kind kind) SadTabView::~SadTabView() {} void SadTabView::LinkClicked(views::Link* source, int event_flags) { - DCHECK(tab_contents_); + DCHECK(web_contents_); if (source == help_link_) { GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kind_ == CRASHED ? chrome::kCrashReasonURL : chrome::kKillReasonURL)); - tab_contents_->OpenURL(OpenURLParams( + web_contents_->OpenURL(OpenURLParams( help_url, content::Referrer(), CURRENT_TAB, @@ -76,7 +78,7 @@ void SadTabView::LinkClicked(views::Link* source, int event_flags) { false /* is renderer initiated */)); } else if (source == feedback_link_) { browser::ShowHtmlBugReportView( - Browser::GetBrowserForController(&tab_contents_->GetController(), NULL), + Browser::GetBrowserForController(&web_contents_->GetController(), NULL), l10n_util::GetStringUTF8(IDS_KILLED_TAB_FEEDBACK_MESSAGE), userfeedback::ChromeOsData_ChromeOsCategory_CRASH); } @@ -84,9 +86,9 @@ void SadTabView::LinkClicked(views::Link* source, int event_flags) { void SadTabView::ButtonPressed(views::Button* source, const views::Event& event) { - DCHECK(tab_contents_); + DCHECK(web_contents_); DCHECK(source == reload_button_); - tab_contents_->GetController().Reload(true); + web_contents_->GetController().Reload(true); } void SadTabView::Layout() { @@ -129,7 +131,7 @@ void SadTabView::ViewHierarchyChanged(bool is_add, layout->StartRowWithPadding(0, column_set_id, 0, kPadding); layout->AddView(message_); - if (tab_contents_) { + if (web_contents_) { layout->StartRowWithPadding(0, column_set_id, 0, kPadding); reload_button_ = new views::TextButton( this, diff --git a/chrome/browser/ui/views/sad_tab_view.h b/chrome/browser/ui/views/sad_tab_view.h index 9eda1ed..a3dcbc4 100644 --- a/chrome/browser/ui/views/sad_tab_view.h +++ b/chrome/browser/ui/views/sad_tab_view.h @@ -12,7 +12,9 @@ #include "ui/views/controls/link_listener.h" #include "ui/views/view.h" -class TabContents; +namespace content { +class WebContents; +} namespace gfx { class Font; @@ -42,7 +44,7 @@ class SadTabView : public views::View, KILLED // Tab killed. Display the "He's dead, Jim!" tab page. }; - SadTabView(TabContents* tab_contents, Kind kind); + SadTabView(content::WebContents* web_contents, Kind kind); virtual ~SadTabView(); // Overridden from views::View: @@ -66,7 +68,7 @@ class SadTabView : public views::View, views::Label* CreateLabel(const string16& text); views::Link* CreateLink(const string16& text); - TabContents* tab_contents_; + content::WebContents* web_contents_; Kind kind_; bool painted_; const gfx::Font& base_font_; diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h index 565cd61..3523bfe 100644 --- a/chrome/common/chrome_notification_types.h +++ b/chrome/common/chrome_notification_types.h @@ -48,11 +48,11 @@ enum NotificationType { // Sent when the language (English, French...) for a page has been detected. // The details Details<std::string> contain the ISO 639-1 language code and - // the source is Source<TabContents>. + // the source is Source<WebContents>. NOTIFICATION_TAB_LANGUAGE_DETERMINED, // Sent when a page has been translated. The source is the tab for that page - // (Source<TabContents>) and the details are the language the page was + // (Source<WebContents>) and the details are the language the page was // originally in and the language it was translated to // (std::pair<std::string, std::string>). NOTIFICATION_PAGE_TRANSLATED, diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc index f091434..3e53676 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -68,6 +68,8 @@ #include "ui/aura/root_window.h" #endif +using content::WebContents; + static const int kDefaultWsPort = 8880; namespace ui_test_utils { @@ -123,7 +125,7 @@ class FindInPageNotificationObserver : public content::NotificationObserver { current_find_request_id_ = parent_tab->find_tab_helper()->current_find_request_id(); registrar_.Add(this, chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, - content::Source<TabContents>(parent_tab_->tab_contents())); + content::Source<WebContents>(parent_tab_->tab_contents())); ui_test_utils::RunMessageLoop(); } diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc index b09be32..980e927 100644 --- a/content/browser/download/save_package.cc +++ b/content/browser/download/save_package.cc @@ -224,7 +224,7 @@ GURL SavePackage::GetUrlToBeSaved() { // rather than the displayed one (returned by GetURL) which may be // different (like having "view-source:" on the front). NavigationEntry* active_entry = - tab_contents()->GetController().GetActiveEntry(); + web_contents()->GetController().GetActiveEntry(); return active_entry->GetURL(); } @@ -251,7 +251,7 @@ void SavePackage::InternalInit() { file_manager_ = rdh->save_file_manager(); DCHECK(file_manager_); - download_manager_ = tab_contents()->GetBrowserContext()->GetDownloadManager(); + download_manager_ = web_contents()->GetBrowserContext()->GetDownloadManager(); DCHECK(download_manager_); } @@ -264,7 +264,7 @@ bool SavePackage::Init() { // Initialize the request context and resource dispatcher. content::BrowserContext* browser_context = - tab_contents()->GetBrowserContext(); + web_contents()->GetBrowserContext(); if (!browser_context) { NOTREACHED(); return false; @@ -652,8 +652,8 @@ void SavePackage::CheckFinish() { file_manager_, final_names, dir, - tab_contents()->GetRenderProcessHost()->GetID(), - tab_contents()->GetRenderViewHost()->routing_id(), + web_contents()->GetRenderProcessHost()->GetID(), + web_contents()->GetRenderViewHost()->routing_id(), id())); } @@ -784,7 +784,7 @@ void SavePackage::SaveCanceled(SaveItem* save_item) { // the save source. Parameter process_all_remaining_items indicates whether // we need to save all remaining items. void SavePackage::SaveNextFile(bool process_all_remaining_items) { - DCHECK(tab_contents()); + DCHECK(web_contents()); DCHECK(waiting_item_queue_.size()); do { @@ -800,11 +800,11 @@ void SavePackage::SaveNextFile(bool process_all_remaining_items) { save_item->Start(); file_manager_->SaveURL(save_item->url(), save_item->referrer(), - tab_contents()->GetRenderProcessHost()->GetID(), + web_contents()->GetRenderProcessHost()->GetID(), routing_id(), save_item->save_source(), save_item->full_path(), - tab_contents()-> + web_contents()-> GetBrowserContext()->GetResourceContext(), this); } while (process_all_remaining_items && waiting_item_queue_.size()); @@ -1162,10 +1162,10 @@ void SavePackage::GetSaveInfo() { DCHECK(download_manager_); download_manager_->delegate()->GetSaveDir( tab_contents(), &website_save_dir, &download_save_dir); - std::string mime_type = tab_contents()->GetContentsMimeType(); + std::string mime_type = web_contents()->GetContentsMimeType(); std::string accept_languages = content::GetContentClient()->browser()->GetAcceptLangs( - tab_contents()->GetBrowserContext()); + web_contents()->GetBrowserContext()); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, @@ -1223,7 +1223,7 @@ void SavePackage::ContinueGetSaveInfo(const FilePath& suggested_path, // The TabContents which owns this SavePackage may have disappeared during // the UI->FILE->UI thread hop of // GetSaveInfo->CreateDirectoryOnFileThread->ContinueGetSaveInfo. - if (!tab_contents()) + if (!web_contents()) return; download_manager_->delegate()->ChooseSavePath( @@ -1237,7 +1237,7 @@ void SavePackage::OnPathPicked(const FilePath& final_name, saved_main_file_path_ = final_name; // TODO(asanka): This call may block on IO and shouldn't be made // from the UI thread. See http://crbug.com/61827. - net::GenerateSafeFileName(tab_contents()->GetContentsMimeType(), false, + net::GenerateSafeFileName(web_contents()->GetContentsMimeType(), false, &saved_main_file_path_); saved_main_directory_path_ = saved_main_file_path_.DirName(); diff --git a/content/browser/intents/intent_injector.cc b/content/browser/intents/intent_injector.cc index 8901613..439ec19 100644 --- a/content/browser/intents/intent_injector.cc +++ b/content/browser/intents/intent_injector.cc @@ -68,13 +68,13 @@ void IntentInjector::SendIntent() { if (source_intent_.get() == NULL || !CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableWebIntents) || - tab_contents()->GetRenderViewHost() == NULL) { + web_contents()->GetRenderViewHost() == NULL) { return; } // Send intent data through to renderer. - tab_contents()->GetRenderViewHost()->Send(new IntentsMsg_SetWebIntentData( - tab_contents()->GetRenderViewHost()->routing_id(), + web_contents()->GetRenderViewHost()->Send(new IntentsMsg_SetWebIntentData( + web_contents()->GetRenderViewHost()->routing_id(), *(source_intent_.get()))); source_intent_.reset(NULL); } diff --git a/content/browser/intents/web_intents_dispatcher_impl.cc b/content/browser/intents/web_intents_dispatcher_impl.cc index e9d12ef..989cc3e 100644 --- a/content/browser/intents/web_intents_dispatcher_impl.cc +++ b/content/browser/intents/web_intents_dispatcher_impl.cc @@ -38,7 +38,7 @@ void WebIntentsDispatcherImpl::SendReplyMessage( const string16& data) { intent_injector_ = NULL; - if (!tab_contents()) + if (!web_contents()) return; Send(new IntentsMsg_WebIntentReply( diff --git a/content/browser/renderer_host/render_view_host_delegate.cc b/content/browser/renderer_host/render_view_host_delegate.cc index de744a8..c9dbb84 100644 --- a/content/browser/renderer_host/render_view_host_delegate.cc +++ b/content/browser/renderer_host/render_view_host_delegate.cc @@ -7,6 +7,8 @@ #include "googleurl/src/gurl.h" #include "webkit/glue/webpreferences.h" +using content::WebContents; + RenderViewHostDelegate::View* RenderViewHostDelegate::GetViewDelegate() { return NULL; } @@ -28,6 +30,10 @@ TabContents* RenderViewHostDelegate::GetAsTabContents() { return NULL; } +WebContents* RenderViewHostDelegate::GetAsWebContents() { + return NULL; +} + WebPreferences RenderViewHostDelegate::GetWebkitPrefs() { return WebPreferences(); } diff --git a/content/browser/renderer_host/render_view_host_delegate.h b/content/browser/renderer_host/render_view_host_delegate.h index f1e4ef0..7ed56d9 100644 --- a/content/browser/renderer_host/render_view_host_delegate.h +++ b/content/browser/renderer_host/render_view_host_delegate.h @@ -42,6 +42,7 @@ class ListValue; namespace content { class BrowserContext; +class WebContents; struct FileChooserParams; struct Referrer; struct RendererPreferences; @@ -193,9 +194,10 @@ class CONTENT_EXPORT RenderViewHostDelegate : public IPC::Channel::Listener { virtual const GURL& GetURL() const; // Return this object cast to a TabContents, if it is one. If the object is - // not a TabContents, returns NULL. DEPRECATED: Be sure to include brettw and + // not a TabContents, returns NULL. DEPRECATED: Be sure to include brettw or // jam as reviewers before you use this method. http://crbug.com/82582 virtual TabContents* GetAsTabContents(); + virtual content::WebContents* GetAsWebContents(); // Return type of RenderView which is attached with this object. virtual content::ViewType GetRenderViewType() const = 0; diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index 46a1562..fbe3825 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -86,6 +86,7 @@ using base::TimeDelta; using base::TimeTicks; using content::BrowserThread; using content::ResourceResponse; +using content::WebContents; using webkit_blob::DeletableFileReference; // ---------------------------------------------------------------------------- @@ -1987,7 +1988,7 @@ void ResourceDispatcherHost::NotifyOnUI(int type, if (rvh) { RenderViewHostDelegate* rvhd = rvh->delegate(); content::NotificationService::current()->Notify( - type, content::Source<RenderViewHostDelegate>(rvhd), + type, content::Source<WebContents>(rvhd->GetAsWebContents()), content::Details<T>(detail)); } delete detail; diff --git a/content/browser/ssl/ssl_manager.cc b/content/browser/ssl/ssl_manager.cc index e207dc0..6544ffff 100644 --- a/content/browser/ssl/ssl_manager.cc +++ b/content/browser/ssl/ssl_manager.cc @@ -23,6 +23,7 @@ #include "net/base/cert_status_flags.h" using content::BrowserThread; +using content::WebContents; // static void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh, @@ -107,10 +108,10 @@ SSLManager::SSLManager(NavigationController* controller) content::Source<NavigationController>(controller_)); registrar_.Add( this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED, - content::Source<RenderViewHostDelegate>(controller_->tab_contents())); + content::Source<WebContents>(controller_->tab_contents())); registrar_.Add( this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, - content::Source<RenderViewHostDelegate>(controller_->tab_contents())); + content::Source<WebContents>(controller_->tab_contents())); registrar_.Add( this, content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, content::Source<NavigationController>(controller_)); diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 327f407..d89b717 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -1590,6 +1590,10 @@ TabContents* TabContents::GetAsTabContents() { return this; } +WebContents* TabContents::GetAsWebContents() { + return this; +} + content::ViewType TabContents::GetRenderViewType() const { return view_type_; } diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 04bc8fc..892c62d 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -234,6 +234,7 @@ class CONTENT_EXPORT TabContents virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; virtual const GURL& GetURL() const OVERRIDE; virtual TabContents* GetAsTabContents() OVERRIDE; + virtual WebContents* GetAsWebContents() OVERRIDE; virtual content::ViewType GetRenderViewType() const OVERRIDE; virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; virtual void RenderViewReady(RenderViewHost* render_view_host) OVERRIDE; diff --git a/content/public/browser/notification_types.h b/content/public/browser/notification_types.h index 912f2603..bfa3d38 100644 --- a/content/public/browser/notification_types.h +++ b/content/public/browser/notification_types.h @@ -109,15 +109,14 @@ enum NotificationType { NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, // A response has been received for a resource request. The source will be - // a Source<RenderViewHostDelegate> corresponding to the tab in which the - // request was issued. Details in the form of a ResourceRequestDetails - // object are provided. + // a Source<WebContents> corresponding to the tab in which the request was + // issued. Details in the form of a ResourceRequestDetails object are + // provided. NOTIFICATION_RESOURCE_RESPONSE_STARTED, // A redirect was received while requesting a resource. The source will be - // a Source<RenderViewHostDelegate> corresponding to the tab in which the - // request was issued. Details in the form of a ResourceRedirectDetails - // are provided. + // a Source<WebContents> corresponding to the tab in which the request was + // issued. Details in the form of a ResourceRedirectDetails are provided. NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, // A new window was requested but was not created. The source will be a |