| Index: chrome/browser/plugin_download_helper.h
|
| diff --git a/chrome/browser/plugin_download_helper.h b/chrome/browser/plugin_download_helper.h
|
| index 18d3f8f2fa72eff7e67b2ce1baf2a0d27d6e5be8..604fdc2c1013d84ab11fdf2d3e3d577056b1e793 100644
|
| --- a/chrome/browser/plugin_download_helper.h
|
| +++ b/chrome/browser/plugin_download_helper.h
|
| @@ -6,15 +6,15 @@
|
| #define CHROME_BROWSER_PLUGIN_DOWNLOAD_HELPER_H_
|
| #pragma once
|
|
|
| -#include <string>
|
| -
|
| -#include "build/build_config.h"
|
| +#include "base/callback.h"
|
| #include "base/file_path.h"
|
| -#include "base/message_loop_proxy.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "content/public/common/url_fetcher_delegate.h"
|
| -#include "net/base/file_stream.h"
|
| -#include "net/url_request/url_request.h"
|
| -#include "ui/gfx/native_widget_types.h"
|
| +#include "googleurl/src/gurl.h"
|
| +
|
| +namespace base {
|
| +class MessageLoopProxy;
|
| +}
|
|
|
| namespace net {
|
| class URLRequestContextGetter;
|
| @@ -25,40 +25,33 @@ class URLRequestContextGetter;
|
| // of this class.
|
| class PluginDownloadUrlHelper : public content::URLFetcherDelegate {
|
| public:
|
| - // The delegate receives notification about the status of downloads
|
| - // initiated.
|
| - class DownloadDelegate {
|
| - public:
|
| - virtual ~DownloadDelegate() {}
|
| + typedef base::Callback<void(FilePath)> DownloadFinishedCallback;
|
|
|
| - virtual void OnDownloadCompleted(const FilePath& download_path,
|
| - bool success) {}
|
| - };
|
| + PluginDownloadUrlHelper();
|
| + virtual ~PluginDownloadUrlHelper();
|
|
|
| - PluginDownloadUrlHelper(const std::string& download_url,
|
| - gfx::NativeWindow caller_window,
|
| - PluginDownloadUrlHelper::DownloadDelegate* delegate);
|
| - ~PluginDownloadUrlHelper();
|
| -
|
| - void InitiateDownload(net::URLRequestContextGetter* request_context,
|
| - base::MessageLoopProxy* file_thread_proxy);
|
| + void InitiateDownload(const GURL& download_url,
|
| + net::URLRequestContextGetter* request_context,
|
| + const DownloadFinishedCallback& callback);
|
|
|
| // content::URLFetcherDelegate
|
| - virtual void OnURLFetchComplete(const content::URLFetcher* source);
|
| + virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE;
|
| +
|
| + private:
|
| + // Renames the file (which was downloaded to a temporary file) to the filename
|
| + // of the download URL.
|
| + void RenameDownloadedFile();
|
|
|
| - void OnDownloadCompleted(net::URLRequest* request);
|
| + // Runs the callback and deletes itself.
|
| + void RunCallback();
|
|
|
| - protected:
|
| // The download file request initiated by the plugin.
|
| scoped_ptr<content::URLFetcher> download_file_fetcher_;
|
| - // TODO(port): this comment doesn't describe the situation on Posix.
|
| - // The window handle for sending the WM_COPYDATA notification,
|
| - // indicating that the download completed.
|
| - gfx::NativeWindow download_file_caller_window_;
|
|
|
| - std::string download_url_;
|
| + GURL download_url_;
|
| + FilePath downloaded_file_;
|
|
|
| - PluginDownloadUrlHelper::DownloadDelegate* delegate_;
|
| + DownloadFinishedCallback callback_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(PluginDownloadUrlHelper);
|
| };
|
|
|