OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_WIN_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_WIN_H_ |
| 7 |
| 8 #include "app/os_exchange_data.h" |
| 9 #include "base/file_path.h" |
| 10 #include "chrome/browser/download/download_manager.h" |
| 11 #include "googleurl/src/gurl.h" |
| 12 |
| 13 class TabContents; |
| 14 |
| 15 class DragDownloadFile : public OSExchangeData::DownloadFileProvider, |
| 16 public DownloadManager::Observer, |
| 17 public DownloadItem::Observer { |
| 18 public: |
| 19 DragDownloadFile(const GURL& url, |
| 20 const GURL& referrer, |
| 21 const std::string& referrer_encoding, |
| 22 TabContents* tab_contents); |
| 23 |
| 24 // OSExchangeData::DownloadFileProvider methods. |
| 25 // Called on drag-and-drop thread. |
| 26 virtual bool Start(OSExchangeData::DownloadFileObserver* observer, |
| 27 int format); |
| 28 virtual void Stop(); |
| 29 |
| 30 // DownloadManager::Observer methods. |
| 31 // Called on UI thread. |
| 32 virtual void ModelChanged(); |
| 33 virtual void SetDownloads(std::vector<DownloadItem*>& downloads); |
| 34 |
| 35 // DownloadItem::Observer methods. |
| 36 // Called on UI thread. |
| 37 virtual void OnDownloadUpdated(DownloadItem* download); |
| 38 virtual void OnDownloadFileCompleted(DownloadItem* download); |
| 39 virtual void OnDownloadOpened(DownloadItem* download) { } |
| 40 |
| 41 private: |
| 42 // Called on drag-and-drop thread. |
| 43 virtual ~DragDownloadFile(); |
| 44 |
| 45 bool InitiateDownload(); |
| 46 void InitiateDownloadSucceeded( |
| 47 const std::vector<OSExchangeData::DownloadFileInfo*>& downloads); |
| 48 void InitiateDownloadFailed(); |
| 49 void InitiateDownloadCompleted(bool result); |
| 50 |
| 51 void DownloadCancelled(); |
| 52 void DownloadCompleted(const FilePath& file_path); |
| 53 |
| 54 void StartNestedMessageLoop(); |
| 55 void QuitNestedMessageLoopIfNeeded(); |
| 56 |
| 57 // Called on UI thread. |
| 58 void OnInitiateDownload(const FilePath& dir_path); |
| 59 void CheckDownloadStatus(DownloadItem* download); |
| 60 |
| 61 // Initialized on drag-and-drop thread. Can be accessed on either thread. |
| 62 GURL url_; |
| 63 GURL referrer_; |
| 64 std::string referrer_encoding_; |
| 65 TabContents* tab_contents_; |
| 66 MessageLoop* drag_message_loop_; |
| 67 |
| 68 // Accessed on drag-and-drop thread. |
| 69 bool is_started_; |
| 70 bool is_running_nested_message_loop_; |
| 71 bool initiate_download_result_; |
| 72 scoped_refptr<OSExchangeData::DownloadFileObserver> observer_; |
| 73 int format_; |
| 74 FilePath dir_path_; |
| 75 FilePath file_path_; |
| 76 |
| 77 // Access on UI thread. |
| 78 DownloadManager* download_manager_; |
| 79 bool download_item_observer_added_; |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(DragDownloadFile); |
| 82 }; |
| 83 |
| 84 #endif // CHROME_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_WIN_H_ |
OLD | NEW |