Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_EXTENSION_DOWNLOADS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "base/stl_util.h" | |
| 15 #include "base/string16.h" | 16 #include "base/string16.h" |
| 16 #include "chrome/browser/extensions/extension_function.h" | 17 #include "chrome/browser/extensions/extension_function.h" |
| 17 #include "content/browser/download/download_item.h" | 18 #include "content/browser/download/download_item.h" |
| 18 #include "content/browser/download/download_manager.h" | 19 #include "content/browser/download/download_manager.h" |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 class DictionaryValue; | 22 class DictionaryValue; |
| 22 } | 23 } |
| 23 class ResourceDispatcherHost; | 24 class ResourceDispatcherHost; |
| 24 class TabContents; | 25 class TabContents; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.drag"); | 249 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.drag"); |
| 249 | 250 |
| 250 protected: | 251 protected: |
| 251 virtual bool ParseArgs() OVERRIDE; | 252 virtual bool ParseArgs() OVERRIDE; |
| 252 virtual void RunInternal() OVERRIDE; | 253 virtual void RunInternal() OVERRIDE; |
| 253 | 254 |
| 254 private: | 255 private: |
| 255 DISALLOW_COPY_AND_ASSIGN(DownloadsDragFunction); | 256 DISALLOW_COPY_AND_ASSIGN(DownloadsDragFunction); |
| 256 }; | 257 }; |
| 257 | 258 |
| 258 class ExtensionDownloadsEventRouter : public DownloadManager::Observer { | 259 // Observes a single DownloadManager and many DownloadItems and dispatches |
| 260 // onCreated and onErased events. | |
| 261 class ExtensionDownloadsEventRouter : public DownloadManager::Observer, | |
| 262 public DownloadItem::Observer { | |
| 259 public: | 263 public: |
| 260 explicit ExtensionDownloadsEventRouter(Profile* profile); | 264 explicit ExtensionDownloadsEventRouter(Profile* profile); |
| 261 virtual ~ExtensionDownloadsEventRouter(); | 265 virtual ~ExtensionDownloadsEventRouter(); |
| 262 | 266 |
| 263 virtual void ModelChanged() OVERRIDE; | 267 virtual void ModelChanged() OVERRIDE; |
| 264 virtual void ManagerGoingDown() OVERRIDE; | 268 virtual void ManagerGoingDown() OVERRIDE; |
| 269 virtual void OnDownloadUpdated(DownloadItem* download) OVERRIDE; | |
| 270 virtual void OnDownloadOpened(DownloadItem* download) OVERRIDE; | |
| 265 | 271 |
| 266 private: | 272 private: |
| 273 typedef std::set<int> DownloadIdSet; | |
|
Randy Smith (Not in Mondays)
2011/10/13 23:42:59
This doesn't look like it's used in this file--sho
benjhayden
2011/10/17 19:14:00
Done.
| |
| 274 typedef base::hash_map<int, DownloadItem*> ItemMap; | |
| 275 typedef base::hash_map<int, base::DictionaryValue*> ItemJsonMap; | |
| 276 | |
| 267 void DispatchEvent(const char* event_name, base::Value* json_arg); | 277 void DispatchEvent(const char* event_name, base::Value* json_arg); |
| 268 typedef base::hash_map<int, DownloadItem*> ItemMap; | |
| 269 typedef std::set<int> DownloadIdSet; | |
| 270 | 278 |
| 271 Profile* profile_; | 279 Profile* profile_; |
| 272 DownloadManager* manager_; | 280 DownloadManager* manager_; |
| 273 DownloadIdSet downloads_; | 281 ItemMap downloads_; |
| 282 ItemJsonMap item_jsons_; | |
| 283 STLValueDeleter<ItemJsonMap> delete_item_jsons_; | |
| 274 | 284 |
| 275 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); | 285 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); |
| 276 }; | 286 }; |
| 277 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ | 287 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ |
| OLD | NEW |