diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-25 19:07:44 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-25 19:07:44 +0000 |
commit | 34f128ddf083c4ff1d21bb2bf10859cf2c040ad6 (patch) | |
tree | 31c266487bf62bc13a451288fa8333c1506f092c | |
parent | 6804b15439f1f40d38df1052e6165a55f216e2ec (diff) | |
download | chromium_src-34f128ddf083c4ff1d21bb2bf10859cf2c040ad6.zip chromium_src-34f128ddf083c4ff1d21bb2bf10859cf2c040ad6.tar.gz chromium_src-34f128ddf083c4ff1d21bb2bf10859cf2c040ad6.tar.bz2 |
Get rid of a few more interfaces from RenderViewHostDelegate that aren't needed.
Review URL: http://codereview.chromium.org/6374009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72522 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/download/save_package.cc | 13 | ||||
-rw-r--r-- | chrome/browser/download/save_package.h | 32 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 22 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.h | 7 | ||||
-rw-r--r-- | chrome/browser/fav_icon_helper.cc | 24 | ||||
-rw-r--r-- | chrome/browser/fav_icon_helper.h | 21 | ||||
-rw-r--r-- | chrome/browser/file_select_helper.h | 8 | ||||
-rw-r--r-- | chrome/browser/printing/print_view_manager.cc | 16 | ||||
-rw-r--r-- | chrome/browser/printing/print_view_manager.h | 14 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 70 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 11 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.cc | 19 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 90 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 40 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 8 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.h | 1 |
16 files changed, 124 insertions, 272 deletions
diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index 53fc1fe..8d8a834 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -44,6 +44,7 @@ #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" #include "chrome/common/pref_names.h" +#include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" #include "grit/generated_resources.h" #include "net/base/io_buffer.h" @@ -899,6 +900,18 @@ void SavePackage::DoSavingProcess() { } } +bool SavePackage::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(SavePackage, message) + IPC_MESSAGE_HANDLER(ViewHostMsg_SendCurrentPageAllSavableResourceLinks, + OnReceivedSavableResourceLinksForCurrentPage) + IPC_MESSAGE_HANDLER(ViewHostMsg_SendSerializedHtmlData, + OnReceivedSerializedHtmlData) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + // After finishing all SaveItems which need to get data from net. // We collect all URLs which have local storage and send the // map:(originalURL:currentLocalPath) to render process (backend). diff --git a/chrome/browser/download/save_package.h b/chrome/browser/download/save_package.h index ddfc172..62c1c1d 100644 --- a/chrome/browser/download/save_package.h +++ b/chrome/browser/download/save_package.h @@ -16,8 +16,8 @@ #include "base/hash_tables.h" #include "base/ref_counted.h" #include "base/task.h" -#include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/shell_dialogs.h" +#include "chrome/browser/tab_contents/web_navigation_observer.h" #include "googleurl/src/gurl.h" class SaveFileManager; @@ -54,7 +54,7 @@ struct SavePackageParam; // by the SavePackage. SaveItems are created when a user initiates a page // saving job, and exist for the duration of one tab's life time. class SavePackage : public base::RefCountedThreadSafe<SavePackage>, - public RenderViewHostDelegate::Save, + public WebNavigationObserver, public SelectFileDialog::Listener { public: enum SavePackageType { @@ -128,22 +128,6 @@ class SavePackage : public base::RefCountedThreadSafe<SavePackage>, void GetSaveInfo(); - // RenderViewHostDelegate::Save ---------------------------------------------- - - // Process all of the current page's savable links of subresources, resources - // referrers and frames (including the main frame and subframes) from the - // render view host. - virtual void OnReceivedSavableResourceLinksForCurrentPage( - const std::vector<GURL>& resources_list, - const std::vector<GURL>& referrers_list, - const std::vector<GURL>& frames_list); - - // Process the serialized html content data of a specified web page - // gotten from render process. - virtual void OnReceivedSerializedHtmlData(const GURL& frame_url, - const std::string& data, - int32 status); - // Statics ------------------------------------------------------------------- // Used to disable prompting the user for a directory/filename of the saved @@ -179,6 +163,9 @@ class SavePackage : public base::RefCountedThreadSafe<SavePackage>, void SaveNextFile(bool process_all_remainder_items); void DoSavingProcess(); + // WebNavigationObserver implementation. + virtual bool OnMessageReceived(const IPC::Message& message); + // Create a file name based on the response from the server. bool GenerateFileName(const std::string& disposition, const GURL& url, @@ -205,6 +192,15 @@ class SavePackage : public base::RefCountedThreadSafe<SavePackage>, bool can_save_as_complete); void ContinueSave(const FilePath& final_name, int index); + void OnReceivedSavableResourceLinksForCurrentPage( + const std::vector<GURL>& resources_list, + const std::vector<GURL>& referrers_list, + const std::vector<GURL>& frames_list); + + void OnReceivedSerializedHtmlData(const GURL& frame_url, + const std::string& data, + int32 status); + typedef base::hash_map<std::string, SaveItem*> SaveUrlItemMap; // in_progress_items_ is map of all saving job in in-progress state. diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index b854971..3c707b8 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -757,6 +757,15 @@ ViewType::Type ExtensionHost::GetRenderViewType() const { return extension_host_type_; } +bool ExtensionHost::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message) + IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + const GURL& ExtensionHost::GetURL() const { return url_; } @@ -779,12 +788,6 @@ void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { } } -RenderViewHostDelegate::FileSelect* ExtensionHost::GetFileSelectDelegate() { - if (file_select_helper_.get() == NULL) - file_select_helper_.reset(new FileSelectHelper(profile())); - return file_select_helper_.get(); -} - int ExtensionHost::GetBrowserWindowID() const { // Hosts not attached to any browser window have an id of -1. This includes // those mentioned below, and background pages. @@ -802,3 +805,10 @@ int ExtensionHost::GetBrowserWindowID() const { } return window_id; } + +void ExtensionHost::OnRunFileChooser( + const ViewHostMsg_RunFileChooser_Params& params) { + if (file_select_helper_.get() == NULL) + file_select_helper_.reset(new FileSelectHelper(profile())); + file_select_helper_->RunFileChooser(render_view_host_, params); +} diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 51db000..c9422ce 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -106,11 +106,11 @@ class ExtensionHost : public RenderViewHostDelegate, // |size_limit| in both width and height. void DisableScrollbarsForSmallWindows(const gfx::Size& size_limit); - // RenderViewHostDelegate::View implementation. + // RenderViewHostDelegate implementation. + virtual bool OnMessageReceived(const IPC::Message& message); virtual const GURL& GetURL() const; virtual void RenderViewCreated(RenderViewHost* render_view_host); virtual ViewType::Type GetRenderViewType() const; - virtual FileSelect* GetFileSelectDelegate(); virtual int GetBrowserWindowID() const; virtual void RenderViewGone(RenderViewHost* render_view_host, base::TerminationStatus status, @@ -226,6 +226,9 @@ class ExtensionHost : public RenderViewHostDelegate, virtual Browser* GetBrowser(); virtual gfx::NativeView GetNativeViewOfHost(); + // Message handlers. + void OnRunFileChooser(const ViewHostMsg_RunFileChooser_Params& params); + // Handles keyboard events that were not handled by HandleKeyboardEvent(). // Platform specific implementation may override this method to handle the // event in platform specific way. diff --git a/chrome/browser/fav_icon_helper.cc b/chrome/browser/fav_icon_helper.cc index 544b4e8..8501ef3 100644 --- a/chrome/browser/fav_icon_helper.cc +++ b/chrome/browser/fav_icon_helper.cc @@ -17,6 +17,7 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents_delegate.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/common/render_messages.h" #include "gfx/codec/png_codec.h" #include "gfx/favicon_size.h" #include "skia/ext/image_operations.h" @@ -111,9 +112,7 @@ void FavIconHelper::UpdateFavIcon(NavigationEntry* entry, tab_contents_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB); } -void FavIconHelper::UpdateFavIconURL(RenderViewHost* render_view_host, - int32 page_id, - const GURL& icon_url) { +void FavIconHelper::OnUpdateFavIconURL(int32 page_id, const GURL& icon_url) { // TODO(davemoore) Should clear on empty url. Currently we ignore it. // This appears to be what FF does as well. if (icon_url.is_empty()) @@ -140,11 +139,20 @@ void FavIconHelper::UpdateFavIconURL(RenderViewHost* render_view_host, DownloadFavIconOrAskHistory(entry); } -void FavIconHelper::DidDownloadFavIcon(RenderViewHost* render_view_host, - int id, - const GURL& image_url, - bool errored, - const SkBitmap& image) { +bool FavIconHelper::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(FavIconHelper, message) + IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFavIconURL, OnUpdateFavIconURL) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidDownloadFavIcon, OnDidDownloadFavIcon) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void FavIconHelper::OnDidDownloadFavIcon(int id, + const GURL& image_url, + bool errored, + const SkBitmap& image) { DownloadRequests::iterator i = download_requests_.find(id); if (i == download_requests_.end()) { // Currently TabContents notifies us of ANY downloads so that it is diff --git a/chrome/browser/fav_icon_helper.h b/chrome/browser/fav_icon_helper.h index a64eba2..f0706bd 100644 --- a/chrome/browser/fav_icon_helper.h +++ b/chrome/browser/fav_icon_helper.h @@ -13,7 +13,7 @@ #include "base/ref_counted.h" #include "chrome/browser/cancelable_request.h" #include "chrome/browser/favicon_service.h" -#include "chrome/browser/renderer_host/render_view_host_delegate.h" +#include "chrome/browser/tab_contents/web_navigation_observer.h" #include "chrome/common/ref_counted_util.h" #include "googleurl/src/gurl.h" @@ -65,7 +65,7 @@ class TabContents; // at which point we update the favicon of the NavigationEntry and notify // the database to save the favicon. -class FavIconHelper : public RenderViewHostDelegate::FavIcon { +class FavIconHelper : public WebNavigationObserver { public: explicit FavIconHelper(TabContents* tab_contents); virtual ~FavIconHelper(); @@ -99,15 +99,14 @@ class FavIconHelper : public RenderViewHostDelegate::FavIcon { ImageDownloadCallback* callback; }; - // RenderViewHostDelegate::Favicon implementation. - virtual void DidDownloadFavIcon(RenderViewHost* render_view_host, - int id, - const GURL& image_url, - bool errored, - const SkBitmap& image); - virtual void UpdateFavIconURL(RenderViewHost* render_view_host, - int32 page_id, - const GURL& icon_url); + // WebNavigationObserver implementation. + virtual bool OnMessageReceived(const IPC::Message& message); + + void OnDidDownloadFavIcon(int id, + const GURL& image_url, + bool errored, + const SkBitmap& image); + void OnUpdateFavIconURL(int32 page_id, const GURL& icon_url); // Return the NavigationEntry for the active entry, or NULL if the active // entries URL does not match that of the URL last passed to FetchFavIcon. diff --git a/chrome/browser/file_select_helper.h b/chrome/browser/file_select_helper.h index ba8441b..3a6fb6a 100644 --- a/chrome/browser/file_select_helper.h +++ b/chrome/browser/file_select_helper.h @@ -9,7 +9,6 @@ #include <vector> #include "chrome/browser/shell_dialogs.h" -#include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "net/base/directory_lister.h" @@ -21,7 +20,6 @@ struct ViewHostMsg_RunFileChooser_Params; class FileSelectHelper : public SelectFileDialog::Listener, public net::DirectoryLister::DirectoryListerDelegate, - public RenderViewHostDelegate::FileSelect, public NotificationObserver { public: explicit FileSelectHelper(Profile* profile); @@ -38,9 +36,9 @@ class FileSelectHelper const net::DirectoryLister::DirectoryListerData& data); virtual void OnListDone(int error); - // RenderViewHostDelegate::FileSelect - virtual void RunFileChooser(RenderViewHost* render_view_host, - const ViewHostMsg_RunFileChooser_Params& params); + // Show the file chooser dialog. + void RunFileChooser(RenderViewHost* render_view_host, + const ViewHostMsg_RunFileChooser_Params& params); private: // NotificationObserver implementation. diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index 84efcf4..2677062 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -15,6 +15,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/notification_details.h" #include "chrome/common/notification_source.h" +#include "chrome/common/render_messages.h" #include "chrome/common/render_messages_params.h" #include "grit/generated_resources.h" #include "printing/native_metafile.h" @@ -73,7 +74,7 @@ GURL PrintViewManager::RenderSourceUrl() { return GURL(); } -void PrintViewManager::DidGetPrintedPagesCount(int cookie, int number_pages) { +void PrintViewManager::OnDidGetPrintedPagesCount(int cookie, int number_pages) { DCHECK_GT(cookie, 0); if (!OpportunisticallyCreatePrintJob(cookie)) return; @@ -91,7 +92,7 @@ void PrintViewManager::DidGetPrintedPagesCount(int cookie, int number_pages) { } } -void PrintViewManager::DidPrintPage( +void PrintViewManager::OnDidPrintPage( const ViewHostMsg_DidPrintPage_Params& params) { if (!OpportunisticallyCreatePrintJob(params.document_cookie)) return; @@ -143,6 +144,17 @@ void PrintViewManager::DidPrintPage( ShouldQuitFromInnerMessageLoop(); } +bool PrintViewManager::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(PrintViewManager, message) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetPrintedPagesCount, + OnDidGetPrintedPagesCount) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, OnDidPrintPage) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + void PrintViewManager::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { diff --git a/chrome/browser/printing/print_view_manager.h b/chrome/browser/printing/print_view_manager.h index cee7382..2fcf4d1 100644 --- a/chrome/browser/printing/print_view_manager.h +++ b/chrome/browser/printing/print_view_manager.h @@ -8,7 +8,7 @@ #include "base/ref_counted.h" #include "base/string16.h" -#include "chrome/browser/renderer_host/render_view_host_delegate.h" +#include "chrome/browser/tab_contents/web_navigation_observer.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "printing/printed_pages_source.h" @@ -27,7 +27,7 @@ class PrintJobWorkerOwner; // delegates a few printing related commands to this instance. class PrintViewManager : public NotificationObserver, public PrintedPagesSource, - public RenderViewHostDelegate::Printing { + public WebNavigationObserver { public: explicit PrintViewManager(TabContents& owner); virtual ~PrintViewManager(); @@ -43,16 +43,18 @@ class PrintViewManager : public NotificationObserver, virtual string16 RenderSourceName(); virtual GURL RenderSourceUrl(); - // RenderViewHostDelegate::Printing implementation. - virtual void DidGetPrintedPagesCount(int cookie, int number_pages); - virtual void DidPrintPage(const ViewHostMsg_DidPrintPage_Params& params); - // NotificationObserver implementation. virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details); + // WebNavigationObserver implementation. + virtual bool OnMessageReceived(const IPC::Message& message); + private: + void OnDidGetPrintedPagesCount(int cookie, int number_pages); + void OnDidPrintPage(const ViewHostMsg_DidPrintPage_Params& params); + // Processes a NOTIFY_PRINT_JOB_EVENT notification. void OnNotifyPrintJobEvent(const JobEventDetails& event_details); diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 5f12b62..566f1fc 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -763,8 +763,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { OnMsgDocumentOnLoadCompletedInMainFrame) IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCodeFinished, OnExecuteCodeFinished) - IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFavIconURL, OnMsgUpdateFavIconURL) - IPC_MESSAGE_HANDLER(ViewHostMsg_DidDownloadFavIcon, OnMsgDidDownloadFavIcon) IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu) IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, @@ -775,7 +773,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardMessageToExternalHost, OnMsgForwardMessageToExternalHost) IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) - IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnMsgRunFileChooser) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, OnMsgRunJavaScriptMessage) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, @@ -786,9 +783,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateDragCursor, OnUpdateDragCursor) IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) IPC_MESSAGE_HANDLER(ViewHostMsg_PageHasOSDD, OnMsgPageHasOSDD) - IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetPrintedPagesCount, - OnDidGetPrintedPagesCount) - IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, DidPrintPage) IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToDevToolsAgent, OnForwardToDevToolsAgent) @@ -804,10 +798,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { OnRequestUndockDevToolsWindow) IPC_MESSAGE_HANDLER(ViewHostMsg_DevToolsRuntimePropertyChanged, OnDevToolsRuntimePropertyChanged) - IPC_MESSAGE_HANDLER(ViewHostMsg_SendCurrentPageAllSavableResourceLinks, - OnReceivedSavableResourceLinksForCurrentPage) - IPC_MESSAGE_HANDLER(ViewHostMsg_SendSerializedHtmlData, - OnReceivedSerializedHtmlData) IPC_MESSAGE_FORWARD(ViewHostMsg_JSOutOfMemory, delegate_, RenderViewHostDelegate::OnJSOutOfMemory) IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) @@ -1102,24 +1092,6 @@ void RenderViewHost::OnExecuteCodeFinished(int request_id, bool success) { Details<std::pair<int, bool> >(&result_details)); } -void RenderViewHost::OnMsgUpdateFavIconURL(int32 page_id, - const GURL& icon_url) { - RenderViewHostDelegate::FavIcon* favicon_delegate = - delegate_->GetFavIconDelegate(); - if (favicon_delegate) - favicon_delegate->UpdateFavIconURL(this, page_id, icon_url); -} - -void RenderViewHost::OnMsgDidDownloadFavIcon(int id, - const GURL& image_url, - bool errored, - const SkBitmap& image) { - RenderViewHostDelegate::FavIcon* favicon_delegate = - delegate_->GetFavIconDelegate(); - if (favicon_delegate) - favicon_delegate->DidDownloadFavIcon(this, id, image_url, errored, image); -} - void RenderViewHost::OnMsgContextMenu(const ContextMenuParams& params) { RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); if (!view) @@ -1257,14 +1229,6 @@ void RenderViewHost::OnMsgSelectionChanged(const std::string& text) { view()->SelectionChanged(text); } -void RenderViewHost::OnMsgRunFileChooser( - const ViewHostMsg_RunFileChooser_Params& params) { - RenderViewHostDelegate::FileSelect* file_select_delegate = - delegate()->GetFileSelectDelegate(); - if (file_select_delegate) - file_select_delegate->RunFileChooser(this, params); -} - void RenderViewHost::OnMsgRunJavaScriptMessage( const std::wstring& message, const std::wstring& default_prompt, @@ -1340,21 +1304,6 @@ void RenderViewHost::OnMsgPageHasOSDD( delegate_->PageHasOSDD(this, page_id, doc_url, provider_type); } -void RenderViewHost::OnDidGetPrintedPagesCount(int cookie, int number_pages) { - RenderViewHostDelegate::Printing* printing_delegate = - delegate_->GetPrintingDelegate(); - if (printing_delegate) - printing_delegate->DidGetPrintedPagesCount(cookie, number_pages); -} - -void RenderViewHost::DidPrintPage( - const ViewHostMsg_DidPrintPage_Params& params) { - RenderViewHostDelegate::Printing* printing_delegate = - delegate_->GetPrintingDelegate(); - if (printing_delegate) - printing_delegate->DidPrintPage(params); -} - void RenderViewHost::OnAddMessageToConsole(const std::wstring& message, int32 line_no, const std::wstring& source_id) { @@ -1417,17 +1366,6 @@ void RenderViewHost::GetAllSavableResourceLinksForCurrentPage( page_url)); } -void RenderViewHost::OnReceivedSavableResourceLinksForCurrentPage( - const std::vector<GURL>& resources_list, - const std::vector<GURL>& referrers_list, - const std::vector<GURL>& frames_list) { - RenderViewHostDelegate::Save* save_delegate = delegate_->GetSaveDelegate(); - if (save_delegate) { - save_delegate->OnReceivedSavableResourceLinksForCurrentPage( - resources_list, referrers_list, frames_list); - } -} - void RenderViewHost::GetSerializedHtmlDataForCurrentPageWithLocalLinks( const std::vector<GURL>& links, const std::vector<FilePath>& local_paths, @@ -1436,14 +1374,6 @@ void RenderViewHost::GetSerializedHtmlDataForCurrentPageWithLocalLinks( routing_id(), links, local_paths, local_directory_name)); } -void RenderViewHost::OnReceivedSerializedHtmlData(const GURL& frame_url, - const std::string& data, - int32 status) { - RenderViewHostDelegate::Save* save_delegate = delegate_->GetSaveDelegate(); - if (save_delegate) - save_delegate->OnReceivedSerializedHtmlData(frame_url, data, status); -} - void RenderViewHost::OnMsgShouldCloseACK(bool proceed) { StopHangMonitorTimeout(); // If this renderer navigated while the beforeunload request was in flight, we diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index e1b6a3a..0864905 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -591,7 +591,6 @@ class RenderViewHost : public RenderWidgetHost { WebKit::WebTextDirection text_direction_hint); void OnMsgSelectionChanged(const std::string& text); void OnMsgPasteFromSelectionClipboard(); - void OnMsgRunFileChooser(const ViewHostMsg_RunFileChooser_Params& params); void OnMsgRunJavaScriptMessage(const std::wstring& message, const std::wstring& default_prompt, const GURL& frame_url, @@ -612,8 +611,6 @@ class RenderViewHost : public RenderWidgetHost { void OnMsgPageHasOSDD(int32 page_id, const GURL& doc_url, const ViewHostMsg_PageHasOSDD_Type& provider_type); - void OnDidGetPrintedPagesCount(int cookie, int number_pages); - void DidPrintPage(const ViewHostMsg_DidPrintPage_Params& params); void OnAddMessageToConsole(const std::wstring& message, int32 line_no, const std::wstring& source_id); @@ -627,14 +624,6 @@ class RenderViewHost : public RenderWidgetHost { void OnRequestUndockDevToolsWindow(); void OnDevToolsRuntimePropertyChanged(const std::string& name, const std::string& value); - void OnReceivedSavableResourceLinksForCurrentPage( - const std::vector<GURL>& resources_list, - const std::vector<GURL>& referrers_list, - const std::vector<GURL>& frames_list); - void OnReceivedSerializedHtmlData(const GURL& frame_url, - const std::string& data, - int32 status); - void OnMsgShouldCloseACK(bool proceed); void OnShowDesktopNotification( const ViewHostMsg_ShowNotification_Params& params); diff --git a/chrome/browser/renderer_host/render_view_host_delegate.cc b/chrome/browser/renderer_host/render_view_host_delegate.cc index 0bbbb58..7299844 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.cc +++ b/chrome/browser/renderer_host/render_view_host_delegate.cc @@ -30,20 +30,6 @@ RenderViewHostDelegate::GetContentSettingsDelegate() { return NULL; } -RenderViewHostDelegate::Save* RenderViewHostDelegate::GetSaveDelegate() { - return NULL; -} - -RenderViewHostDelegate::Printing* -RenderViewHostDelegate::GetPrintingDelegate() { - return NULL; -} - -RenderViewHostDelegate::FavIcon* -RenderViewHostDelegate::GetFavIconDelegate() { - return NULL; -} - RenderViewHostDelegate::BookmarkDrag* RenderViewHostDelegate::GetBookmarkDragDelegate() { return NULL; @@ -54,11 +40,6 @@ RenderViewHostDelegate::GetSSLDelegate() { return NULL; } -RenderViewHostDelegate::FileSelect* -RenderViewHostDelegate::GetFileSelectDelegate() { - return NULL; -} - AutomationResourceRoutingDelegate* RenderViewHostDelegate::GetAutomationResourceRoutingDelegate() { return NULL; diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 7cab0be..ef02f96 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -318,78 +318,6 @@ class RenderViewHostDelegate : public IPC::Channel::Listener { virtual ~ContentSettings() {} }; - // Save ---------------------------------------------------------------------- - // Interface for saving web pages. - - class Save { - public: - // Notification that we get when we receive all savable links of - // sub-resources for the current page, their referrers and list of frames - // (include main frame and sub frames). - virtual void OnReceivedSavableResourceLinksForCurrentPage( - const std::vector<GURL>& resources_list, - const std::vector<GURL>& referrers_list, - const std::vector<GURL>& frames_list) = 0; - - // Notification that we get when we receive serialized html content data of - // a specified web page from render process. The parameter frame_url - // specifies what frame the data belongs. The parameter data contains the - // available data for sending. The parameter status indicates the - // serialization status, See - // webkit_glue::DomSerializerDelegate::PageSavingSerializationStatus for - // the detail meaning of status. - virtual void OnReceivedSerializedHtmlData(const GURL& frame_url, - const std::string& data, - int32 status) = 0; - - protected: - virtual ~Save() {} - }; - - // Printing ------------------------------------------------------------------ - - class Printing { - public: - // Notification that the render view has calculated the number of printed - // pages. - virtual void DidGetPrintedPagesCount(int cookie, int number_pages) = 0; - - // Notification that the render view is done rendering one printed page. - // This call is synchronous, the renderer is waiting on us because of the - // EMF memory mapped data. - virtual void DidPrintPage( - const ViewHostMsg_DidPrintPage_Params& params) = 0; - - protected: - virtual ~Printing() {} - }; - - // FavIcon ------------------------------------------------------------------- - // Interface for the renderer to supply favicon information. - - class FavIcon { - public: - // An image that was requested to be downloaded by DownloadImage has - // completed. - // - // TODO(brettw) this should be renamed DidDownloadFavIcon, and the RVH - // function, IPC message, and the RenderView function DownloadImage should - // all be named DownloadFavIcon. - virtual void DidDownloadFavIcon(RenderViewHost* render_view_host, - int id, - const GURL& image_url, - bool errored, - const SkBitmap& image) = 0; - - // The URL for the FavIcon of a page has changed. - virtual void UpdateFavIconURL(RenderViewHost* render_view_host, - int32 page_id, - const GURL& icon_url) = 0; - - protected: - virtual ~FavIcon() {} - }; - // BookmarkDrag -------------------------------------------------------------- // Interface for forwarding bookmark drag and drop to extenstions. @@ -445,20 +373,6 @@ class RenderViewHostDelegate : public IPC::Channel::Listener { virtual ~SSL() {} }; - // FileSelect ---------------------------------------------------------------- - // Interface for handling file selection. - - class FileSelect { - public: - // A file chooser should be shown. - virtual void RunFileChooser( - RenderViewHost* render_view_host, - const ViewHostMsg_RunFileChooser_Params& params) = 0; - - protected: - virtual ~FileSelect() {} - }; - // --------------------------------------------------------------------------- // Returns the current delegate associated with a feature. May return NULL if @@ -466,13 +380,9 @@ class RenderViewHostDelegate : public IPC::Channel::Listener { virtual View* GetViewDelegate(); virtual RendererManagement* GetRendererManagementDelegate(); virtual ContentSettings* GetContentSettingsDelegate(); - virtual Save* GetSaveDelegate(); - virtual Printing* GetPrintingDelegate(); - virtual FavIcon* GetFavIconDelegate(); virtual BookmarkDrag* GetBookmarkDragDelegate(); virtual SSL* GetSSLDelegate(); - virtual FileSelect* GetFileSelectDelegate(); // Return the delegate for registering RenderViewHosts for automation resource // routing. diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 8b5b74c..cb494aa 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -472,6 +472,8 @@ TabContents::TabContents(Profile* profile, AddNavigationObserver(autofill_manager_.get()); autocomplete_history_manager_.reset(new AutocompleteHistoryManager(this)); AddNavigationObserver(autocomplete_history_manager_.get()); + AddNavigationObserver(&fav_icon_helper_); + AddNavigationObserver(printing_.get()); } TabContents::~TabContents() { @@ -635,6 +637,7 @@ bool TabContents::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestions, OnSetSuggestions) IPC_MESSAGE_HANDLER(ViewHostMsg_InstantSupportDetermined, OnInstantSupportDetermined) + IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() @@ -1456,7 +1459,7 @@ void TabContents::OnSavePage() { // Create the save package and possibly prompt the user for the name to save // the page as. The user prompt is an asynchronous operation that runs on // another thread. - save_package_ = new SavePackage(this); + SetSavePackage(new SavePackage(this)); save_package_->GetSaveInfo(); } @@ -1468,10 +1471,17 @@ bool TabContents::SavePage(const FilePath& main_file, const FilePath& dir_path, // Stop the page from navigating. Stop(); - save_package_ = new SavePackage(this, save_type, main_file, dir_path); + SetSavePackage(new SavePackage(this, save_type, main_file, dir_path)); return save_package_->Init(); } +void TabContents::SetSavePackage(SavePackage* save_package) { + if (save_package_.get()) + RemoveNavigationObserver(save_package_.get()); + save_package_ = save_package; + AddNavigationObserver(save_package); +} + void TabContents::EmailPageLocation() { std::string title = EscapeQueryParamValue(UTF16ToUTF8(GetTitle()), false); std::string page_url = EscapeQueryParamValue(GetURL().spec(), false); @@ -2423,6 +2433,14 @@ void TabContents::OnInstantSupportDetermined(int32 page_id, bool result) { delegate()->OnInstantSupportDetermined(page_id, result); } +void TabContents::OnRunFileChooser( + const ViewHostMsg_RunFileChooser_Params& params) { + if (file_select_helper_.get() == NULL) + file_select_helper_.reset(new FileSelectHelper(profile())); + file_select_helper_->RunFileChooser(render_view_host(), params); +} + + void TabContents::OnContentSettingsAccessed(bool content_was_blocked) { if (delegate_) delegate_->OnContentSettingsChange(this); @@ -2442,28 +2460,10 @@ TabContents::GetContentSettingsDelegate() { return content_settings_delegate_.get(); } -RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() { - return save_package_.get(); // May be NULL, but we can return NULL. -} - -RenderViewHostDelegate::Printing* TabContents::GetPrintingDelegate() { - return printing_.get(); -} - -RenderViewHostDelegate::FavIcon* TabContents::GetFavIconDelegate() { - return &fav_icon_helper_; -} - RenderViewHostDelegate::SSL* TabContents::GetSSLDelegate() { return GetSSLHelper(); } -RenderViewHostDelegate::FileSelect* TabContents::GetFileSelectDelegate() { - if (file_select_helper_.get() == NULL) - file_select_helper_.reset(new FileSelectHelper(profile())); - return file_select_helper_.get(); -} - AutomationResourceRoutingDelegate* TabContents::GetAutomationResourceRoutingDelegate() { return delegate(); diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index d22eeec..a40edfb 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -600,6 +600,9 @@ class TabContents : public PageNavigator, bool SavePage(const FilePath& main_file, const FilePath& dir_path, SavePackage::SavePackageType save_type); + // Sets save_package_, taking care to register and unregister the observers. + void SetSavePackage(SavePackage* save_package); + // Tells the user's email client to open a compose window containing the // current page's URL. void EmailPageLocation(); @@ -835,6 +838,7 @@ class TabContents : public PageNavigator, void OnSetSuggestions(int32 page_id, const std::vector<std::string>& suggestions); void OnInstantSupportDetermined(int32 page_id, bool result); + void OnRunFileChooser(const ViewHostMsg_RunFileChooser_Params& params); // Changes the IsLoading state and notifies delegate as needed // |details| is used to provide details on the load that just finished @@ -946,11 +950,7 @@ class TabContents : public PageNavigator, virtual RenderViewHostDelegate::RendererManagement* GetRendererManagementDelegate(); virtual RenderViewHostDelegate::ContentSettings* GetContentSettingsDelegate(); - virtual RenderViewHostDelegate::Save* GetSaveDelegate(); - virtual RenderViewHostDelegate::Printing* GetPrintingDelegate(); - virtual RenderViewHostDelegate::FavIcon* GetFavIconDelegate(); virtual RenderViewHostDelegate::SSL* GetSSLDelegate(); - virtual RenderViewHostDelegate::FileSelect* GetFileSelectDelegate(); virtual AutomationResourceRoutingDelegate* GetAutomationResourceRoutingDelegate(); virtual TabContents* GetAsTabContents(); diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index aabc2a6..0aa0cff 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -24,6 +24,7 @@ #include "chrome/test/automation/automation_handle_tracker.h" #include "chrome/test/automation/dom_element_proxy.h" #include "chrome/test/automation/javascript_execution_controller.h" +#include "webkit/glue/window_open_disposition.h" class GURL; class Value; |