| OLD | NEW |
| 1 // Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/download_file_interface.h" | |
| 10 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 11 #include "base/linked_ptr.h" | 10 #include "base/linked_ptr.h" |
| 12 #include "chrome/browser/download/download_file.h" | 11 #include "chrome/browser/download/download_file.h" |
| 13 #include "chrome/browser/download/download_item.h" | 12 #include "chrome/browser/download/download_item.h" |
| 14 #include "chrome/browser/download/download_manager.h" | 13 #include "chrome/browser/download/download_manager.h" |
| 15 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "ui/base/dragdrop/download_file_interface.h" |
| 16 | 16 |
| 17 class TabContents; | 17 class TabContents; |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 class FileStream; | 20 class FileStream; |
| 21 } | 21 } |
| 22 | 22 |
| 23 class DragDownloadFile : public DownloadFileProvider, | 23 class DragDownloadFile : public ui::DownloadFileProvider, |
| 24 public DownloadManager::Observer, | 24 public DownloadManager::Observer, |
| 25 public DownloadItem::Observer { | 25 public DownloadItem::Observer { |
| 26 public: | 26 public: |
| 27 // On Windows, we need to download into a temporary file. Two threads are | 27 // On Windows, we need to download into a temporary file. Two threads are |
| 28 // involved: background drag-and-drop thread and UI thread. | 28 // involved: background drag-and-drop thread and UI thread. |
| 29 // The first parameter file_name_or_path should contain file name while the | 29 // The first parameter file_name_or_path should contain file name while the |
| 30 // second parameter file_stream should be NULL. | 30 // second parameter file_stream should be NULL. |
| 31 // | 31 // |
| 32 // On MacOSX, we need to download into a file stream that has already been | 32 // On MacOSX, we need to download into a file stream that has already been |
| 33 // created. Only UI thread is involved. | 33 // created. Only UI thread is involved. |
| 34 // The file path and file stream should be provided as the first two | 34 // The file path and file stream should be provided as the first two |
| 35 // parameters. | 35 // parameters. |
| 36 DragDownloadFile(const FilePath& file_name_or_path, | 36 DragDownloadFile(const FilePath& file_name_or_path, |
| 37 linked_ptr<net::FileStream> file_stream, | 37 linked_ptr<net::FileStream> file_stream, |
| 38 const GURL& url, | 38 const GURL& url, |
| 39 const GURL& referrer, | 39 const GURL& referrer, |
| 40 const std::string& referrer_encoding, | 40 const std::string& referrer_encoding, |
| 41 TabContents* tab_contents); | 41 TabContents* tab_contents); |
| 42 | 42 |
| 43 // DownloadFileProvider methods. | 43 // DownloadFileProvider methods. |
| 44 // Called on drag-and-drop thread (Windows). | 44 // Called on drag-and-drop thread (Windows). |
| 45 // Called on UI thread (MacOSX). | 45 // Called on UI thread (MacOSX). |
| 46 virtual bool Start(DownloadFileObserver* observer); | 46 virtual bool Start(ui::DownloadFileObserver* observer); |
| 47 virtual void Stop(); | 47 virtual void Stop(); |
| 48 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
| 49 virtual IStream* GetStream() { return NULL; } | 49 virtual IStream* GetStream() { return NULL; } |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 // DownloadManager::Observer methods. | 52 // DownloadManager::Observer methods. |
| 53 // Called on UI thread. | 53 // Called on UI thread. |
| 54 virtual void ModelChanged(); | 54 virtual void ModelChanged(); |
| 55 | 55 |
| 56 // DownloadItem::Observer methods. | 56 // DownloadItem::Observer methods. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 GURL referrer_; | 89 GURL referrer_; |
| 90 std::string referrer_encoding_; | 90 std::string referrer_encoding_; |
| 91 TabContents* tab_contents_; | 91 TabContents* tab_contents_; |
| 92 MessageLoop* drag_message_loop_; | 92 MessageLoop* drag_message_loop_; |
| 93 FilePath temp_dir_path_; | 93 FilePath temp_dir_path_; |
| 94 | 94 |
| 95 // Accessed on drag-and-drop thread (Windows). | 95 // Accessed on drag-and-drop thread (Windows). |
| 96 // Accessed on UI thread (MacOSX). | 96 // Accessed on UI thread (MacOSX). |
| 97 bool is_started_; | 97 bool is_started_; |
| 98 bool is_successful_; | 98 bool is_successful_; |
| 99 scoped_refptr<DownloadFileObserver> observer_; | 99 scoped_refptr<ui::DownloadFileObserver> observer_; |
| 100 | 100 |
| 101 // Accessed on drag-and-drop thread (Windows only). | 101 // Accessed on drag-and-drop thread (Windows only). |
| 102 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
| 103 bool is_running_nested_message_loop_; | 103 bool is_running_nested_message_loop_; |
| 104 #endif | 104 #endif |
| 105 | 105 |
| 106 // Access on UI thread. | 106 // Access on UI thread. |
| 107 DownloadManager* download_manager_; | 107 DownloadManager* download_manager_; |
| 108 bool download_item_observer_added_; | 108 bool download_item_observer_added_; |
| 109 | 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(DragDownloadFile); | 110 DISALLOW_COPY_AND_ASSIGN(DragDownloadFile); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 #endif // CHROME_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_ | 113 #endif // CHROME_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_ |
| OLD | NEW |