| 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_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/download/hyperbolic_download_item_notifier.h" | 16 #include "chrome/browser/download/all_download_item_notifier.h" |
| 17 #include "chrome/browser/extensions/extension_function.h" | 17 #include "chrome/browser/extensions/extension_function.h" |
| 18 #include "content/public/browser/download_id.h" | 18 #include "content/public/browser/download_id.h" |
| 19 #include "content/public/browser/download_item.h" | 19 #include "content/public/browser/download_item.h" |
| 20 #include "content/public/browser/download_manager.h" | 20 #include "content/public/browser/download_manager.h" |
| 21 | 21 |
| 22 class DownloadFileIconExtractor; | 22 class DownloadFileIconExtractor; |
| 23 class DownloadQuery; | 23 class DownloadQuery; |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class ResourceContext; | 26 class ResourceContext; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 void OnIconURLExtracted(const std::string& url); | 207 void OnIconURLExtracted(const std::string& url); |
| 208 FilePath path_; | 208 FilePath path_; |
| 209 int icon_size_; | 209 int icon_size_; |
| 210 scoped_ptr<DownloadFileIconExtractor> icon_extractor_; | 210 scoped_ptr<DownloadFileIconExtractor> icon_extractor_; |
| 211 DISALLOW_COPY_AND_ASSIGN(DownloadsGetFileIconFunction); | 211 DISALLOW_COPY_AND_ASSIGN(DownloadsGetFileIconFunction); |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 // Observes a single DownloadManager and many DownloadItems and dispatches | 214 // Observes a single DownloadManager and many DownloadItems and dispatches |
| 215 // onCreated and onErased events. | 215 // onCreated and onErased events. |
| 216 class ExtensionDownloadsEventRouter | 216 class ExtensionDownloadsEventRouter |
| 217 : public HyperbolicDownloadItemNotifier::Observer { | 217 : public AllDownloadItemNotifier::Observer { |
| 218 public: | 218 public: |
| 219 explicit ExtensionDownloadsEventRouter( | 219 explicit ExtensionDownloadsEventRouter( |
| 220 Profile* profile, content::DownloadManager* manager); | 220 Profile* profile, content::DownloadManager* manager); |
| 221 virtual ~ExtensionDownloadsEventRouter(); | 221 virtual ~ExtensionDownloadsEventRouter(); |
| 222 | 222 |
| 223 // HyperbolicDownloadItemNotifier::Observer interface | 223 // AllDownloadItemNotifier::Observer interface |
| 224 virtual void OnDownloadCreated( | 224 virtual void OnDownloadCreated( |
| 225 content::DownloadManager* manager, | 225 content::DownloadManager* manager, |
| 226 content::DownloadItem* download_item) OVERRIDE; | 226 content::DownloadItem* download_item) OVERRIDE; |
| 227 virtual void OnDownloadUpdated( | 227 virtual void OnDownloadUpdated( |
| 228 content::DownloadManager* manager, | 228 content::DownloadManager* manager, |
| 229 content::DownloadItem* download_item) OVERRIDE; | 229 content::DownloadItem* download_item) OVERRIDE; |
| 230 virtual void OnDownloadRemoved( | 230 virtual void OnDownloadRemoved( |
| 231 content::DownloadManager* manager, | 231 content::DownloadManager* manager, |
| 232 content::DownloadItem* download_item) OVERRIDE; | 232 content::DownloadItem* download_item) OVERRIDE; |
| 233 | 233 |
| 234 // Used for testing. | 234 // Used for testing. |
| 235 struct DownloadsNotificationSource { | 235 struct DownloadsNotificationSource { |
| 236 std::string event_name; | 236 std::string event_name; |
| 237 Profile* profile; | 237 Profile* profile; |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 private: | 240 private: |
| 241 void DispatchEvent(const char* event_name, base::Value* json_arg); | 241 void DispatchEvent(const char* event_name, base::Value* json_arg); |
| 242 | 242 |
| 243 Profile* profile_; | 243 Profile* profile_; |
| 244 HyperbolicDownloadItemNotifier notifier_; | 244 AllDownloadItemNotifier notifier_; |
| 245 | 245 |
| 246 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); | 246 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); |
| 247 }; | 247 }; |
| 248 | 248 |
| 249 #endif // CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ | 249 #endif // CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ |
| OLD | NEW |