OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_COCOA_DOWNLOAD_DOWNLOAD_ITEM_MAC_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_DOWNLOAD_DOWNLOAD_ITEM_MAC_H_ |
6 #define CHROME_BROWSER_UI_COCOA_DOWNLOAD_DOWNLOAD_ITEM_MAC_H_ | 6 #define CHROME_BROWSER_UI_COCOA_DOWNLOAD_DOWNLOAD_ITEM_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/download/download_item_model.h" |
12 #include "chrome/browser/icon_manager.h" | 13 #include "chrome/browser/icon_manager.h" |
13 #include "chrome/common/cancelable_task_tracker.h" | 14 #include "chrome/common/cancelable_task_tracker.h" |
14 #include "content/public/browser/download_item.h" | 15 #include "content/public/browser/download_item.h" |
15 #include "content/public/browser/download_manager.h" | 16 #include "content/public/browser/download_manager.h" |
16 | 17 |
17 @class DownloadItemController; | 18 @class DownloadItemController; |
18 class DownloadItemModel; | |
19 | 19 |
20 namespace gfx{ | 20 namespace gfx{ |
21 class Image; | 21 class Image; |
22 } | 22 } |
23 | 23 |
24 // A class that bridges the visible mac download items to chromium's download | 24 // A class that bridges the visible mac download items to chromium's download |
25 // model. The owning object (DownloadItemController) must explicitly call | 25 // model. The owning object (DownloadItemController) must explicitly call |
26 // |LoadIcon| if it wants to display the icon associated with this download. | 26 // |LoadIcon| if it wants to display the icon associated with this download. |
27 | 27 |
28 class DownloadItemMac : content::DownloadItem::Observer { | 28 class DownloadItemMac : content::DownloadItem::Observer { |
29 public: | 29 public: |
30 // DownloadItemMac takes ownership of |download_model|. | 30 DownloadItemMac(content::DownloadItem* download, |
31 DownloadItemMac(DownloadItemModel* download_model, | |
32 DownloadItemController* controller); | 31 DownloadItemController* controller); |
33 | 32 |
34 // Destructor. | 33 // Destructor. |
35 virtual ~DownloadItemMac(); | 34 virtual ~DownloadItemMac(); |
36 | 35 |
37 // content::DownloadItem::Observer implementation | 36 // content::DownloadItem::Observer implementation |
38 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; | 37 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; |
39 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; | 38 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; |
40 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; | 39 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; |
41 | 40 |
42 DownloadItemModel* download_model() { return download_model_.get(); } | 41 DownloadItemModel* download_model() { return &download_model_; } |
43 | 42 |
44 // Asynchronous icon loading support. | 43 // Asynchronous icon loading support. |
45 void LoadIcon(); | 44 void LoadIcon(); |
46 | 45 |
47 private: | 46 private: |
48 // Callback for asynchronous icon loading. | 47 // Callback for asynchronous icon loading. |
49 void OnExtractIconComplete(gfx::Image* icon_bitmap); | 48 void OnExtractIconComplete(gfx::Image* icon_bitmap); |
50 | 49 |
51 // The download item model we represent. | 50 // The download item model we represent. |
52 scoped_ptr<DownloadItemModel> download_model_; | 51 DownloadItemModel download_model_; |
53 | 52 |
54 // The objective-c controller object. | 53 // The objective-c controller object. |
55 DownloadItemController* item_controller_; // weak, owns us. | 54 DownloadItemController* item_controller_; // weak, owns us. |
56 | 55 |
57 // For canceling an in progress icon request. | 56 // For canceling an in progress icon request. |
58 CancelableTaskTracker cancelable_task_tracker_; | 57 CancelableTaskTracker cancelable_task_tracker_; |
59 | 58 |
60 // Stores the last known path where the file will be saved. | 59 // Stores the last known path where the file will be saved. |
61 FilePath lastFilePath_; | 60 FilePath lastFilePath_; |
62 | 61 |
63 DISALLOW_COPY_AND_ASSIGN(DownloadItemMac); | 62 DISALLOW_COPY_AND_ASSIGN(DownloadItemMac); |
64 }; | 63 }; |
65 | 64 |
66 #endif // CHROME_BROWSER_UI_COCOA_DOWNLOAD_DOWNLOAD_ITEM_MAC_H_ | 65 #endif // CHROME_BROWSER_UI_COCOA_DOWNLOAD_DOWNLOAD_ITEM_MAC_H_ |
OLD | NEW |