Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: chrome/browser/plugin_download_helper.h

Issue 8851007: WIP / Do not commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/plugin_database_handler.cc ('k') | chrome/browser/plugin_download_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « chrome/browser/plugin_database_handler.cc ('k') | chrome/browser/plugin_download_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698