diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-09 22:00:21 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-09 22:00:21 +0000 |
commit | 8d3347feb74ff61582d42b214365664ecc41c775 (patch) | |
tree | 300f42cdb3c7f0de84241fa72b8e8e07735e7cc1 /chrome/browser/tab_contents | |
parent | 8f27da1f873a11a7900ef2735967cec1a2291a79 (diff) | |
download | chromium_src-8d3347feb74ff61582d42b214365664ecc41c775.zip chromium_src-8d3347feb74ff61582d42b214365664ecc41c775.tar.gz chromium_src-8d3347feb74ff61582d42b214365664ecc41c775.tar.bz2 |
Move some more interfaces on RenderViewHostDelegate to separate classes. The
ones in the patch are those that are implemented by other classes, avoiding
TabContents pass-throughs.
Review URL: http://codereview.chromium.org/149373
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/interstitial_page.cc | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/interstitial_page.h | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_host_manager.cc | 73 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_host_manager.h | 25 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 69 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 25 |
6 files changed, 80 insertions, 116 deletions
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index 2eff140..c8863d9 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -281,7 +281,7 @@ void InterstitialPage::Observe(NotificationType type, } } -RenderViewHostDelegate::View* InterstitialPage::GetViewDelegate() const { +RenderViewHostDelegate::View* InterstitialPage::GetViewDelegate() { return rvh_view_delegate_.get(); } diff --git a/chrome/browser/tab_contents/interstitial_page.h b/chrome/browser/tab_contents/interstitial_page.h index 8ebfb51..05b2031 100644 --- a/chrome/browser/tab_contents/interstitial_page.h +++ b/chrome/browser/tab_contents/interstitial_page.h @@ -92,7 +92,7 @@ class InterstitialPage : public NotificationObserver, const NotificationDetails& details); // RenderViewHostDelegate implementation: - virtual View* GetViewDelegate() const; + virtual View* GetViewDelegate(); virtual const GURL& GetURL() const; virtual void RenderViewGone(RenderViewHost* render_view_host); virtual void DidNavigate(RenderViewHost* render_view_host, diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc index 28f5a95..a34668c 100644 --- a/chrome/browser/tab_contents/render_view_host_manager.cc +++ b/chrome/browser/tab_contents/render_view_host_manager.cc @@ -180,27 +180,6 @@ void RenderViewHostManager::DidNavigateMainFrame( } } -void RenderViewHostManager::OnCrossSiteResponse(int new_render_process_host_id, - int new_request_id) { - // Should only see this while we have a pending renderer. - if (!cross_navigation_pending_) - return; - DCHECK(pending_render_view_host_); - - // Tell the old renderer to run its onunload handler. When it finishes, it - // will send a ClosePage_ACK to the ResourceDispatcherHost with the given - // IDs (of the pending RVH's request), allowing the pending RVH's response to - // resume. - render_view_host_->ClosePage(new_render_process_host_id, new_request_id); - - // ResourceDispatcherHost has told us to run the onunload handler, which - // means it is not a download or unsafe page, and we are going to perform the - // navigation. Thus, we no longer need to remember that the RenderViewHost - // is part of a pending cross-site request. - pending_render_view_host_->SetHasPendingCrossSiteRequest(false, - new_request_id); -} - void RenderViewHostManager::RendererAbortedProvisionalLoad( RenderViewHost* render_view_host) { // We used to cancel the pending renderer here for cross-site downloads. @@ -215,6 +194,17 @@ void RenderViewHostManager::RendererAbortedProvisionalLoad( // the response is not a download. } +void RenderViewHostManager::OnJavaScriptMessageBoxClosed( + IPC::Message* reply_msg, + bool success, + const std::wstring& prompt) { + render_view_host_->JavaScriptMessageBoxClosed(reply_msg, success, prompt); +} + +void RenderViewHostManager::OnJavaScriptMessageBoxWindowDestroyed() { + render_view_host_->JavaScriptMessageBoxWindowDestroyed(); +} + void RenderViewHostManager::ShouldClosePage(bool proceed) { // Should only see this while we have a pending renderer. Otherwise, we // should ignore. @@ -245,15 +235,32 @@ void RenderViewHostManager::ShouldClosePage(bool proceed) { } } -void RenderViewHostManager::OnJavaScriptMessageBoxClosed( - IPC::Message* reply_msg, - bool success, - const std::wstring& prompt) { - render_view_host_->JavaScriptMessageBoxClosed(reply_msg, success, prompt); +void RenderViewHostManager::OnCrossSiteResponse(int new_render_process_host_id, + int new_request_id) { + // Should only see this while we have a pending renderer. + if (!cross_navigation_pending_) + return; + DCHECK(pending_render_view_host_); + + // Tell the old renderer to run its onunload handler. When it finishes, it + // will send a ClosePage_ACK to the ResourceDispatcherHost with the given + // IDs (of the pending RVH's request), allowing the pending RVH's response to + // resume. + render_view_host_->ClosePage(new_render_process_host_id, new_request_id); + + // ResourceDispatcherHost has told us to run the onunload handler, which + // means it is not a download or unsafe page, and we are going to perform the + // navigation. Thus, we no longer need to remember that the RenderViewHost + // is part of a pending cross-site request. + pending_render_view_host_->SetHasPendingCrossSiteRequest(false, + new_request_id); } -void RenderViewHostManager::OnJavaScriptMessageBoxWindowDestroyed() { - render_view_host_->JavaScriptMessageBoxWindowDestroyed(); +void RenderViewHostManager::OnCrossSiteNavigationCanceled() { + DCHECK(cross_navigation_pending_); + cross_navigation_pending_ = false; + if (pending_render_view_host_) + CancelPending(); } bool RenderViewHostManager::ShouldTransitionCrossSite() { @@ -284,9 +291,10 @@ bool RenderViewHostManager::ShouldSwapProcessesForNavigation( // Also, we must switch if one is an extension and the other is not the exact // same extension. if (cur_entry->url().SchemeIs(chrome::kExtensionScheme) || - new_entry->url().SchemeIs(chrome::kExtensionScheme)) + new_entry->url().SchemeIs(chrome::kExtensionScheme)) { if (cur_entry->url().GetOrigin() != new_entry->url().GetOrigin()) return true; + } return false; } @@ -577,10 +585,3 @@ void RenderViewHostManager::CancelPending() { pending_dom_ui_.reset(); } - -void RenderViewHostManager::CrossSiteNavigationCanceled() { - DCHECK(cross_navigation_pending_); - cross_navigation_pending_ = false; - if (pending_render_view_host_) - CancelPending(); -} diff --git a/chrome/browser/tab_contents/render_view_host_manager.h b/chrome/browser/tab_contents/render_view_host_manager.h index a725d16..0b2460b 100644 --- a/chrome/browser/tab_contents/render_view_host_manager.h +++ b/chrome/browser/tab_contents/render_view_host_manager.h @@ -8,6 +8,7 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" #include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_observer.h" @@ -16,14 +17,14 @@ class InterstitialPage; class NavigationController; class NavigationEntry; class Profile; -class RenderViewHostDelegate; class RenderWidgetHostView; class SiteInstance; // Manages RenderViewHosts for a TabContents. Normally there is only one and // it is easy to do. But we can also have transitions of processes (and hence // RenderViewHosts) that can get complex. -class RenderViewHostManager { +class RenderViewHostManager + : public RenderViewHostDelegate::RendererManagement { public: // Functions implemented by our owner that we need. // @@ -126,23 +127,9 @@ class RenderViewHostManager { // Called when a renderer's main frame navigates. void DidNavigateMainFrame(RenderViewHost* render_view_host); - // Allows the TabContents to react when a cross-site response is ready to be - // delivered to a pending RenderViewHost. We must first run the onunload - // handler of the old RenderViewHost before we can allow it to proceed. - void OnCrossSiteResponse(int new_render_process_host_id, - int new_request_id); - - // Notifies that the navigation that initiated a cross-site transition has - // been canceled. - void CrossSiteNavigationCanceled(); - // Called when a provisional load on the given renderer is aborted. void RendererAbortedProvisionalLoad(RenderViewHost* render_view_host); - // Actually implements this RenderViewHostDelegate function for the - // TabContents. - void ShouldClosePage(bool proceed); - // Forwards the message to the RenderViewHost, which is the original one. void OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg, bool success, @@ -172,6 +159,12 @@ class RenderViewHostManager { return interstitial_page_; } + // RenderViewHostDelegate::RendererManagement implementation. + virtual void ShouldClosePage(bool proceed); + virtual void OnCrossSiteResponse(int new_render_process_host_id, + int new_request_id); + virtual void OnCrossSiteNavigationCanceled(); + private: friend class TestTabContents; diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index cddddfb..001be58 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -149,10 +149,6 @@ const wchar_t* kPrefsToObserve[] = { const int kPrefsToObserveLength = arraysize(kPrefsToObserve); -// Limit on the number of suggestions to appear in the pop-up menu under an -// text input element in a form. -const int kMaxAutofillMenuItems = 6; - // Returns true if the entry's transition type is FORM_SUBMIT. bool IsFormSubmit(const NavigationEntry* entry) { return (PageTransition::StripQualifier(entry->transition_type()) == @@ -415,12 +411,6 @@ bool TabContents::HostsExtension() const { return GetURL().SchemeIs(chrome::kExtensionScheme); } -AutofillManager* TabContents::GetAutofillManager() { - if (autofill_manager_.get() == NULL) - autofill_manager_.reset(new AutofillManager(this)); - return autofill_manager_.get(); -} - PasswordManager* TabContents::GetPasswordManager() { if (password_manager_.get() == NULL) password_manager_.reset(new PasswordManager(this)); @@ -1681,25 +1671,40 @@ void TabContents::DocumentLoadedInFrame() { controller_.DocumentLoadedInFrame(); } -RenderViewHostDelegate::View* TabContents::GetViewDelegate() const { +RenderViewHostDelegate::View* TabContents::GetViewDelegate() { return view_.get(); } +RenderViewHostDelegate::RendererManagement* +TabContents::GetRendererManagementDelegate() { + return &render_manager_; +} + RenderViewHostDelegate::BrowserIntegration* - TabContents::GetBrowserIntegrationDelegate() const { - return const_cast<TabContents*>(this); + TabContents::GetBrowserIntegrationDelegate() { + return this; } -RenderViewHostDelegate::Resource* TabContents::GetResourceDelegate() const { - return const_cast<TabContents*>(this); +RenderViewHostDelegate::Resource* TabContents::GetResourceDelegate() { + return this; } -RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() const { +RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() { return save_package_.get(); // May be NULL, but we can return NULL. } -RenderViewHostDelegate::FavIcon* TabContents::GetFavIconDelegate() const { - return &const_cast<TabContents*>(this)->fav_icon_helper_; +RenderViewHostDelegate::Printing* TabContents::GetPrintingDelegate() { + return &printing_; +} + +RenderViewHostDelegate::FavIcon* TabContents::GetFavIconDelegate() { + return &fav_icon_helper_; +} + +RenderViewHostDelegate::Autofill* TabContents::GetAutofillDelegate() { + if (autofill_manager_.get() == NULL) + autofill_manager_.reset(new AutofillManager(this)); + return autofill_manager_.get(); } RendererPreferences TabContents::GetRendererPrefs() const { @@ -2068,22 +2073,6 @@ void TabContents::PasswordFormsSeen( GetPasswordManager()->PasswordFormsSeen(forms); } -void TabContents::AutofillFormSubmitted( - const webkit_glue::AutofillForm& form) { - GetAutofillManager()->AutofillFormSubmitted(form); -} - -void TabContents::GetAutofillSuggestions(const std::wstring& field_name, - const std::wstring& user_text, int64 node_id, int request_id) { - GetAutofillManager()->FetchValuesForName(field_name, user_text, - kMaxAutofillMenuItems, node_id, request_id); -} - -void TabContents::RemoveAutofillEntry(const std::wstring& field_name, - const std::wstring& value) { - GetAutofillManager()->RemoveValueForName(field_name, value); -} - // Checks to see if we should generate a keyword based on the OSDD, and if // necessary uses TemplateURLFetcher to download the OSDD and create a keyword. void TabContents::PageHasOSDD(RenderViewHost* render_view_host, @@ -2153,14 +2142,6 @@ void TabContents::PageHasOSDD(RenderViewHost* render_view_host, autodetected); } -void TabContents::DidGetPrintedPagesCount(int cookie, int number_pages) { - printing_.DidGetPrintedPagesCount(cookie, number_pages); -} - -void TabContents::DidPrintPage(const ViewHostMsg_DidPrintPage_Params& params) { - printing_.DidPrintPage(params); -} - GURL TabContents::GetAlternateErrorPageURL() const { GURL url; // Disable alternate error pages when in OffTheRecord/Incognito mode. @@ -2200,10 +2181,6 @@ void TabContents::OnCrossSiteResponse(int new_render_process_host_id, new_request_id); } -void TabContents::OnCrossSiteNavigationCanceled() { - render_manager_.CrossSiteNavigationCanceled(); -} - bool TabContents::CanBlur() const { return delegate() ? delegate()->CanBlur() : true; } diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 6b8f417..99e99a1 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -142,9 +142,6 @@ class TabContents : public PageNavigator, // Returns true if contains content rendered by an extension. bool HostsExtension() const; - // Returns the AutofillManager, creating it if necessary. - AutofillManager* GetAutofillManager(); - // Returns the PasswordManager, creating it if necessary. PasswordManager* GetPasswordManager(); @@ -771,12 +768,16 @@ class TabContents : public PageNavigator, virtual void DocumentLoadedInFrame(); // RenderViewHostDelegate implementation. - virtual RenderViewHostDelegate::View* GetViewDelegate() const; + virtual RenderViewHostDelegate::View* GetViewDelegate(); + virtual RenderViewHostDelegate::RendererManagement* + GetRendererManagementDelegate(); virtual RenderViewHostDelegate::BrowserIntegration* - GetBrowserIntegrationDelegate() const; - virtual RenderViewHostDelegate::Resource* GetResourceDelegate() const; - virtual RenderViewHostDelegate::Save* GetSaveDelegate() const; - virtual RenderViewHostDelegate::FavIcon* GetFavIconDelegate() const; + GetBrowserIntegrationDelegate(); + virtual RenderViewHostDelegate::Resource* GetResourceDelegate(); + virtual RenderViewHostDelegate::Save* GetSaveDelegate(); + virtual RenderViewHostDelegate::Printing* GetPrintingDelegate(); + virtual RenderViewHostDelegate::FavIcon* GetFavIconDelegate(); + virtual RenderViewHostDelegate::Autofill* GetAutofillDelegate(); virtual TabContents* GetAsTabContents(); virtual void RenderViewCreated(RenderViewHost* render_view_host); virtual void RenderViewReady(RenderViewHost* render_view_host); @@ -828,15 +829,8 @@ class TabContents : public PageNavigator, IPC::Message* reply_msg); virtual void PasswordFormsSeen( const std::vector<webkit_glue::PasswordForm>& forms); - virtual void AutofillFormSubmitted(const webkit_glue::AutofillForm& form); - virtual void GetAutofillSuggestions(const std::wstring& field_name, - const std::wstring& user_text, int64 node_id, int request_id); - virtual void RemoveAutofillEntry(const std::wstring& field_name, - const std::wstring& value); virtual void PageHasOSDD(RenderViewHost* render_view_host, int32 page_id, const GURL& url, bool autodetected); - virtual void DidGetPrintedPagesCount(int cookie, int number_pages); - virtual void DidPrintPage(const ViewHostMsg_DidPrintPage_Params& params); virtual GURL GetAlternateErrorPageURL() const; virtual RendererPreferences GetRendererPrefs() const; virtual WebPreferences GetWebkitPrefs(); @@ -844,7 +838,6 @@ class TabContents : public PageNavigator, virtual void ShouldClosePage(bool proceed); virtual void OnCrossSiteResponse(int new_render_process_host_id, int new_request_id); - virtual void OnCrossSiteNavigationCanceled(); virtual bool CanBlur() const; virtual gfx::Rect GetRootWindowResizerRect() const; virtual void RendererUnresponsive(RenderViewHost* render_view_host, |