OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_DOWNLOAD_REQUEST_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_MANAGER_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_MANAGER_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 PROMPT_BEFORE_DOWNLOAD, | 50 PROMPT_BEFORE_DOWNLOAD, |
51 ALLOW_ALL_DOWNLOADS, | 51 ALLOW_ALL_DOWNLOADS, |
52 DOWNLOADS_NOT_ALLOWED | 52 DOWNLOADS_NOT_ALLOWED |
53 }; | 53 }; |
54 | 54 |
55 // The callback from CanDownloadOnIOThread. This is invoked on the io thread. | 55 // The callback from CanDownloadOnIOThread. This is invoked on the io thread. |
56 class Callback { | 56 class Callback { |
57 public: | 57 public: |
58 virtual void ContinueDownload() = 0; | 58 virtual void ContinueDownload() = 0; |
59 virtual void CancelDownload() = 0; | 59 virtual void CancelDownload() = 0; |
60 protected: | |
61 ~Callback() {} | |
62 }; | 60 }; |
63 | 61 |
64 // TabDownloadState maintains the download state for a particular tab. | 62 // TabDownloadState maintains the download state for a particular tab. |
65 // TabDownloadState installs observers to update the download status | 63 // TabDownloadState installs observers to update the download status |
66 // appropriately. Additionally TabDownloadState prompts the user as necessary. | 64 // appropriately. Additionally TabDownloadState prompts the user as necessary. |
67 // TabDownloadState deletes itself (by invoking | 65 // TabDownloadState deletes itself (by invoking |
68 // DownloadRequestManager::Remove) as necessary. | 66 // DownloadRequestManager::Remove) as necessary. |
69 class TabDownloadState : public NotificationObserver { | 67 class TabDownloadState : public NotificationObserver { |
70 public: | 68 public: |
71 // Creates a new TabDownloadState. |controller| is the controller the | 69 // Creates a new TabDownloadState. |controller| is the controller the |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 void OnUserGesture(TabContents* tab); | 162 void OnUserGesture(TabContents* tab); |
165 | 163 |
166 private: | 164 private: |
167 friend class DownloadRequestManagerTest; | 165 friend class DownloadRequestManagerTest; |
168 friend class TabDownloadState; | 166 friend class TabDownloadState; |
169 | 167 |
170 // For unit tests. If non-null this is used instead of creating a dialog. | 168 // For unit tests. If non-null this is used instead of creating a dialog. |
171 class TestingDelegate { | 169 class TestingDelegate { |
172 public: | 170 public: |
173 virtual bool ShouldAllowDownload() = 0; | 171 virtual bool ShouldAllowDownload() = 0; |
174 protected: | |
175 ~TestingDelegate() {} | |
176 }; | 172 }; |
177 static void SetTestingDelegate(TestingDelegate* delegate); | 173 static void SetTestingDelegate(TestingDelegate* delegate); |
178 | 174 |
179 // Gets the download state for the specified controller. If the | 175 // Gets the download state for the specified controller. If the |
180 // TabDownloadState does not exist and |create| is true, one is created. | 176 // TabDownloadState does not exist and |create| is true, one is created. |
181 // See TabDownloadState's constructor description for details on the two | 177 // See TabDownloadState's constructor description for details on the two |
182 // controllers. | 178 // controllers. |
183 // | 179 // |
184 // The returned TabDownloadState is owned by the DownloadRequestManager and | 180 // The returned TabDownloadState is owned by the DownloadRequestManager and |
185 // deleted when no longer needed (the Remove method is invoked). | 181 // deleted when no longer needed (the Remove method is invoked). |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // the TabDownloadState is removed and deleted (by way of Remove). | 218 // the TabDownloadState is removed and deleted (by way of Remove). |
223 typedef std::map<NavigationController*, TabDownloadState*> StateMap; | 219 typedef std::map<NavigationController*, TabDownloadState*> StateMap; |
224 StateMap state_map_; | 220 StateMap state_map_; |
225 | 221 |
226 static TestingDelegate* delegate_; | 222 static TestingDelegate* delegate_; |
227 | 223 |
228 DISALLOW_COPY_AND_ASSIGN(DownloadRequestManager); | 224 DISALLOW_COPY_AND_ASSIGN(DownloadRequestManager); |
229 }; | 225 }; |
230 | 226 |
231 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_MANAGER_H_ | 227 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_MANAGER_H_ |
OLD | NEW |