diff options
Diffstat (limited to 'chrome')
30 files changed, 98 insertions, 163 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 3a0f040..139f20d 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -61,7 +61,6 @@ include_rules = [ "+content/browser/download/mock_download_file.h", "+content/browser/download/mock_download_item.h", "+content/browser/download/mock_download_manager.h", - "+content/browser/download/save_package.h", "+content/browser/file_system/browser_file_system_helper.h", "+content/browser/find_pasteboard.h", "+content/browser/font_list_async.h", diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 06d1ec5..be09899 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -78,7 +78,6 @@ #include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" -#include "content/browser/download/save_package.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/ssl/ssl_manager.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 223014d..7325a5e 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -74,7 +74,6 @@ #include "chrome/common/chrome_view_type.h" #include "chrome/common/content_settings_types.h" #include "chrome/common/extensions/extension.h" -#include "content/browser/download/save_package.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/notification_service.h" diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index e10c260..a417f6c 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -1733,10 +1733,10 @@ void TestingAutomationProvider::SavePage(int tab_handle, const FilePath& dir_path, int type, bool* success) { - SavePackage::SavePackageType save_type = - static_cast<SavePackage::SavePackageType>(type); - if (save_type < SavePackage::SAVE_AS_ONLY_HTML || - save_type > SavePackage::SAVE_AS_COMPLETE_HTML) { + content::SavePageType save_type = + static_cast<content::SavePageType>(type); + if (save_type < content::SAVE_PAGE_TYPE_AS_ONLY_HTML || + save_type > content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML) { *success = false; return; } @@ -3753,7 +3753,7 @@ void TestingAutomationProvider::SaveTabContents( if (!web_contents->SavePage( FilePath(filename), FilePath(parent_directory), - SavePackage::SAVE_AS_ONLY_HTML)) { + content::SAVE_PAGE_TYPE_AS_ONLY_HTML)) { AutomationJSONReply(this, reply_message).SendError( "Could not initiate SavePage"); return; diff --git a/chrome/browser/browser_encoding_uitest.cc b/chrome/browser/browser_encoding_uitest.cc index 93bb37e..fd9e362 100644 --- a/chrome/browser/browser_encoding_uitest.cc +++ b/chrome/browser/browser_encoding_uitest.cc @@ -11,7 +11,6 @@ #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/base/ui_test_utils.h" #include "chrome/test/ui/ui_test.h" -#include "content/browser/download/save_package.h" #include "content/browser/net/url_request_mock_http_job.h" static const FilePath::CharType* kTestDir = FILE_PATH_LITERAL("encoding_tests"); @@ -152,7 +151,7 @@ TEST_F(BrowserEncodingTest, FLAKY_TestOverrideEncoding) { // name to save sub resources in it. Although this test file does not have // sub resources, but the directory name is still required. EXPECT_TRUE(tab_proxy->SavePage(full_file_name, temp_sub_resource_dir_, - SavePackage::SAVE_AS_COMPLETE_HTML)); + content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML)); scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); @@ -297,7 +296,7 @@ TEST_F(BrowserEncodingTest, MAYBE_TestEncodingAutoDetect) { expected_result_file_name = expected_result_file_name.AppendASCII( kTestDatas[i].expected_result); EXPECT_TRUE(tab->SavePage(full_saved_file_name, temp_sub_resource_dir_, - SavePackage::SAVE_AS_COMPLETE_HTML)); + content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML)); EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); CheckFile(full_saved_file_name, expected_result_file_name, true); } diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc index 74dfe8d..f882957 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc @@ -12,6 +12,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" +#include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/web_contents.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc index 695aeaf..e430200 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.cc +++ b/chrome/browser/download/chrome_download_manager_delegate.cc @@ -303,13 +303,15 @@ void ChromeDownloadManagerDelegate::GetSaveDir(WebContents* web_contents, } void ChromeDownloadManagerDelegate::ChooseSavePath( - const base::WeakPtr<SavePackage>& save_package, + WebContents* web_contents, const FilePath& suggested_path, - bool can_save_as_complete) { + const FilePath::StringType& default_extension, + bool can_save_as_complete, + content::SaveFilePathPickedCallback callback) { // Deletes itself. new SavePackageFilePicker( - save_package, suggested_path, can_save_as_complete, - download_prefs_.get()); + web_contents, suggested_path, default_extension, can_save_as_complete, + download_prefs_.get(), callback); } void ChromeDownloadManagerDelegate::DownloadProgressUpdated() { diff --git a/chrome/browser/download/chrome_download_manager_delegate.h b/chrome/browser/download/chrome_download_manager_delegate.h index b8f0ff10..b04282e 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.h +++ b/chrome/browser/download/chrome_download_manager_delegate.h @@ -81,9 +81,12 @@ class ChromeDownloadManagerDelegate virtual void GetSaveDir(content::WebContents* web_contents, FilePath* website_save_dir, FilePath* download_save_dir) OVERRIDE; - virtual void ChooseSavePath(const base::WeakPtr<SavePackage>& save_package, - const FilePath& suggested_path, - bool can_save_as_complete) OVERRIDE; + virtual void ChooseSavePath( + content::WebContents* web_contents, + const FilePath& suggested_path, + const FilePath::StringType& default_extension, + bool can_save_as_complete, + content::SaveFilePathPickedCallback callback) OVERRIDE; virtual void DownloadProgressUpdated() OVERRIDE; DownloadPrefs* download_prefs() { return download_prefs_.get(); } diff --git a/chrome/browser/download/download_file_picker.cc b/chrome/browser/download/download_file_picker.cc index 22d6365..2451ce6 100644 --- a/chrome/browser/download/download_file_picker.cc +++ b/chrome/browser/download/download_file_picker.cc @@ -7,7 +7,6 @@ #include "chrome/browser/download/download_prefs.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/profiles/profile.h" -#include "content/browser/download/save_package.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/download/download_item_model.cc b/chrome/browser/download/download_item_model.cc index c9e2a0f..feb0c0b 100644 --- a/chrome/browser/download/download_item_model.cc +++ b/chrome/browser/download/download_item_model.cc @@ -10,7 +10,6 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/download/chrome_download_manager_delegate.h" #include "chrome/common/time_format.h" -#include "content/browser/download/save_package.h" #include "content/public/browser/download_item.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -110,48 +109,3 @@ string16 DownloadItemModel::GetStatusText() { return status_text; } - -// ----------------------------------------------------------------------------- -// SavePageModel - -SavePageModel::SavePageModel(SavePackage* save, DownloadItem* download) - : BaseDownloadItemModel(download), - save_(save) { -} - -void SavePageModel::CancelTask() { - save_->Cancel(true); -} - -string16 SavePageModel::GetStatusText() { - int64 size = download_->GetReceivedBytes(); - int64 total_size = download_->GetTotalBytes(); - - string16 status_text; - switch (download_->GetState()) { - case DownloadItem::IN_PROGRESS: - status_text = l10n_util::GetStringFUTF16( - IDS_SAVE_PAGE_PROGRESS, - base::FormatNumber(size), - base::FormatNumber(total_size)); - break; - case DownloadItem::COMPLETE: - status_text = l10n_util::GetStringUTF16(IDS_SAVE_PAGE_STATUS_COMPLETED); - break; - case DownloadItem::CANCELLED: - status_text = l10n_util::GetStringUTF16(IDS_SAVE_PAGE_STATUS_CANCELED); - break; - case DownloadItem::REMOVING: - break; - case DownloadItem::INTERRUPTED: - status_text = l10n_util::GetStringFUTF16( - IDS_SAVE_PAGE_STATUS_INTERRUPTED, - base::FormatNumber(size), - base::FormatNumber(total_size)); - break; - default: - NOTREACHED(); - } - - return status_text; -} diff --git a/chrome/browser/download/download_item_model.h b/chrome/browser/download/download_item_model.h index a658636..db81467 100644 --- a/chrome/browser/download/download_item_model.h +++ b/chrome/browser/download/download_item_model.h @@ -56,25 +56,4 @@ class DownloadItemModel : public BaseDownloadItemModel { DISALLOW_COPY_AND_ASSIGN(DownloadItemModel); }; -// This class is a model class for DownloadItemView. It provides cancel -// functionality for saving page, and also the text for displaying saving -// status. -class SavePageModel : public BaseDownloadItemModel { - public: - SavePageModel(SavePackage* save, content::DownloadItem* download); - virtual ~SavePageModel() { } - - // Cancel the page saving. - virtual void CancelTask() OVERRIDE; - - // Get page saving status text. - virtual string16 GetStatusText() OVERRIDE; - - private: - // Saving page management. - SavePackage* save_; - - DISALLOW_COPY_AND_ASSIGN(SavePageModel); -}; - #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ diff --git a/chrome/browser/download/download_prefs.cc b/chrome/browser/download/download_prefs.cc index 0c0a613..728cf16 100644 --- a/chrome/browser/download/download_prefs.cc +++ b/chrome/browser/download/download_prefs.cc @@ -20,9 +20,9 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" -#include "content/browser/download/save_package.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/download_manager.h" +#include "content/public/browser/save_page_type.h" using content::BrowserThread; using content::DownloadManager; @@ -67,7 +67,7 @@ void DownloadPrefs::RegisterUserPrefs(PrefService* prefs) { false, PrefService::UNSYNCABLE_PREF); prefs->RegisterIntegerPref(prefs::kSaveFileType, - SavePackage::SAVE_AS_COMPLETE_HTML, + content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, PrefService::UNSYNCABLE_PREF); // The default download path is userprofile\download. diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index 737f30a..857c3a4 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -40,6 +40,7 @@ #include "content/public/browser/download_file.h" #include "content/public/browser/download_item.h" #include "content/public/browser/download_manager.h" +#include "content/public/common/url_constants.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "grit/theme_resources.h" @@ -599,4 +600,13 @@ FilePath GetCrDownloadPath(const FilePath& suggested_path) { suggested_path, FILE_PATH_LITERAL(".crdownload")); } +bool IsSavableURL(const GURL& url) { + for (int i = 0; chrome::GetSavableSchemes()[i] != NULL; ++i) { + if (url.SchemeIs(chrome::GetSavableSchemes()[i])) { + return true; + } + } + return false; +} + } // namespace download_util diff --git a/chrome/browser/download/download_util.h b/chrome/browser/download/download_util.h index c459ce6..fcfa401 100644 --- a/chrome/browser/download/download_util.h +++ b/chrome/browser/download/download_util.h @@ -20,6 +20,8 @@ #include "ui/views/view.h" #endif +class GURL; + namespace base { class DictionaryValue; } @@ -161,6 +163,9 @@ int GetUniquePathNumberWithCrDownload(const FilePath& path); // Returns a .crdownload intermediate path for the |suggested_path|. FilePath GetCrDownloadPath(const FilePath& suggested_path); +// Check whether we can do the saving page operation for the specified URL. +bool IsSavableURL(const GURL& url); + } // namespace download_util #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ diff --git a/chrome/browser/download/save_package_file_picker.cc b/chrome/browser/download/save_package_file_picker.cc index 8cec092..1249273 100644 --- a/chrome/browser/download/save_package_file_picker.cc +++ b/chrome/browser/download/save_package_file_picker.cc @@ -11,12 +11,15 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" -#include "content/browser/download/save_package.h" #include "content/public/browser/download_manager.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/save_page_type.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +using content::RenderProcessHost; +using content::SavePageType; using content::WebContents; namespace { @@ -25,14 +28,14 @@ namespace { // exists only for testing. bool g_should_prompt_for_filename = true; -// Used for mapping between SavePackageType constants and the indexes above. -const SavePackage::SavePackageType kIndexToSaveType[] = { - SavePackage::SAVE_TYPE_UNKNOWN, - SavePackage::SAVE_AS_ONLY_HTML, - SavePackage::SAVE_AS_COMPLETE_HTML, +// Used for mapping between SavePageType constants and the indexes above. +const SavePageType kIndexToSaveType[] = { + content::SAVE_PAGE_TYPE_UNKNOWN, + content::SAVE_PAGE_TYPE_AS_ONLY_HTML, + content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, }; -int SavePackageTypeToIndex(SavePackage::SavePackageType type) { +int SavePackageTypeToIndex(SavePageType type) { for (size_t i = 0; i < arraysize(kIndexToSaveType); ++i) { if (kIndexToSaveType[i] == type) return i; @@ -54,18 +57,18 @@ const int kIndexToIDS[] = { } SavePackageFilePicker::SavePackageFilePicker( - const base::WeakPtr<SavePackage>& save_package, + content::WebContents* web_contents, const FilePath& suggested_path, + const FilePath::StringType& default_extension, bool can_save_as_complete, - DownloadPrefs* download_prefs) - : save_package_(save_package) { + DownloadPrefs* download_prefs, + content::SaveFilePathPickedCallback callback) + : render_process_id_(web_contents->GetRenderProcessHost()->GetID()) { int file_type_index = SavePackageTypeToIndex( - static_cast<SavePackage::SavePackageType>( - download_prefs->save_file_type())); + static_cast<SavePageType>(download_prefs->save_file_type())); DCHECK_NE(-1, file_type_index); SelectFileDialog::FileTypeInfo file_type_info; - FilePath::StringType default_extension; // If the contents can not be saved as complete-HTML, do not show the // file filters. @@ -105,7 +108,6 @@ SavePackageFilePicker::SavePackageFilePicker( file_type_info.extension_description_overrides.push_back( l10n_util::GetStringUTF16(kIndexToIDS[kSelectFileCompleteIndex])); file_type_info.include_all_files = false; - default_extension = SavePackage::kDefaultHtmlExtension; } else { file_type_info.extensions.resize(1); file_type_info.extensions[kSelectFileHtmlOnlyIndex - 1].push_back( @@ -122,7 +124,6 @@ SavePackageFilePicker::SavePackageFilePicker( if (g_should_prompt_for_filename) { select_file_dialog_ = SelectFileDialog::Create(this); - WebContents* web_contents = save_package_->web_contents(); select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, string16(), suggested_path, @@ -135,8 +136,7 @@ SavePackageFilePicker::SavePackageFilePicker( NULL); } else { // Just use 'suggested_path' instead of opening the dialog prompt. - save_package_->OnPathPicked( - suggested_path, kIndexToSaveType[file_type_index]); + callback.Run(suggested_path, kIndexToSaveType[file_type_index]); } } @@ -154,11 +154,11 @@ void SavePackageFilePicker::FileSelected(const FilePath& path, DCHECK(index >= kSelectFileHtmlOnlyIndex && index <= kSelectFileCompleteIndex); - if (save_package_) { - WebContents* web_contents = save_package_->web_contents(); - SavePackage::SavePackageType save_type = kIndexToSaveType[index]; + RenderProcessHost* process = RenderProcessHost::FromID(render_process_id_); + if (process) { + SavePageType save_type = kIndexToSaveType[index]; Profile* profile = - Profile::FromBrowserContext(web_contents->GetBrowserContext()); + Profile::FromBrowserContext(process->GetBrowserContext()); PrefService* prefs = profile->GetPrefs(); if (select_file_dialog_ && select_file_dialog_->HasMultipleFileTypeChoices()) @@ -173,12 +173,12 @@ void SavePackageFilePicker::FileSelected(const FilePath& path, #endif // If user change the default saving directory, we will remember it just // like IE and FireFox. - if (!web_contents->GetBrowserContext()->IsOffTheRecord() && + if (!process->GetBrowserContext()->IsOffTheRecord() && save_file_path.GetValue() != path_string) { save_file_path.SetValue(path_string); } - save_package_->OnPathPicked(path, save_type); + callback_.Run(path, save_type); } delete this; diff --git a/chrome/browser/download/save_package_file_picker.h b/chrome/browser/download/save_package_file_picker.h index 86b74a6..c3b622c 100644 --- a/chrome/browser/download/save_package_file_picker.h +++ b/chrome/browser/download/save_package_file_picker.h @@ -6,21 +6,22 @@ #define CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_ #pragma once +#include "base/callback.h" #include "base/memory/ref_counted.h" -#include "base/memory/weak_ptr.h" #include "chrome/browser/ui/select_file_dialog.h" +#include "content/public/browser/download_manager_delegate.h" class DownloadPrefs; -class FilePath; -class SavePackage; // Handles showing a dialog to the user to ask for the filename to save a page. class SavePackageFilePicker : public SelectFileDialog::Listener { public: - SavePackageFilePicker(const base::WeakPtr<SavePackage>& save_package, + SavePackageFilePicker(content::WebContents* web_contents, const FilePath& suggested_path, + const FilePath::StringType& default_extension, bool can_save_as_complete, - DownloadPrefs* download_prefs); + DownloadPrefs* download_prefs, + content::SaveFilePathPickedCallback callback); virtual ~SavePackageFilePicker(); // Used to disable prompting the user for a directory/filename of the saved @@ -34,7 +35,10 @@ class SavePackageFilePicker : public SelectFileDialog::Listener { void* params) OVERRIDE; virtual void FileSelectionCanceled(void* params) OVERRIDE; - base::WeakPtr<SavePackage> save_package_; + // Used to look up the renderer process for this request to get the context. + int render_process_id_; + + content::SaveFilePathPickedCallback callback_; // For managing select file dialogs. scoped_refptr<SelectFileDialog> select_file_dialog_; diff --git a/chrome/browser/download/save_page_browsertest.cc b/chrome/browser/download/save_page_browsertest.cc index 4985d02..835b2b1 100644 --- a/chrome/browser/download/save_page_browsertest.cc +++ b/chrome/browser/download/save_page_browsertest.cc @@ -201,7 +201,7 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveHTMLOnly) { FilePath full_file_name, dir; GetDestinationPaths("a", &full_file_name, &dir); ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, - SavePackage::SAVE_AS_ONLY_HTML)); + content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); EXPECT_EQ(url, WaitForSavePackageToFinish()); @@ -226,7 +226,7 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveViewSourceHTMLOnly) { FilePath full_file_name, dir; GetDestinationPaths("a", &full_file_name, &dir); ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, - SavePackage::SAVE_AS_ONLY_HTML)); + content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); EXPECT_EQ(actual_page_url, WaitForSavePackageToFinish()); @@ -245,8 +245,8 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveCompleteHTML) { FilePath full_file_name, dir; GetDestinationPaths("b", &full_file_name, &dir); - ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, - SavePackage::SAVE_AS_COMPLETE_HTML)); + ASSERT_TRUE(GetCurrentTab()->SavePage( + full_file_name, dir, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML)); EXPECT_EQ(url, WaitForSavePackageToFinish()); @@ -279,8 +279,8 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, FileNameFromPageTitle) { std::string("Test page for saving page feature") + kAppendedExtension); FilePath dir = save_dir_.path().AppendASCII( "Test page for saving page feature_files"); - ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, - SavePackage::SAVE_AS_COMPLETE_HTML)); + ASSERT_TRUE(GetCurrentTab()->SavePage( + full_file_name, dir, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML)); EXPECT_EQ(url, WaitForSavePackageToFinish()); @@ -306,7 +306,7 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, RemoveFromList) { FilePath full_file_name, dir; GetDestinationPaths("a", &full_file_name, &dir); ASSERT_TRUE(GetCurrentTab()->SavePage(full_file_name, dir, - SavePackage::SAVE_AS_ONLY_HTML)); + content::SAVE_PAGE_TYPE_AS_ONLY_HTML)); EXPECT_EQ(url, WaitForSavePackageToFinish()); @@ -332,25 +332,4 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, RemoveFromList) { full_file_name)); } -// Create a SavePackage and delete it without calling Init. -// SavePackage dtor has various asserts/checks that should not fire. -IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, ImplicitCancel) { - GURL url = NavigateToMockURL("a"); - FilePath full_file_name, dir; - GetDestinationPaths("a", &full_file_name, &dir); - scoped_refptr<SavePackage> save_package(new SavePackage(GetCurrentTab(), - SavePackage::SAVE_AS_ONLY_HTML, full_file_name, dir)); -} - -// Create a SavePackage, call Cancel, then delete it. -// SavePackage dtor has various asserts/checks that should not fire. -IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, ExplicitCancel) { - GURL url = NavigateToMockURL("a"); - FilePath full_file_name, dir; - GetDestinationPaths("a", &full_file_name, &dir); - scoped_refptr<SavePackage> save_package(new SavePackage(GetCurrentTab(), - SavePackage::SAVE_AS_ONLY_HTML, full_file_name, dir)); - save_package->Cancel(true); -} - } // namespace diff --git a/chrome/browser/download/save_page_uitest.cc b/chrome/browser/download/save_page_uitest.cc index eff6ed55..b3885b1 100644 --- a/chrome/browser/download/save_page_uitest.cc +++ b/chrome/browser/download/save_page_uitest.cc @@ -13,7 +13,6 @@ #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/base/ui_test_utils.h" #include "chrome/test/ui/ui_test.h" -#include "content/browser/download/save_package.h" #include "content/browser/net/url_request_mock_http_job.h" #include "net/url_request/url_request_test_util.h" diff --git a/chrome/browser/feedback/feedback_util.cc b/chrome/browser/feedback/feedback_util.cc index 065cc80..1c22d47 100644 --- a/chrome/browser/feedback/feedback_util.cc +++ b/chrome/browser/feedback/feedback_util.cc @@ -23,6 +23,7 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" +#include "content/public/browser/navigation_controller.h" #include "content/public/browser/web_contents.h" #include "content/public/common/url_fetcher.h" #include "content/public/common/url_fetcher_delegate.h" diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index df2d39c..727bb99 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -20,6 +20,7 @@ #include "content/browser/renderer_host/backing_store_manager.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host_delegate.h" diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index f6f1fc2..2fd71bb 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -23,6 +23,7 @@ #include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/download/download_service.h" #include "chrome/browser/download/download_service_factory.h" +#include "chrome/browser/download/download_util.h" #include "chrome/browser/extensions/extension_event_router.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_service.h" @@ -61,7 +62,6 @@ #include "chrome/common/url_constants.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/download/download_stats.h" -#include "content/browser/download/save_package.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/browser/speech/speech_input_preferences.h" @@ -1237,7 +1237,7 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { // different (like having "view-source:" on the front). NavigationEntry* active_entry = source_web_contents_->GetController().GetActiveEntry(); - return SavePackage::IsSavableURL( + return download_util::IsSavableURL( (active_entry) ? active_entry->GetURL() : GURL()); } diff --git a/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc b/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc index 6dae82f..9bc2b9f 100644 --- a/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc +++ b/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc @@ -12,6 +12,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" +#include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/web_contents.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 3080871..1011ffb 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -46,6 +46,7 @@ #include "chrome/browser/download/download_service.h" #include "chrome/browser/download/download_service_factory.h" #include "chrome/browser/download/download_started_animation.h" +#include "chrome/browser/download/download_util.h" #include "chrome/browser/extensions/crx_installer.h" #include "chrome/browser/extensions/default_apps_trial.h" #include "chrome/browser/extensions/extension_browser_event_router.h" @@ -145,7 +146,6 @@ #include "chrome/common/web_apps.h" #include "content/browser/browser_url_handler.h" #include "content/browser/child_process_security_policy.h" -#include "content/browser/download/save_package.h" #include "content/browser/host_zoom_map.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/site_instance.h" @@ -4732,8 +4732,7 @@ void Browser::UpdateCommandsForTabState() { bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()) || current_tab->ShowingInterstitialPage(); command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, - !is_chrome_internal && SavePackage::IsSavableContents( - current_tab->GetContentsMimeType())); + !is_chrome_internal && current_tab->IsSavable()); // Show various bits of UI // TODO(pinkerton): Disable app-mode in the model until we implement it @@ -5405,7 +5404,7 @@ int Browser::GetContentRestrictionsForSelectedTab() { NavigationEntry* active_entry = current_tab->GetController().GetActiveEntry(); // See comment in UpdateCommandsForTabState about why we call url(). - if (!SavePackage::IsSavableURL( + if (!download_util::IsSavableURL( active_entry ? active_entry->GetURL() : GURL()) || current_tab->ShowingInterstitialPage()) content_restrictions |= content::CONTENT_RESTRICTION_SAVE; diff --git a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm index 9b64abc..8aef217 100644 --- a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm +++ b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm @@ -18,10 +18,10 @@ #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/url_constants.h" -#include "content/browser/download/save_package.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" +#include "content/public/browser/save_page_type.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" #include "googleurl/src/gurl.h" @@ -369,22 +369,19 @@ static NSAppleEventDescriptor* valueToDescriptor(Value* value) { NSString* saveType = [dictionary objectForKey:@"FileType"]; - SavePackage::SavePackageType savePackageType = - SavePackage::SAVE_AS_COMPLETE_HTML; + content::SavePageType savePageType = content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML; if (saveType) { if ([saveType isEqualToString:@"only html"]) { - savePackageType = SavePackage::SAVE_AS_ONLY_HTML; + savePageType = content::SAVE_PAGE_TYPE_AS_ONLY_HTML; } else if ([saveType isEqualToString:@"complete html"]) { - savePackageType = SavePackage::SAVE_AS_COMPLETE_HTML; + savePageType = content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML; } else { AppleScript::SetError(AppleScript::errInvalidSaveType); return; } } - tabContents_->web_contents()->SavePage(mainFile, - directoryPath, - savePackageType); + tabContents_->web_contents()->SavePage(mainFile, directoryPath, savePageType); } - (void)handlesCloseScriptCommand:(NSScriptCommand*)command { diff --git a/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm b/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm index 2e08505..7ccbab6 100644 --- a/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm +++ b/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm @@ -7,6 +7,7 @@ #include "base/sys_string_conversions.h" #import "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h" #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" +#include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc b/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc index f6497f5..5850023 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc @@ -11,6 +11,7 @@ #include "base/bind.h" #include "base/file_path.h" #include "base/message_loop.h" +#include "base/pickle.h" #include "base/threading/platform_thread.h" #include "base/threading/thread.h" #include "base/utf_string_conversions.h" diff --git a/chrome/browser/ui/webui/options/certificate_manager_handler.cc b/chrome/browser/ui/webui/options/certificate_manager_handler.cc index ac58c40..e69d279 100644 --- a/chrome/browser/ui/webui/options/certificate_manager_handler.cc +++ b/chrome/browser/ui/webui/options/certificate_manager_handler.cc @@ -20,6 +20,7 @@ #include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "net/base/crypto_module.h" +#include "net/base/net_errors.h" #include "net/base/x509_certificate.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util_collator.h" diff --git a/chrome/browser/ui/webui/options2/certificate_manager_handler2.cc b/chrome/browser/ui/webui/options2/certificate_manager_handler2.cc index 5e6e836..9e95d9d 100644 --- a/chrome/browser/ui/webui/options2/certificate_manager_handler2.cc +++ b/chrome/browser/ui/webui/options2/certificate_manager_handler2.cc @@ -20,6 +20,7 @@ #include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" #include "net/base/crypto_module.h" +#include "net/base/net_errors.h" #include "net/base/x509_certificate.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util_collator.h" diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index d15825f..b3a35ba 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -630,7 +630,7 @@ bool TabProxy::PrintAsync() { bool TabProxy::SavePage(const FilePath& file_name, const FilePath& dir_path, - SavePackage::SavePackageType type) { + content::SavePageType type) { if (!is_valid()) return false; diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index d86f76d..336d6d8 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -22,13 +22,14 @@ #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 "content/browser/download/save_package.h" +#include "content/public/browser/save_page_type.h" #include "content/public/common/page_type.h" #include "content/public/common/security_style.h" #include "net/base/cert_status_flags.h" #include "webkit/glue/window_open_disposition.h" class BrowserProxy; +class FilePath; class GURL; namespace IPC { class Message; @@ -305,7 +306,7 @@ class TabProxy : public AutomationResourceProxy, // |dir_path| is the directory for saving resource files. |type| indicates // which type we're saving as: HTML only or the complete web page. bool SavePage(const FilePath& file_name, const FilePath& dir_path, - SavePackage::SavePackageType type) WARN_UNUSED_RESULT; + content::SavePageType type) WARN_UNUSED_RESULT; // Retrieves the number of info-bars currently showing in |count|. bool GetInfoBarCount(size_t* count) WARN_UNUSED_RESULT; |