diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-08 18:25:42 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-08 18:25:42 +0000 |
commit | 3ea60637f9c24092c7d9296a4ff7a68017547ba3 (patch) | |
tree | f09350c376c0a4b316ca56022f9b4445e7243db8 | |
parent | 5dd4976fcf3349f84eb74b8aa6d62340abf10aa0 (diff) | |
download | chromium_src-3ea60637f9c24092c7d9296a4ff7a68017547ba3.zip chromium_src-3ea60637f9c24092c7d9296a4ff7a68017547ba3.tar.gz chromium_src-3ea60637f9c24092c7d9296a4ff7a68017547ba3.tar.bz2 |
Move save package to TCW from TC.
BUG=71097
TEST=Save As... still works just fine.
Review URL: http://codereview.chromium.org/6816016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80962 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 8 | ||||
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 20 | ||||
-rw-r--r-- | chrome/browser/download/save_file_manager.cc | 11 | ||||
-rw-r--r-- | chrome/browser/download/save_page_browsertest.cc | 26 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.cc | 13 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/applescript/tab_applescript.mm | 9 | ||||
-rw-r--r-- | chrome/browser/ui/download/download_tab_helper.cc | 51 | ||||
-rw-r--r-- | chrome/browser/ui/download/download_tab_helper.h | 40 | ||||
-rw-r--r-- | chrome/browser/ui/tab_contents/tab_contents_wrapper.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/tab_contents/tab_contents_wrapper.h | 6 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 31 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.h | 16 |
14 files changed, 160 insertions, 79 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 59e3134..9ec3e86 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -67,6 +67,7 @@ #include "chrome/browser/ssl/ssl_manager.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" +#include "chrome/browser/ui/download/download_tab_helper.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/find_bar/find_bar.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" @@ -959,6 +960,9 @@ void AutomationProvider::GetExtensionProperty( void AutomationProvider::SaveAsAsync(int tab_handle) { NavigationController* tab = NULL; TabContents* tab_contents = GetTabContentsForHandle(tab_handle, &tab); - if (tab_contents) - tab_contents->OnSavePage(); + if (tab_contents) { + TabContentsWrapper* wrapper = + TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); + wrapper->download_tab_helper()->OnSavePage(); + } } diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 382ba9f..fcca9b3 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -45,6 +45,7 @@ #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/download/download_prefs.h" #include "chrome/browser/download/download_shelf.h" +#include "chrome/browser/download/save_package.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/history/top_sites.h" @@ -69,6 +70,7 @@ #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" +#include "chrome/browser/ui/download/download_tab_helper.h" #include "chrome/browser/ui/find_bar/find_bar.h" #include "chrome/browser/ui/login/login_prompt.h" #include "chrome/browser/ui/omnibox/location_bar.h" @@ -1487,7 +1489,9 @@ void TestingAutomationProvider::SavePage(int tab_handle, return; } - nav->tab_contents()->SavePage(file_name, dir_path, save_type); + TabContentsWrapper* wrapper = + TabContentsWrapper::GetCurrentWrapperForContents(nav->tab_contents()); + wrapper->download_tab_helper()->SavePage(file_name, dir_path, save_type); *success = true; } @@ -3217,7 +3221,7 @@ void TestingAutomationProvider::SaveTabContents( int tab_index = 0; FilePath::StringType filename; FilePath::StringType parent_directory; - TabContents* tab_contents = NULL; + TabContentsWrapper* tab_contents = NULL; if (!args->GetInteger("tab_index", &tab_index) || !args->GetString("filename", &filename)) { @@ -3225,7 +3229,7 @@ void TestingAutomationProvider::SaveTabContents( .SendError("tab_index or filename param missing"); return; } else { - tab_contents = browser->GetTabContentsAt(tab_index); + tab_contents = browser->GetTabContentsWrapperAt(tab_index); if (!tab_contents) { AutomationJSONReply(this, reply_message).SendError("no tab at tab_index"); return; @@ -3234,15 +3238,17 @@ void TestingAutomationProvider::SaveTabContents( // We're doing a SAVE_AS_ONLY_HTML so the the directory path isn't // used. Nevertheless, SavePackage requires it be valid. Sigh. parent_directory = FilePath(filename).DirName().value(); - if (!tab_contents->SavePage(FilePath(filename), FilePath(parent_directory), - SavePackage::SAVE_AS_ONLY_HTML)) { + if (!tab_contents->download_tab_helper()->SavePage( + FilePath(filename), + FilePath(parent_directory), + SavePackage::SAVE_AS_ONLY_HTML)) { AutomationJSONReply(this, reply_message).SendError( "Could not initiate SavePage"); return; } // The observer will delete itself when done. - new SavePackageNotificationObserver(tab_contents->save_package(), - this, reply_message); + new SavePackageNotificationObserver( + tab_contents->download_tab_helper()->save_package(), this, reply_message); } // Refer to ImportSettings() in chrome/test/pyautolib/pyauto.py for sample diff --git a/chrome/browser/download/save_file_manager.cc b/chrome/browser/download/save_file_manager.cc index 910aed6..874e7e7 100644 --- a/chrome/browser/download/save_file_manager.cc +++ b/chrome/browser/download/save_file_manager.cc @@ -16,6 +16,8 @@ #include "chrome/browser/download/save_package.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/tab_contents/tab_util.h" +#include "chrome/browser/ui/download/download_tab_helper.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_paths.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" @@ -167,7 +169,7 @@ void SaveFileManager::RemoveSaveFile(int save_id, const GURL& save_url, SavePackage* package) { DCHECK(package); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - // A save page job(SavePackage) can only have one manager, + // A save page job (SavePackage) can only have one manager, // so remove it if it exists. if (save_id == -1) { SavePackage* old_package = UnregisterStartingRequest(save_url, @@ -187,8 +189,11 @@ SavePackage* SaveFileManager::GetSavePackageFromRenderIds( int render_process_id, int render_view_id) { TabContents* contents = tab_util::GetTabContentsByID(render_process_id, render_view_id); - if (contents) - return contents->save_package(); + if (contents) { + TabContentsWrapper* wrapper = + TabContentsWrapper::GetCurrentWrapperForContents(contents); + return wrapper->download_tab_helper()->save_package(); + } return NULL; } diff --git a/chrome/browser/download/save_page_browsertest.cc b/chrome/browser/download/save_page_browsertest.cc index d64db72..aec9381 100644 --- a/chrome/browser/download/save_page_browsertest.cc +++ b/chrome/browser/download/save_page_browsertest.cc @@ -10,6 +10,8 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/net/url_request_mock_http_job.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/download/download_tab_helper.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/url_constants.h" #include "chrome/test/in_process_browser_test.h" @@ -58,13 +60,13 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveHTMLOnly) { FilePath(kTestDir).Append(file_name)); ui_test_utils::NavigateToURL(browser(), url); - TabContents* current_tab = browser()->GetSelectedTabContents(); + TabContentsWrapper* current_tab = browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(current_tab); FilePath full_file_name = save_dir_.path().Append(file_name); FilePath dir = save_dir_.path().AppendASCII("a_files"); - ASSERT_TRUE(current_tab->SavePage(full_file_name, dir, - SavePackage::SAVE_AS_ONLY_HTML)); + ASSERT_TRUE(current_tab->download_tab_helper()->SavePage( + full_file_name, dir, SavePackage::SAVE_AS_ONLY_HTML)); EXPECT_EQ(url, WaitForSavePackageToFinish()); @@ -86,14 +88,14 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveViewSourceHTMLOnly) { FilePath(kTestDir).Append(file_name)); ui_test_utils::NavigateToURL(browser(), view_source_url); - TabContents* current_tab = browser()->GetSelectedTabContents(); + TabContentsWrapper* current_tab = browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(current_tab); FilePath full_file_name = save_dir_.path().Append(file_name); FilePath dir = save_dir_.path().AppendASCII("a_files"); - ASSERT_TRUE(current_tab->SavePage(full_file_name, dir, - SavePackage::SAVE_AS_ONLY_HTML)); + ASSERT_TRUE(current_tab->download_tab_helper()->SavePage( + full_file_name, dir, SavePackage::SAVE_AS_ONLY_HTML)); EXPECT_EQ(actual_page_url, WaitForSavePackageToFinish()); @@ -113,13 +115,13 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveCompleteHTML) { FilePath(kTestDir).Append(file_name)); ui_test_utils::NavigateToURL(browser(), url); - TabContents* current_tab = browser()->GetSelectedTabContents(); + TabContentsWrapper* current_tab = browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(current_tab); FilePath full_file_name = save_dir_.path().Append(file_name); FilePath dir = save_dir_.path().AppendASCII("b_files"); - ASSERT_TRUE(current_tab->SavePage(full_file_name, dir, - SavePackage::SAVE_AS_COMPLETE_HTML)); + ASSERT_TRUE(current_tab->download_tab_helper()->SavePage( + full_file_name, dir, SavePackage::SAVE_AS_COMPLETE_HTML)); EXPECT_EQ(url, WaitForSavePackageToFinish()); @@ -157,11 +159,11 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, FileNameFromPageTitle) { FilePath dir = save_dir_.path().AppendASCII( "Test page for saving page feature_files"); - TabContents* current_tab = browser()->GetSelectedTabContents(); + TabContentsWrapper* current_tab = browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(current_tab); - ASSERT_TRUE(current_tab->SavePage(full_file_name, dir, - SavePackage::SAVE_AS_COMPLETE_HTML)); + ASSERT_TRUE(current_tab->download_tab_helper()->SavePage( + full_file_name, dir, SavePackage::SAVE_AS_COMPLETE_HTML)); EXPECT_EQ(url, WaitForSavePackageToFinish()); diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index fff23a73..fb6566b 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -22,6 +22,7 @@ #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/download/download_manager.h" +#include "chrome/browser/download/save_package.h" #include "chrome/browser/extensions/extension_event_router.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/metrics/user_metrics.h" @@ -36,8 +37,10 @@ #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/spellcheck_host.h" #include "chrome/browser/spellchecker_platform_engine.h" -#include "chrome/browser/translate/translate_prefs.h" #include "chrome/browser/translate/translate_manager.h" +#include "chrome/browser/translate/translate_prefs.h" +#include "chrome/browser/ui/download/download_tab_helper.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/content_restriction.h" @@ -1288,9 +1291,13 @@ void RenderViewContextMenu::ExecuteCommand(int id) { source_tab_contents_->controller().GoForward(); break; - case IDC_SAVE_PAGE: - source_tab_contents_->OnSavePage(); + case IDC_SAVE_PAGE: { + TabContentsWrapper* wrapper = + TabContentsWrapper::GetCurrentWrapperForContents( + source_tab_contents_); + wrapper->download_tab_helper()->OnSavePage(); break; + } case IDC_RELOAD: // Prevent the modal "Resubmit form post" dialog from appearing in the diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 8514f8f..0dcae48 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -40,6 +40,7 @@ #include "chrome/browser/download/download_manager.h" #include "chrome/browser/download/download_shelf.h" #include "chrome/browser/download/download_started_animation.h" +#include "chrome/browser/download/save_package.h" #include "chrome/browser/extensions/crx_installer.h" #include "chrome/browser/extensions/extension_browser_event_router.h" #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h" @@ -74,6 +75,7 @@ #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" +#include "chrome/browser/ui/download/download_tab_helper.h" #include "chrome/browser/ui/find_bar/find_bar.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" #include "chrome/browser/ui/find_bar/find_tab_helper.h" @@ -1611,7 +1613,7 @@ void Browser::SavePage() { TabContents* current_tab = GetSelectedTabContents(); if (current_tab && current_tab->contents_mime_type() == "application/pdf") UserMetrics::RecordAction(UserMetricsAction("PDF.SavePage"), profile_); - GetSelectedTabContents()->OnSavePage(); + GetSelectedTabContentsWrapper()->download_tab_helper()->OnSavePage(); } void Browser::ViewSelectedSource() { diff --git a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm index 2571073..019b300 100644 --- a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm +++ b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm @@ -12,6 +12,7 @@ #include "chrome/browser/download/save_package.h" #include "chrome/browser/sessions/session_id.h" #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" +#include "chrome/browser/ui/download/download_tab_helper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_view_host.h" @@ -240,7 +241,7 @@ // Scripter has not specifed the location at which to save, so we prompt for // it. if (!fileURL) { - tabContents_->tab_contents()->OnSavePage(); + tabContents_->download_tab_helper()->OnSavePage(); return; } @@ -266,9 +267,9 @@ } } - tabContents_->tab_contents()->SavePage(mainFile, - directoryPath, - savePackageType); + tabContents_->download_tab_helper()->SavePage(mainFile, + directoryPath, + savePackageType); } diff --git a/chrome/browser/ui/download/download_tab_helper.cc b/chrome/browser/ui/download/download_tab_helper.cc new file mode 100644 index 0000000..384baf4 --- /dev/null +++ b/chrome/browser/ui/download/download_tab_helper.cc @@ -0,0 +1,51 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/download/download_tab_helper.h" + +#include "chrome/browser/download/download_manager.h" +#include "chrome/browser/profiles/profile.h" +#include "content/browser/tab_contents/tab_contents.h" + +DownloadTabHelper::DownloadTabHelper(TabContents* tab_contents) + : tab_contents_(tab_contents) { + DCHECK(tab_contents_); +} + +DownloadTabHelper::~DownloadTabHelper() { +} + +void DownloadTabHelper::OnSavePage() { + // If we can not save the page, try to download it. + if (!SavePackage::IsSavableContents(tab_contents_->contents_mime_type())) { + DownloadManager* dlm = tab_contents_->profile()->GetDownloadManager(); + const GURL& current_page_url = tab_contents_->GetURL(); + if (dlm && current_page_url.is_valid()) + dlm->DownloadUrl(current_page_url, GURL(), "", tab_contents_); + return; + } + + tab_contents_->Stop(); + + // 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(tab_contents_); + save_package_->GetSaveInfo(); +} + +// Used in automated testing to bypass prompting the user for file names. +// Instead, the names and paths are hard coded rather than running them through +// file name sanitation and extension / mime checking. +bool DownloadTabHelper::SavePage(const FilePath& main_file, + const FilePath& dir_path, + SavePackage::SavePackageType save_type) { + // Stop the page from navigating. + tab_contents_->Stop(); + + save_package_ = + new SavePackage(tab_contents_, save_type, main_file, dir_path); + return save_package_->Init(); +} + diff --git a/chrome/browser/ui/download/download_tab_helper.h b/chrome/browser/ui/download/download_tab_helper.h new file mode 100644 index 0000000..e8fcabf --- /dev/null +++ b/chrome/browser/ui/download/download_tab_helper.h @@ -0,0 +1,40 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ +#define CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ +#pragma once + +#include "base/basictypes.h" +#include "chrome/browser/download/save_package.h" + +// Per-tab download controller. Handles dealing with various per-tab download +// duties. +class DownloadTabHelper { + public: + explicit DownloadTabHelper(TabContents* tab_contents); + virtual ~DownloadTabHelper(); + + // Prepare for saving the current web page to disk. + void OnSavePage(); + + // Save page with the main HTML file path, the directory for saving resources, + // and the save type: HTML only or complete web page. Returns true if the + // saving process has been initiated successfully. + bool SavePage(const FilePath& main_file, const FilePath& dir_path, + SavePackage::SavePackageType save_type); + + // Returns the SavePackage which manages the page saving job. May be NULL. + SavePackage* save_package() const { return save_package_.get(); } + + private: + TabContents* tab_contents_; + + // SavePackage, lazily created. + scoped_refptr<SavePackage> save_package_; + + DISALLOW_COPY_AND_ASSIGN(DownloadTabHelper); +}; + +#endif // CHROME_BROWSER_UI_DOWNLOAD_DOWNLOAD_TAB_HELPER_H_ diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index faeb076..b694bc1 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -23,6 +23,7 @@ #include "chrome/browser/printing/print_preview_message_handler.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" +#include "chrome/browser/ui/download/download_tab_helper.h" #include "chrome/browser/ui/find_bar/find_tab_helper.h" #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" @@ -56,6 +57,7 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents) autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); autofill_manager_.reset(new AutofillManager(contents)); automation_tab_helper_.reset(new AutomationTabHelper(contents)); + download_tab_helper_.reset(new DownloadTabHelper(contents)); extension_tab_helper_.reset(new ExtensionTabHelper(this)); find_tab_helper_.reset(new FindTabHelper(contents)); password_manager_delegate_.reset(new PasswordManagerDelegateImpl(contents)); diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h index 63d9007..314c21d 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h @@ -28,6 +28,7 @@ class AutocompleteHistoryManager; class AutofillManager; class AutomationTabHelper; class DevToolsObserver; +class DownloadTabHelper; class Extension; class ExtensionMessageObserver; class ExtensionTabHelper; @@ -105,6 +106,10 @@ class TabContentsWrapper : public NotificationObserver, return automation_tab_helper_.get(); } + DownloadTabHelper* download_tab_helper() { + return download_tab_helper_.get(); + } + ExtensionTabHelper* extension_tab_helper() { return extension_tab_helper_.get(); } @@ -170,6 +175,7 @@ class TabContentsWrapper : public NotificationObserver, scoped_ptr<AutocompleteHistoryManager> autocomplete_history_manager_; scoped_ptr<AutofillManager> autofill_manager_; scoped_ptr<AutomationTabHelper> automation_tab_helper_; + scoped_ptr<DownloadTabHelper> download_tab_helper_; scoped_ptr<ExtensionTabHelper> extension_tab_helper_; scoped_ptr<FindTabHelper> find_tab_helper_; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 264efc8..0696066 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2488,6 +2488,8 @@ 'browser/ui/crypto_module_password_dialog.h', 'browser/ui/crypto_module_password_dialog_nss.cc', 'browser/ui/crypto_module_password_dialog_openssl.cc', + 'browser/ui/download/download_tab_helper.cc', + 'browser/ui/download/download_tab_helper.h', 'browser/ui/find_bar/find_bar.h', 'browser/ui/find_bar/find_bar_controller.cc', 'browser/ui/find_bar/find_bar_controller.h', diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index ebee41c..110acf5 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -1037,37 +1037,6 @@ void TabContents::WillCloseBlockedContentContainer( PopupNotificationVisibilityChanged(false); } -void TabContents::OnSavePage() { - // If we can not save the page, try to download it. - if (!SavePackage::IsSavableContents(contents_mime_type())) { - DownloadManager* dlm = profile()->GetDownloadManager(); - const GURL& current_page_url = GetURL(); - if (dlm && current_page_url.is_valid()) - dlm->DownloadUrl(current_page_url, GURL(), "", this); - return; - } - - Stop(); - - // 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); - save_package_->GetSaveInfo(); -} - -// Used in automated testing to bypass prompting the user for file names. -// Instead, the names and paths are hard coded rather than running them through -// file name sanitation and extension / mime checking. -bool TabContents::SavePage(const FilePath& main_file, const FilePath& dir_path, - SavePackage::SavePackageType save_type) { - // Stop the page from navigating. - Stop(); - - save_package_ = new SavePackage(this, save_type, main_file, dir_path); - return save_package_->Init(); -} - void TabContents::EmailPageLocation() { std::string title = EscapeQueryParamValue(UTF16ToUTF8(GetTitle()), false); std::string page_url = EscapeQueryParamValue(GetURL().spec(), false); diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index b458293..d1ac0b9 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -15,7 +15,6 @@ #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "base/string16.h" -#include "chrome/browser/download/save_package.h" #include "chrome/browser/favicon_helper.h" #include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/tab_contents/tab_specific_content_settings.h" @@ -146,9 +145,6 @@ class TabContents : public PageNavigator, // Returns the TabContentsSSLHelper, creating it if necessary. TabContentsSSLHelper* GetSSLHelper(); - // Returns the SavePackage which manages the page saving job. May be NULL. - SavePackage* save_package() const { return save_package_.get(); } - // Return the currently active RenderProcessHost and RenderViewHost. Each of // these may change over time. RenderProcessHost* GetRenderProcessHost() const; @@ -485,15 +481,6 @@ class TabContents : public PageNavigator, suppress_javascript_messages_ = suppress_javascript_messages; } - // Prepare for saving the current web page to disk. - void OnSavePage(); - - // Save page with the main HTML file path, the directory for saving resources, - // and the save type: HTML only or complete web page. Returns true if the - // saving process has been initiated successfully. - bool SavePage(const FilePath& main_file, const FilePath& dir_path, - SavePackage::SavePackageType save_type); - // Tells the user's email client to open a compose window containing the // current page's URL. void EmailPageLocation(); @@ -962,9 +949,6 @@ class TabContents : public PageNavigator, // Registers and unregisters for pref notifications. PrefChangeRegistrar pref_change_registrar_; - // SavePackage, lazily created. - scoped_refptr<SavePackage> save_package_; - // Handles plugin messages. scoped_ptr<PluginObserver> plugin_observer_; |