diff options
26 files changed, 169 insertions, 123 deletions
diff --git a/chrome/browser/background/background_contents_service.cc b/chrome/browser/background/background_contents_service.cc index 95333aa..6b60a8d 100644 --- a/chrome/browser/background/background_contents_service.cc +++ b/chrome/browser/background/background_contents_service.cc @@ -457,7 +457,7 @@ void BackgroundContentsService::LoadBackgroundContents( // TODO(atwilson): Create RenderViews asynchronously to avoid increasing // startup latency (http://crbug.com/47236). - contents->tab_contents()->GetController().LoadURL( + contents->web_contents()->GetController().LoadURL( url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); } diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc index 228cdc2..c4f687d 100644 --- a/chrome/browser/browser_focus_uitest.cc +++ b/chrome/browser/browser_focus_uitest.cc @@ -50,6 +50,8 @@ #include "base/string_util.h" #endif +using content::WebContents; + #if defined(OS_MACOSX) // TODO(suzhe): http://crbug.com/60973 #define MAYBE_FocusTraversal DISABLED_FocusTraversal @@ -170,7 +172,7 @@ class TestInterstitialPage : public InterstitialPage { return InterstitialPage::render_view_host(); } - virtual TabContents* tab() { + virtual WebContents* tab() { return InterstitialPage::tab(); } diff --git a/chrome/browser/chromeos/offline/offline_load_page.cc b/chrome/browser/chromeos/offline/offline_load_page.cc index dabacb3..be8b22f 100644 --- a/chrome/browser/chromeos/offline/offline_load_page.cc +++ b/chrome/browser/chromeos/offline/offline_load_page.cc @@ -22,15 +22,16 @@ #include "chrome/common/extensions/extension.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/url_constants.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/web_contents.h" #include "grit/browser_resources.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" using content::BrowserThread; +using content::WebContents; namespace { @@ -46,10 +47,10 @@ void SetString(DictionaryValue* strings, const char* name, int resource_id) { namespace chromeos { -OfflineLoadPage::OfflineLoadPage(TabContents* tab_contents, +OfflineLoadPage::OfflineLoadPage(WebContents* web_contents, const GURL& url, OfflineResourceHandler* handler) - : ChromeInterstitialPage(tab_contents, true, url), + : ChromeInterstitialPage(web_contents, true, url), handler_(handler), proceeded_(false), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { diff --git a/chrome/browser/chromeos/offline/offline_load_page.h b/chrome/browser/chromeos/offline/offline_load_page.h index 1271029..b17eb15 100644 --- a/chrome/browser/chromeos/offline/offline_load_page.h +++ b/chrome/browser/chromeos/offline/offline_load_page.h @@ -15,7 +15,6 @@ class Extension; class OfflineResourceHandler; -class TabContents; namespace base { class DictionaryValue; @@ -30,8 +29,8 @@ namespace chromeos { class OfflineLoadPage : public ChromeInterstitialPage, public net::NetworkChangeNotifier::OnlineStateObserver { public: - // Create a offline load page for the |tab_contents|. - OfflineLoadPage(TabContents* tab_contents, const GURL& url, + // Create a offline load page for the |web_contents|. + OfflineLoadPage(content::WebContents* web_contents, const GURL& url, OfflineResourceHandler* handler); protected: diff --git a/chrome/browser/renderer_host/offline_resource_handler.cc b/chrome/browser/renderer_host/offline_resource_handler.cc index f3f10fa..f0c4c18 100644 --- a/chrome/browser/renderer_host/offline_resource_handler.cc +++ b/chrome/browser/renderer_host/offline_resource_handler.cc @@ -25,6 +25,7 @@ #include "net/url_request/url_request_context.h" using content::BrowserThread; +using content::WebContents; OfflineResourceHandler::OfflineResourceHandler( ResourceHandler* handler, @@ -206,13 +207,13 @@ void OfflineResourceHandler::ShowOfflinePage() { } else { RenderViewHost* render_view_host = RenderViewHost::FromID(process_host_id_, render_view_id_); - TabContents* tab_contents = render_view_host ? - render_view_host->delegate()->GetAsTabContents() : NULL; + WebContents* web_contents = render_view_host ? + render_view_host->delegate()->GetAsWebContents() : NULL; // There is a chance that the tab closed after we decided to show // the offline page on the IO thread and before we actually show the // offline page here on the UI thread. - if (tab_contents) - (new chromeos::OfflineLoadPage(tab_contents, deferred_url_, this))-> + if (web_contents) + (new chromeos::OfflineLoadPage(web_contents, deferred_url_, this))-> Show(); } } diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc index 3451ade..062b794 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -29,9 +29,9 @@ #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/user_metrics.h" +#include "content/public/browser/web_contents.h" #include "grit/browser_resources.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -43,6 +43,7 @@ using content::BrowserThread; using content::OpenURLParams; using content::Referrer; using content::UserMetricsAction; +using content::WebContents; // For malware interstitial pages, we link the problematic URL to Google's // diagnostic page. @@ -114,9 +115,9 @@ class SafeBrowsingBlockingPageFactoryImpl public: SafeBrowsingBlockingPage* CreateSafeBrowsingPage( SafeBrowsingService* service, - TabContents* tab_contents, + WebContents* web_contents, const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) { - return new SafeBrowsingBlockingPage(service, tab_contents, + return new SafeBrowsingBlockingPage(service, web_contents, unsafe_resources); } @@ -134,9 +135,9 @@ static base::LazyInstance<SafeBrowsingBlockingPageFactoryImpl> SafeBrowsingBlockingPage::SafeBrowsingBlockingPage( SafeBrowsingService* sb_service, - TabContents* tab_contents, + WebContents* web_contents, const UnsafeResourceList& unsafe_resources) - : ChromeInterstitialPage(tab_contents, + : ChromeInterstitialPage(web_contents, IsMainPageLoadBlocked(unsafe_resources), unsafe_resources[0].url), malware_details_proceed_delay_ms_( @@ -703,11 +704,11 @@ SafeBrowsingBlockingPage::UnsafeResourceMap* void SafeBrowsingBlockingPage::ShowBlockingPage( SafeBrowsingService* sb_service, const SafeBrowsingService::UnsafeResource& unsafe_resource) { - TabContents* tab_contents = tab_util::GetTabContentsByID( + WebContents* web_contents = tab_util::GetWebContentsByID( unsafe_resource.render_process_host_id, unsafe_resource.render_view_id); InterstitialPage* interstitial = - InterstitialPage::GetInterstitialPage(tab_contents); + InterstitialPage::GetInterstitialPage(web_contents); if (interstitial && !unsafe_resource.is_subresource) { // There is already an interstitial showing and we are about to display a // new one for the main frame. Just hide the current one, it is now @@ -726,14 +727,14 @@ void SafeBrowsingBlockingPage::ShowBlockingPage( if (!factory_) factory_ = g_safe_browsing_blocking_page_factory_impl.Pointer(); SafeBrowsingBlockingPage* blocking_page = - factory_->CreateSafeBrowsingPage(sb_service, tab_contents, resources); + factory_->CreateSafeBrowsingPage(sb_service, web_contents, resources); blocking_page->Show(); return; } // This is an interstitial for a page's resource, let's queue it. UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); - (*unsafe_resource_map)[tab_contents].push_back(unsafe_resource); + (*unsafe_resource_map)[web_contents].push_back(unsafe_resource); } // static diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.h b/chrome/browser/safe_browsing/safe_browsing_blocking_page.h index 0fdea90..767c726 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.h +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.h @@ -48,7 +48,7 @@ class DictionaryValue; class SafeBrowsingBlockingPage : public ChromeInterstitialPage { public: typedef std::vector<SafeBrowsingService::UnsafeResource> UnsafeResourceList; - typedef std::map<TabContents*, UnsafeResourceList> UnsafeResourceMap; + typedef std::map<content::WebContents*, UnsafeResourceList> UnsafeResourceMap; virtual ~SafeBrowsingBlockingPage(); @@ -82,7 +82,7 @@ class SafeBrowsingBlockingPage : public ChromeInterstitialPage { // Don't instanciate this class directly, use ShowBlockingPage instead. SafeBrowsingBlockingPage(SafeBrowsingService* service, - TabContents* tab_contents, + content::WebContents* web_contents, const UnsafeResourceList& unsafe_resources); // After a malware interstitial where the user opted-in to the @@ -184,7 +184,7 @@ class SafeBrowsingBlockingPageFactory { virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( SafeBrowsingService* service, - TabContents* tab_contents, + content::WebContents* web_contents, const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 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 f69647e..a59d801 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc @@ -21,8 +21,8 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_view.h" +#include "content/public/browser/web_contents.h" #include "content/test/test_browser_thread.h" using content::BrowserThread; @@ -181,9 +181,9 @@ class TestMalwareDetailsFactory : public MalwareDetailsFactory { class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { public: TestSafeBrowsingBlockingPage(SafeBrowsingService* service, - TabContents* tab_contents, + WebContents* web_contents, const UnsafeResourceList& unsafe_resources) - : SafeBrowsingBlockingPage(service, tab_contents, unsafe_resources) { + : SafeBrowsingBlockingPage(service, web_contents, unsafe_resources) { // Don't wait the whole 3 seconds for the browser test. malware_details_proceed_delay_ms_ = 100; wait_for_delete_ = false; @@ -212,9 +212,9 @@ class TestSafeBrowsingBlockingPageFactory virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( SafeBrowsingService* service, - TabContents* tab_contents, + WebContents* web_contents, const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) { - return new TestSafeBrowsingBlockingPage(service, tab_contents, + return new TestSafeBrowsingBlockingPage(service, web_contents, unsafe_resources); } }; @@ -263,7 +263,8 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest, } void SendCommand(const std::string& command) { - TabContents* contents = browser()->GetSelectedTabContents(); + WebContents* contents = + browser()->GetSelectedTabContentsWrapper()->web_contents(); // We use InterstitialPage::GetInterstitialPage(tab) instead of // tab->GetInterstitialPage() because the tab doesn't have a pointer // to its interstital page until it gets a command from the renderer @@ -277,7 +278,8 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest, } void DontProceedThroughInterstitial() { - TabContents* contents = browser()->GetSelectedTabContents(); + WebContents* contents = + browser()->GetSelectedTabContentsWrapper()->web_contents(); InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( contents); ASSERT_TRUE(interstitial_page); @@ -285,7 +287,8 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest, } void ProceedThroughInterstitial() { - TabContents* contents = browser()->GetSelectedTabContents(); + WebContents* contents = + browser()->GetSelectedTabContentsWrapper()->web_contents(); InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( contents); ASSERT_TRUE(interstitial_page); @@ -293,7 +296,8 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest, } void AssertNoInterstitial(bool wait_for_delete) { - TabContents* contents = browser()->GetSelectedTabContents(); + WebContents* contents = + browser()->GetSelectedTabContentsWrapper()->web_contents(); if (contents->ShowingInterstitialPage() && wait_for_delete) { // We'll get notified when the interstitial is deleted. @@ -308,14 +312,16 @@ class SafeBrowsingBlockingPageTest : public InProcessBrowserTest, } bool YesInterstitial() { - TabContents* contents = browser()->GetSelectedTabContents(); + WebContents* contents = + browser()->GetSelectedTabContentsWrapper()->web_contents(); InterstitialPage* interstitial_page = InterstitialPage::GetInterstitialPage( contents); return interstitial_page != NULL; } void WaitForInterstitial() { - TabContents* contents = browser()->GetSelectedTabContents(); + WebContents* contents = + browser()->GetSelectedTabContentsWrapper()->web_contents(); ui_test_utils::WindowedNotificationObserver interstitial_observer( content::NOTIFICATION_INTERSTITIAL_ATTACHED, content::Source<WebContents>(contents)); @@ -411,8 +417,9 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareDontProceed) { SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" AssertNoInterstitial(false); // Assert the interstitial is gone - EXPECT_EQ(GURL(chrome::kAboutBlankURL), // Back to "about:blank" - browser()->GetSelectedTabContents()->GetURL()); + EXPECT_EQ( + GURL(chrome::kAboutBlankURL), // Back to "about:blank" + browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); } IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { @@ -423,12 +430,14 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareProceed) { ui_test_utils::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> + &browser()->GetSelectedTabContentsWrapper()->web_contents()-> GetController())); SendCommand("\"proceed\""); // Simulate the user clicking "proceed" observer.Wait(); AssertNoInterstitial(true); // Assert the interstitial is gone. - EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); + EXPECT_EQ( + url, + browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); } IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { @@ -439,8 +448,9 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingDontProceed) { SendCommand("\"takeMeBack\""); // Simulate the user clicking "proceed" AssertNoInterstitial(false); // Assert the interstitial is gone - EXPECT_EQ(GURL(chrome::kAboutBlankURL), // We are back to "about:blank". - browser()->GetSelectedTabContents()->GetURL()); + EXPECT_EQ( + GURL(chrome::kAboutBlankURL), // We are back to "about:blank". + browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); } IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) { @@ -452,12 +462,14 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingProceed) { ui_test_utils::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> + &browser()->GetSelectedTabContentsWrapper()->web_contents()-> GetController())); SendCommand("\"proceed\""); // Simulate the user clicking "proceed". observer.Wait(); AssertNoInterstitial(true); // Assert the interstitial is gone - EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); + EXPECT_EQ( + url, + browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); } IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { @@ -469,15 +481,17 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, PhishingReportError) { ui_test_utils::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> + &browser()->GetSelectedTabContentsWrapper()->web_contents()-> GetController())); SendCommand("\"reportError\""); // Simulate the user clicking "report error" observer.Wait(); AssertNoInterstitial(false); // Assert the interstitial is gone // We are in the error reporting page. - EXPECT_EQ("/safebrowsing/report_error/", - browser()->GetSelectedTabContents()->GetURL().path()); + EXPECT_EQ( + "/safebrowsing/report_error/", + browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL(). + path()); } IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, @@ -490,15 +504,17 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, ui_test_utils::WindowedNotificationObserver observer( content::NOTIFICATION_LOAD_STOP, content::Source<NavigationController>( - &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> + &browser()->GetSelectedTabContentsWrapper()->web_contents()-> GetController())); SendCommand("\"learnMore\""); // Simulate the user clicking "learn more" observer.Wait(); AssertNoInterstitial(false); // Assert the interstitial is gone // We are in the help page. - EXPECT_EQ("/support/bin/answer.py", - browser()->GetSelectedTabContents()->GetURL().path()); + EXPECT_EQ( + "/support/bin/answer.py", + browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL(). + path()); } IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeDontProceed) { @@ -511,14 +527,15 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, MalwareIframeDontProceed) { ui_test_utils::WindowedNotificationObserver observer( content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>( - &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> + &browser()->GetSelectedTabContentsWrapper()->web_contents()-> GetController())); SendCommand("\"takeMeBack\""); // Simulate the user clicking "back" observer.Wait(); AssertNoInterstitial(false); // Assert the interstitial is gone - EXPECT_EQ(GURL(chrome::kAboutBlankURL), // Back to "about:blank" - browser()->GetSelectedTabContents()->GetURL()); + EXPECT_EQ( + GURL(chrome::kAboutBlankURL), // Back to "about:blank" + browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); } // Crashy, http://crbug.com/68834. @@ -533,7 +550,9 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, SendCommand("\"proceed\""); // Simulate the user clicking "proceed" AssertNoInterstitial(true); // Assert the interstitial is gone - EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); + EXPECT_EQ( + url, + browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); } IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, @@ -562,7 +581,9 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingBlockingPageTest, SendCommand("\"proceed\""); // Simulate the user clicking "back" AssertNoInterstitial(true); // Assert the interstitial is gone - EXPECT_EQ(url, browser()->GetSelectedTabContents()->GetURL()); + EXPECT_EQ( + url, + browser()->GetSelectedTabContentsWrapper()->web_contents()->GetURL()); AssertReportSent(); } diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc index ffc4e0d..15cc478 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc @@ -15,6 +15,7 @@ using content::BrowserThread; using content::NavigationEntry; +using content::WebContents; static const char* kGoogleURL = "http://www.google.com/"; static const char* kGoodURL = "http://www.goodguys.com/"; @@ -26,9 +27,9 @@ static const char* kBadURL3 = "http://www.badguys3.com/"; class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { public: TestSafeBrowsingBlockingPage(SafeBrowsingService* service, - TabContents* tab_contents, + WebContents* web_contents, const UnsafeResourceList& unsafe_resources) - : SafeBrowsingBlockingPage(service, tab_contents, unsafe_resources) { + : SafeBrowsingBlockingPage(service, web_contents, unsafe_resources) { // Don't delay details at all for the unittest. malware_details_proceed_delay_ms_ = 0; } @@ -62,9 +63,9 @@ class TestSafeBrowsingBlockingPageFactory virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( SafeBrowsingService* service, - TabContents* tab_contents, + WebContents* web_contents, const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) { - return new TestSafeBrowsingBlockingPage(service, tab_contents, + return new TestSafeBrowsingBlockingPage(service, web_contents, unsafe_resources); } }; diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc index b93921d..d2b3597 100644 --- a/chrome/browser/ssl/ssl_blocking_page.cc +++ b/chrome/browser/ssl/ssl_blocking_page.cc @@ -17,11 +17,12 @@ #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/ssl/ssl_cert_error_handler.h" #include "content/browser/tab_contents/navigation_controller.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" +#include "content/public/browser/render_process_host.h" #include "content/public/browser/ssl_status.h" +#include "content/public/browser/web_contents.h" #include "grit/browser_resources.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -51,7 +52,7 @@ SSLBlockingPage::SSLBlockingPage( bool overridable, const base::Callback<void(SSLCertErrorHandler*, bool)>& callback) : ChromeInterstitialPage( - tab_util::GetTabContentsByID( + tab_util::GetWebContentsByID( handler->render_process_host_id(), handler->tab_contents_id()), true, handler->request_url()), diff --git a/chrome/browser/tab_contents/background_contents.h b/chrome/browser/tab_contents/background_contents.h index 0efb73c..a1f0bf7 100644 --- a/chrome/browser/tab_contents/background_contents.h +++ b/chrome/browser/tab_contents/background_contents.h @@ -43,7 +43,6 @@ class BackgroundContents : public content::WebContentsDelegate, Delegate* delegate); virtual ~BackgroundContents(); - TabContents* tab_contents() { return tab_contents_.get(); } // TODO(jam): move impl to header once this class only uses WebContents. content::WebContents* web_contents() const; virtual const GURL& GetURL() const; diff --git a/chrome/browser/tab_contents/chrome_interstitial_page.cc b/chrome/browser/tab_contents/chrome_interstitial_page.cc index ba6d562..ef1c194 100644 --- a/chrome/browser/tab_contents/chrome_interstitial_page.cc +++ b/chrome/browser/tab_contents/chrome_interstitial_page.cc @@ -10,11 +10,13 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/render_messages.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" +#include "content/public/browser/web_contents.h" -ChromeInterstitialPage::ChromeInterstitialPage(TabContents* tab, +using content::WebContents; + +ChromeInterstitialPage::ChromeInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) : InterstitialPage(tab, new_navigation, url) { diff --git a/chrome/browser/tab_contents/chrome_interstitial_page.h b/chrome/browser/tab_contents/chrome_interstitial_page.h index 8883129..2fdd646 100644 --- a/chrome/browser/tab_contents/chrome_interstitial_page.h +++ b/chrome/browser/tab_contents/chrome_interstitial_page.h @@ -13,13 +13,11 @@ #include "content/public/browser/notification_observer.h" #include "googleurl/src/gurl.h" -class TabContents; - // This class adds the possibility to react to DOMResponse-messages sent by // the RenderViewHost via ChromeRenderViewHostObserver to the InterstitialPage. class ChromeInterstitialPage : public InterstitialPage { public: - ChromeInterstitialPage(TabContents* tab, + ChromeInterstitialPage(content::WebContents* tab, bool new_navigation, const GURL& url); virtual ~ChromeInterstitialPage(); 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 20ad1dc..010296a 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -151,7 +151,7 @@ TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow( frame_name); if (contents) { pending_contents_[route_id] = - contents->tab_contents()->GetRenderViewHost(); + contents->web_contents()->GetRenderViewHost(); return NULL; } } diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc index 0a18d2a..d38ad1b 100644 --- a/chrome/browser/task_manager/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager/task_manager_resource_providers.cc @@ -547,9 +547,9 @@ TaskManagerBackgroundContentsResource::TaskManagerBackgroundContentsResource( BackgroundContents* background_contents, const string16& application_name) : TaskManagerRendererResource( - background_contents->tab_contents()->GetRenderProcessHost()-> + background_contents->web_contents()->GetRenderProcessHost()-> GetHandle(), - background_contents->tab_contents()->GetRenderViewHost()), + background_contents->web_contents()->GetRenderViewHost()), background_contents_(background_contents), application_name_(application_name) { // Just use the same icon that other extension resources do. @@ -616,7 +616,7 @@ TaskManagerBackgroundContentsResourceProvider::GetResource( return NULL; for (Resources::iterator i = resources_.begin(); i != resources_.end(); i++) { - TabContents* tab = i->first->tab_contents(); + WebContents* tab = i->first->web_contents(); if (tab->GetRenderProcessHost()->GetID() == render_process_host_id && tab->GetRenderViewHost()->routing_id() == routing_id) { return i->second; @@ -710,7 +710,7 @@ void TaskManagerBackgroundContentsResourceProvider::Add( return; // Don't add contents whose process is dead. - if (!contents->tab_contents()->GetRenderProcessHost()->GetHandle()) + if (!contents->web_contents()->GetRenderProcessHost()->GetHandle()) return; // Should never add the same BackgroundContents twice. diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index b5757be..1a867ba 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -5122,7 +5122,7 @@ void Browser::TabDetachedAtImpl(TabContentsWrapper* contents, int index, registrar_.Remove(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED, content::Source<WebContents>(contents->web_contents())); registrar_.Remove(this, content::NOTIFICATION_INTERSTITIAL_DETACHED, - content::Source<WebContents>(contents->tab_contents())); + content::Source<WebContents>(contents->web_contents())); registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, content::Source<WebContents>(contents->web_contents())); } diff --git a/chrome/browser/ui/pdf/pdf_unsupported_feature.cc b/chrome/browser/ui/pdf/pdf_unsupported_feature.cc index f5db878..5bce9e2 100644 --- a/chrome/browser/ui/pdf/pdf_unsupported_feature.cc +++ b/chrome/browser/ui/pdf/pdf_unsupported_feature.cc @@ -21,9 +21,10 @@ #include "chrome/common/jstemplate_builder.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/plugin_service.h" +#include "content/public/browser/render_process_host.h" #include "content/public/browser/user_metrics.h" +#include "content/public/browser/web_contents.h" #include "grit/browser_resources.h" #include "grit/generated_resources.h" #include "grit/theme_resources_standard.h" @@ -36,6 +37,7 @@ using content::OpenURLParams; using content::PluginService; using content::Referrer; using content::UserMetricsAction; +using content::WebContents; using webkit::npapi::PluginGroup; using webkit::WebPluginInfo; @@ -130,7 +132,7 @@ void PDFEnableAdobeReaderInfoBarDelegate::OnNo() { } // Launch the url to get the latest Adbobe Reader installer. -void OpenReaderUpdateURL(TabContents* tab) { +void OpenReaderUpdateURL(WebContents* tab) { OpenURLParams params( GURL(kReaderUpdateUrl), Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); @@ -143,11 +145,11 @@ void OpenUsingReader(TabContentsWrapper* tab, InfoBarDelegate* old_delegate, InfoBarDelegate* new_delegate) { ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( - tab->tab_contents()->GetRenderProcessHost()->GetID(), - tab->tab_contents()->GetRenderViewHost()->routing_id(), - tab->tab_contents()->GetURL(), + tab->web_contents()->GetRenderProcessHost()->GetID(), + tab->web_contents()->GetRenderViewHost()->routing_id(), + tab->web_contents()->GetURL(), ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName)); - tab->tab_contents()->GetRenderViewHost()->ReloadFrame(); + tab->web_contents()->GetRenderViewHost()->ReloadFrame(); if (new_delegate) { if (old_delegate) { @@ -166,7 +168,7 @@ class PDFUnsupportedFeatureInterstitial : public ChromeInterstitialPage { TabContentsWrapper* tab, const WebPluginInfo& reader_webplugininfo) : ChromeInterstitialPage( - tab->tab_contents(), false, tab->tab_contents()->GetURL()), + tab->web_contents(), false, tab->web_contents()->GetURL()), tab_contents_(tab), reader_webplugininfo_(reader_webplugininfo) { content::RecordAction(UserMetricsAction("PDF_ReaderInterstitialShown")); @@ -332,7 +334,7 @@ string16 PDFUnsupportedFeatureInfoBarDelegate::GetMessageText() const { bool PDFUnsupportedFeatureInfoBarDelegate::OnYes() { if (!reader_installed_) { content::RecordAction(UserMetricsAction("PDF_InstallReaderInfoBarOK")); - OpenReaderUpdateURL(tab_contents_->tab_contents()); + OpenReaderUpdateURL(tab_contents_->web_contents()); return true; } @@ -367,13 +369,13 @@ void PDFUnsupportedFeatureInfoBarDelegate::OnNo() { void GotPluginGroupsCallback(int process_id, int routing_id, const std::vector<PluginGroup>& groups) { - TabContents* tab_contents = - tab_util::GetTabContentsByID(process_id, routing_id); - if (!tab_contents) + WebContents* web_contents = + tab_util::GetWebContentsByID(process_id, routing_id); + if (!web_contents) return; TabContentsWrapper* tab = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + TabContentsWrapper::GetCurrentWrapperForContents(web_contents); if (!tab) return; @@ -409,6 +411,6 @@ void PDFHasUnsupportedFeature(TabContentsWrapper* tab) { PluginService::GetInstance()->GetPluginGroups( base::Bind(&GotPluginGroupsCallback, - tab->tab_contents()->GetRenderProcessHost()->GetID(), - tab->tab_contents()->GetRenderViewHost()->routing_id())); + tab->web_contents()->GetRenderProcessHost()->GetID(), + tab->web_contents()->GetRenderViewHost()->routing_id())); } diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 7ef63cb..75e261d 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -2119,7 +2119,8 @@ void BrowserView::UpdateSidebarForContents(TabContentsWrapper* tab_contents) { bool should_hide = !visible && sidebar_container_->visible(); // Update sidebar content. - TabContents* old_contents = sidebar_container_->tab_contents(); + TabContents* old_contents = + static_cast<TabContents*>(sidebar_container_->web_contents()); sidebar_container_->ChangeTabContents(sidebar_contents); SidebarManager::GetInstance()-> NotifyStateChanges(old_contents, sidebar_contents); @@ -2597,7 +2598,7 @@ void BrowserView::ProcessTabSelected(TabContentsWrapper* new_contents) { // the TabContents window. DCHECK(new_contents); bool change_tab_contents = - contents_container_->tab_contents() != new_contents->tab_contents(); + contents_container_->web_contents() != new_contents->tab_contents(); // Update various elements that are interested in knowing the current // TabContents. diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_container.h b/chrome/browser/ui/views/tab_contents/native_tab_contents_container.h index cdb286c..6879bd9 100644 --- a/chrome/browser/ui/views/tab_contents/native_tab_contents_container.h +++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_container.h @@ -7,7 +7,6 @@ #pragma once class RenderViewHost; -class TabContents; class TabContentsContainer; namespace content { diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_aura.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_aura.cc index b998388..ccdb0e5 100644 --- a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_aura.cc +++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_aura.cc @@ -91,8 +91,8 @@ bool NativeTabContentsContainerAura::SkipDefaultKeyEventProcessing( // We'll first give the page a chance to process the key events. If it does // not process them, they'll be returned to us and we'll treat them as // accelerators then. - return container_->tab_contents() && - !container_->tab_contents()->IsCrashed(); + return container_->web_contents() && + !container_->web_contents()->IsCrashed(); } bool NativeTabContentsContainerAura::IsFocusable() const { @@ -102,8 +102,8 @@ bool NativeTabContentsContainerAura::IsFocusable() const { } void NativeTabContentsContainerAura::OnFocus() { - if (container_->tab_contents()) - container_->tab_contents()->Focus(); + if (container_->web_contents()) + container_->web_contents()->Focus(); } void NativeTabContentsContainerAura::RequestFocus() { @@ -126,7 +126,7 @@ void NativeTabContentsContainerAura::RequestFocus() { void NativeTabContentsContainerAura::AboutToRequestFocusFromTabTraversal( bool reverse) { - container_->tab_contents()->FocusThroughTabTraversal(reverse); + container_->web_contents()->FocusThroughTabTraversal(reverse); } void NativeTabContentsContainerAura::GetAccessibleState( diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc index 45539b8..2424d28 100644 --- a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc +++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk.cc @@ -90,8 +90,8 @@ bool NativeTabContentsContainerGtk::SkipDefaultKeyEventProcessing( // We'll first give the page a chance to process the key events. If it does // not process them, they'll be returned to us and we'll treat them as // accelerators then. - return container_->tab_contents() && - !container_->tab_contents()->IsCrashed(); + return container_->web_contents() && + !container_->web_contents()->IsCrashed(); } views::FocusTraversable* NativeTabContentsContainerGtk::GetFocusTraversable() { @@ -101,12 +101,12 @@ views::FocusTraversable* NativeTabContentsContainerGtk::GetFocusTraversable() { bool NativeTabContentsContainerGtk::IsFocusable() const { // We need to be focusable when our contents is not a view hierarchy, as // clicking on the contents needs to focus us. - return container_->tab_contents() != NULL; + return container_->web_contents() != NULL; } void NativeTabContentsContainerGtk::OnFocus() { - if (container_->tab_contents()) - container_->tab_contents()->Focus(); + if (container_->web_contents()) + container_->web_contents()->Focus(); } void NativeTabContentsContainerGtk::RequestFocus() { @@ -127,15 +127,15 @@ void NativeTabContentsContainerGtk::RequestFocus() { void NativeTabContentsContainerGtk::AboutToRequestFocusFromTabTraversal( bool reverse) { - if (!container_->tab_contents()) + if (!container_->web_contents()) return; // Give an opportunity to the tab to reset its focus. - if (container_->tab_contents()->GetInterstitialPage()) { - container_->tab_contents()->GetInterstitialPage()->FocusThroughTabTraversal( + if (container_->web_contents()->GetInterstitialPage()) { + container_->web_contents()->GetInterstitialPage()->FocusThroughTabTraversal( reverse); return; } - container_->tab_contents()->FocusThroughTabTraversal(reverse); + container_->web_contents()->FocusThroughTabTraversal(reverse); } void NativeTabContentsContainerGtk::GetAccessibleState( diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_win.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_win.cc index 959667b..b738795 100644 --- a/chrome/browser/ui/views/tab_contents/native_tab_contents_container_win.cc +++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_container_win.cc @@ -102,19 +102,19 @@ bool NativeTabContentsContainerWin::SkipDefaultKeyEventProcessing( // We'll first give the page a chance to process the key events. If it does // not process them, they'll be returned to us and we'll treat them as // accelerators then. - return container_->tab_contents() && - !container_->tab_contents()->IsCrashed(); + return container_->web_contents() && + !container_->web_contents()->IsCrashed(); } bool NativeTabContentsContainerWin::IsFocusable() const { // We need to be focusable when our contents is not a view hierarchy, as // clicking on the contents needs to focus us. - return container_->tab_contents() != NULL; + return container_->web_contents() != NULL; } void NativeTabContentsContainerWin::OnFocus() { - if (container_->tab_contents()) - container_->tab_contents()->Focus(); + if (container_->web_contents()) + container_->web_contents()->Focus(); } void NativeTabContentsContainerWin::RequestFocus() { @@ -137,7 +137,7 @@ void NativeTabContentsContainerWin::RequestFocus() { void NativeTabContentsContainerWin::AboutToRequestFocusFromTabTraversal( bool reverse) { - container_->tab_contents()->FocusThroughTabTraversal(reverse); + container_->web_contents()->FocusThroughTabTraversal(reverse); } void NativeTabContentsContainerWin::GetAccessibleState( @@ -147,11 +147,11 @@ void NativeTabContentsContainerWin::GetAccessibleState( gfx::NativeViewAccessible NativeTabContentsContainerWin::GetNativeViewAccessible() { - TabContents* tab_contents = container_->tab_contents(); - if (tab_contents) { + WebContents* web_contents = container_->web_contents(); + if (web_contents) { RenderWidgetHostViewWin* host_view_win = static_cast<RenderWidgetHostViewWin*>( - tab_contents->GetRenderWidgetHostView()); + web_contents->GetRenderWidgetHostView()); if (host_view_win) return host_view_win->GetIAccessible(); } 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 f3f89c9..870149d 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_container.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_container.cc @@ -47,6 +47,10 @@ void TabContentsContainer::ChangeTabContents(TabContents* contents) { } } +content::WebContents* TabContentsContainer::web_contents() { + return tab_contents_; +} + void TabContentsContainer::WebContentsFocused(WebContents* contents) { native_container_->WebContentsFocused(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 4d04d54..c42cb2d 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_container.h +++ b/chrome/browser/ui/views/tab_contents/tab_contents_container.h @@ -31,8 +31,8 @@ class TabContentsContainer : public views::View, View* GetFocusView() { return native_container_->GetView(); } - // Accessor for |tab_contents_|. - TabContents* tab_contents() const { return tab_contents_; } + // TODO(jam): move web_contents() to header. + content::WebContents* web_contents(); // Called by the BrowserView to notify that |contents| got the focus. void WebContentsFocused(content::WebContents* contents); diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc index 6c89fcb..cbc0b29 100644 --- a/content/browser/tab_contents/interstitial_page.cc +++ b/content/browser/tab_contents/interstitial_page.cc @@ -115,10 +115,10 @@ class InterstitialPage::InterstitialPageRVHViewDelegate InterstitialPage::InterstitialPageMap* InterstitialPage::tab_to_interstitial_page_ = NULL; -InterstitialPage::InterstitialPage(TabContents* tab, +InterstitialPage::InterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) - : tab_(tab), + : tab_(static_cast<TabContents*>(tab)), url_(url), new_navigation_(new_navigation), should_discard_pending_nav_entry_(new_navigation), @@ -419,6 +419,10 @@ void InterstitialPage::HandleKeyboardEvent( return tab_->HandleKeyboardEvent(event); } +WebContents* InterstitialPage::tab() const { + return tab_; +} + RenderViewHost* InterstitialPage::CreateRenderViewHost() { RenderViewHost* render_view_host = new RenderViewHost( SiteInstance::CreateSiteInstance(tab()->GetBrowserContext()), @@ -591,8 +595,9 @@ void InterstitialPage::InitInterstitialPageMap() { // static InterstitialPage* InterstitialPage::GetInterstitialPage( - TabContents* tab_contents) { + WebContents* web_contents) { InitInterstitialPageMap(); + TabContents* tab_contents = static_cast<TabContents*>(web_contents); InterstitialPageMap::const_iterator iter = tab_to_interstitial_page_->find(tab_contents); if (iter == tab_to_interstitial_page_->end()) @@ -673,8 +678,13 @@ void InterstitialPage::InterstitialPageRVHViewDelegate::GotFocus() { void InterstitialPage::InterstitialPageRVHViewDelegate::TakeFocus( bool reverse) { - if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate()) - interstitial_page_->tab()->GetViewDelegate()->TakeFocus(reverse); + if (!interstitial_page_->tab()) + return; + TabContents* tab = static_cast<TabContents*>(interstitial_page_->tab()); + if (!tab->GetViewDelegate()) + return; + + tab->GetViewDelegate()->TakeFocus(reverse); } void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply( diff --git a/content/browser/tab_contents/interstitial_page.h b/content/browser/tab_contents/interstitial_page.h index 4088e8a..ce786bf 100644 --- a/content/browser/tab_contents/interstitial_page.h +++ b/content/browser/tab_contents/interstitial_page.h @@ -24,6 +24,7 @@ class TabContentsView; namespace content { class NavigationEntry; +class WebContents; } // This class is a base class for interstitial pages, pages that show some @@ -60,7 +61,9 @@ class CONTENT_EXPORT InterstitialPage : public content::NotificationObserver, // added to the navigation controller (so the interstitial page appears as a // new navigation entry). |new_navigation| should be false when the // interstitial was triggered by a loading a sub-resource in a page. - InterstitialPage(TabContents* tab, bool new_navigation, const GURL& url); + InterstitialPage(content::WebContents* tab, + bool new_navigation, + const GURL& url); virtual ~InterstitialPage(); // Shows the interstitial page in the tab. @@ -70,8 +73,9 @@ class CONTENT_EXPORT InterstitialPage : public content::NotificationObserver, void Hide(); // Retrieves the InterstitialPage if any associated with the specified - // |tab_contents| (used by ui tests). - static InterstitialPage* GetInterstitialPage(TabContents* tab_contents); + // |web_contents| (used by ui tests). + static InterstitialPage* GetInterstitialPage( + content::WebContents* web_contents); // Sub-classes should return the HTML that should be displayed in the page. virtual std::string GetHTMLContents(); @@ -148,7 +152,7 @@ class CONTENT_EXPORT InterstitialPage : public content::NotificationObserver, virtual void UpdateEntry(content::NavigationEntry* entry) {} bool enabled() const { return enabled_; } - TabContents* tab() const { return tab_; } + content::WebContents* tab() const; const GURL& url() const { return url_; } RenderViewHost* render_view_host() const { return render_view_host_; } void set_renderer_preferences(const content::RendererPreferences& prefs) { |