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_DOWNLOAD_DOWNLOAD_EXTENSION_API_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_EXTENSION_API_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_EXTENSION_API_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_EXTENSION_API_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // Errors that can be returned through chrome.extension.lastError.message. | 37 // Errors that can be returned through chrome.extension.lastError.message. |
38 extern const char kGenericError[]; | 38 extern const char kGenericError[]; |
39 extern const char kIconNotFoundError[]; | 39 extern const char kIconNotFoundError[]; |
40 extern const char kInvalidDangerTypeError[]; | 40 extern const char kInvalidDangerTypeError[]; |
41 extern const char kInvalidFilterError[]; | 41 extern const char kInvalidFilterError[]; |
42 extern const char kInvalidOperationError[]; | 42 extern const char kInvalidOperationError[]; |
43 extern const char kInvalidOrderByError[]; | 43 extern const char kInvalidOrderByError[]; |
44 extern const char kInvalidQueryLimit[]; | 44 extern const char kInvalidQueryLimit[]; |
45 extern const char kInvalidStateError[]; | 45 extern const char kInvalidStateError[]; |
46 extern const char kInvalidUrlError[]; | 46 extern const char kInvalidURLError[]; |
47 extern const char kNotImplementedError[]; | 47 extern const char kNotImplementedError[]; |
48 | 48 |
49 } // namespace download_extension_errors | 49 } // namespace download_extension_errors |
50 | 50 |
51 class DownloadsFunctionInterface { | 51 class DownloadsFunctionInterface { |
52 public: | 52 public: |
53 enum DownloadsFunctionName { | 53 enum DownloadsFunctionName { |
54 DOWNLOADS_FUNCTION_DOWNLOAD = 0, | 54 DOWNLOADS_FUNCTION_DOWNLOAD = 0, |
55 DOWNLOADS_FUNCTION_SEARCH = 1, | 55 DOWNLOADS_FUNCTION_SEARCH = 1, |
56 DOWNLOADS_FUNCTION_PAUSE = 2, | 56 DOWNLOADS_FUNCTION_PAUSE = 2, |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 public content::DownloadItem::Observer { | 350 public content::DownloadItem::Observer { |
351 public: | 351 public: |
352 explicit ExtensionDownloadsEventRouter(Profile* profile); | 352 explicit ExtensionDownloadsEventRouter(Profile* profile); |
353 virtual ~ExtensionDownloadsEventRouter(); | 353 virtual ~ExtensionDownloadsEventRouter(); |
354 | 354 |
355 virtual void ModelChanged(content::DownloadManager* manager) OVERRIDE; | 355 virtual void ModelChanged(content::DownloadManager* manager) OVERRIDE; |
356 virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE; | 356 virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE; |
357 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; | 357 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; |
358 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; | 358 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; |
359 | 359 |
| 360 // Used for testing. |
| 361 struct DownloadsNotificationSource { |
| 362 std::string event_name; |
| 363 Profile* profile; |
| 364 }; |
| 365 |
360 private: | 366 private: |
361 struct OnChangedStat { | 367 struct OnChangedStat { |
362 OnChangedStat(); | 368 OnChangedStat(); |
363 ~OnChangedStat(); | 369 ~OnChangedStat(); |
364 int fires; | 370 int fires; |
365 int total; | 371 int total; |
366 }; | 372 }; |
367 | 373 |
368 typedef std::map<int, content::DownloadItem*> ItemMap; | 374 typedef std::map<int, content::DownloadItem*> ItemMap; |
369 typedef std::map<int, base::DictionaryValue*> ItemJsonMap; | 375 typedef std::map<int, base::DictionaryValue*> ItemJsonMap; |
370 typedef std::map<int, OnChangedStat*> OnChangedStatMap; | 376 typedef std::map<int, OnChangedStat*> OnChangedStatMap; |
371 | 377 |
372 void Init(content::DownloadManager* manager); | 378 void Init(content::DownloadManager* manager); |
373 void DispatchEvent(const char* event_name, base::Value* json_arg); | 379 void DispatchEvent(const char* event_name, base::Value* json_arg); |
374 | 380 |
375 Profile* profile_; | 381 Profile* profile_; |
376 content::DownloadManager* manager_; | 382 content::DownloadManager* manager_; |
377 ItemMap downloads_; | 383 ItemMap downloads_; |
378 ItemJsonMap item_jsons_; | 384 ItemJsonMap item_jsons_; |
379 STLValueDeleter<ItemJsonMap> delete_item_jsons_; | 385 STLValueDeleter<ItemJsonMap> delete_item_jsons_; |
380 OnChangedStatMap on_changed_stats_; | 386 OnChangedStatMap on_changed_stats_; |
381 STLValueDeleter<OnChangedStatMap> delete_on_changed_stats_; | 387 STLValueDeleter<OnChangedStatMap> delete_on_changed_stats_; |
382 | 388 |
383 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); | 389 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); |
384 }; | 390 }; |
385 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_EXTENSION_API_H_ | 391 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_EXTENSION_API_H_ |
OLD | NEW |