diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 17:36:32 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-19 17:36:32 +0000 |
commit | bbc81ba76805f35e7b9ce4fe5bb9355c5011d5ee (patch) | |
tree | c2ef31488922612ca8a4cbe70d31e5e29107bdc0 /chrome/browser/download | |
parent | cbebd4b483315de678d5a24db6feee4bb1477e6a (diff) | |
download | chromium_src-bbc81ba76805f35e7b9ce4fe5bb9355c5011d5ee.zip chromium_src-bbc81ba76805f35e7b9ce4fe5bb9355c5011d5ee.tar.gz chromium_src-bbc81ba76805f35e7b9ce4fe5bb9355c5011d5ee.tar.bz2 |
Move simple download calls to chrome code to use ContentBrowserClient interface.
BUG=82782
Review URL: http://codereview.chromium.org/7670086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97477 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download')
-rw-r--r-- | chrome/browser/download/download_shelf_context_menu.cc | 15 | ||||
-rw-r--r-- | chrome/browser/download/download_shelf_context_menu.h | 5 | ||||
-rw-r--r-- | chrome/browser/download/download_util.cc | 20 | ||||
-rw-r--r-- | chrome/browser/download/download_util.h | 10 |
4 files changed, 18 insertions, 32 deletions
diff --git a/chrome/browser/download/download_shelf_context_menu.cc b/chrome/browser/download/download_shelf_context_menu.cc index 7182e1e..839bc1b 100644 --- a/chrome/browser/download/download_shelf_context_menu.cc +++ b/chrome/browser/download/download_shelf_context_menu.cc @@ -5,12 +5,23 @@ #include "chrome/browser/download/download_shelf_context_menu.h" #include "chrome/browser/download/download_item_model.h" +#include "chrome/browser/download/download_prefs.h" #include "content/browser/download/download_item.h" +#include "content/browser/download/download_manager.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" DownloadShelfContextMenu::~DownloadShelfContextMenu() {} +void DownloadShelfContextMenu::OpenFilesBasedOnExtension(DownloadItem* item, + bool open) { + DownloadPrefs* prefs = item->download_manager()->download_prefs(); + if (open) + prefs->EnableAutoOpenBasedOnExtension(item->GetUserVerifiedFilePath()); + else + prefs->DisableAutoOpenBasedOnExtension(item->GetUserVerifiedFilePath()); +} + DownloadShelfContextMenu::DownloadShelfContextMenu( BaseDownloadItemModel* download_model) : download_model_(download_model), @@ -59,8 +70,8 @@ void DownloadShelfContextMenu::ExecuteCommand(int command_id) { download_item_->OpenDownload(); break; case ALWAYS_OPEN_TYPE: { - download_item_->OpenFilesBasedOnExtension( - !IsCommandIdChecked(ALWAYS_OPEN_TYPE)); + OpenFilesBasedOnExtension(download_item_, + !IsCommandIdChecked(ALWAYS_OPEN_TYPE)); break; } case CANCEL: diff --git a/chrome/browser/download/download_shelf_context_menu.h b/chrome/browser/download/download_shelf_context_menu.h index 3e7c47d..82ee567 100644 --- a/chrome/browser/download/download_shelf_context_menu.h +++ b/chrome/browser/download/download_shelf_context_menu.h @@ -33,6 +33,11 @@ class DownloadShelfContextMenu : public ui::SimpleMenuModel::Delegate { DownloadItem* download_item() const { return download_item_; } void set_download_item(DownloadItem* item) { download_item_ = item; } + // Registers the file's extension for automatic opening upon download + // completion if 'open' is true, or prevents the extension from automatic + // opening if 'open' is false. + static void OpenFilesBasedOnExtension(DownloadItem* item, bool open); + protected: explicit DownloadShelfContextMenu(BaseDownloadItemModel* download_model); diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index 33b77ab..a363d13 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -612,26 +612,6 @@ int GetUniquePathNumber(const FilePath& path) { return -1; } -void DownloadUrl( - const GURL& url, - const GURL& referrer, - const std::string& referrer_charset, - const DownloadSaveInfo& save_info, - ResourceDispatcherHost* rdh, - int render_process_host_id, - int render_view_id, - const content::ResourceContext* context) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - rdh->BeginDownload(url, - referrer, - save_info, - true, // Show "Save as" UI. - render_process_host_id, - render_view_id, - *context); -} - int GetUniquePathNumberWithCrDownload(const FilePath& path) { if (!file_util::PathExists(path) && !file_util::PathExists(GetCrDownloadPath(path))) diff --git a/chrome/browser/download/download_util.h b/chrome/browser/download/download_util.h index fb5886d..8b6b1d4 100644 --- a/chrome/browser/download/download_util.h +++ b/chrome/browser/download/download_util.h @@ -181,16 +181,6 @@ void AppendNumberToPath(FilePath* path, int number); // a number, -1 is returned. int GetUniquePathNumber(const FilePath& path); -// Download the URL. Must be called on the IO thread. -void DownloadUrl(const GURL& url, - const GURL& referrer, - const std::string& referrer_charset, - const DownloadSaveInfo& save_info, - ResourceDispatcherHost* rdh, - int render_process_host_id, - int render_view_id, - const content::ResourceContext* context); - // Same as GetUniquePathNumber, except that it also checks the existence // of its .crdownload intermediate path. // If |path| does not exist, 0 is returned. If it fails to find such |