Chromium Code Reviews| 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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "base/scoped_observer.h" | |
| 13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "chrome/browser/download/all_download_item_notifier.h" | 16 #include "chrome/browser/download/all_download_item_notifier.h" |
| 16 #include "chrome/browser/download/download_danger_prompt.h" | 17 #include "chrome/browser/download/download_danger_prompt.h" |
| 17 #include "chrome/browser/download/download_path_reservation_tracker.h" | 18 #include "chrome/browser/download/download_path_reservation_tracker.h" |
| 18 #include "chrome/browser/extensions/chrome_extension_function.h" | 19 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 19 #include "chrome/browser/extensions/extension_warning_set.h" | 20 #include "chrome/browser/extensions/extension_warning_set.h" |
| 20 #include "chrome/common/extensions/api/downloads.h" | 21 #include "chrome/common/extensions/api/downloads.h" |
| 21 #include "content/public/browser/download_item.h" | 22 #include "content/public/browser/download_item.h" |
| 22 #include "content/public/browser/download_manager.h" | 23 #include "content/public/browser/download_manager.h" |
| 23 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
| 24 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
|
not at google - send to devlin
2014/04/24 17:43:41
you can delete these #includes
limasdf
2014/04/24 18:27:47
Done. not only here but also others.
| |
| 25 #include "extensions/browser/event_router.h" | 26 #include "extensions/browser/event_router.h" |
| 27 #include "extensions/browser/extension_registry_observer.h" | |
| 26 | 28 |
| 27 class DownloadFileIconExtractor; | 29 class DownloadFileIconExtractor; |
| 28 class DownloadQuery; | 30 class DownloadQuery; |
| 29 | 31 |
| 30 namespace content { | 32 namespace content { |
| 31 class ResourceContext; | 33 class ResourceContext; |
| 32 class ResourceDispatcherHost; | 34 class ResourceDispatcherHost; |
| 33 } | 35 } |
| 34 | 36 |
| 37 namespace extensions { | |
| 38 class ExtensionRegistry; | |
| 39 } | |
| 40 | |
| 35 // Functions in the chrome.downloads namespace facilitate | 41 // Functions in the chrome.downloads namespace facilitate |
| 36 // controlling downloads from extensions. See the full API doc at | 42 // controlling downloads from extensions. See the full API doc at |
| 37 // http://goo.gl/6hO1n | 43 // http://goo.gl/6hO1n |
| 38 | 44 |
| 39 namespace download_extension_errors { | 45 namespace download_extension_errors { |
| 40 | 46 |
| 41 // Errors that can be returned through chrome.runtime.lastError.message. | 47 // Errors that can be returned through chrome.runtime.lastError.message. |
| 42 extern const char kEmptyFile[]; | 48 extern const char kEmptyFile[]; |
| 43 extern const char kFileAlreadyDeleted[]; | 49 extern const char kFileAlreadyDeleted[]; |
| 44 extern const char kFileNotRemoved[]; | 50 extern const char kFileNotRemoved[]; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 | 295 |
| 290 private: | 296 private: |
| 291 void OnIconURLExtracted(const std::string& url); | 297 void OnIconURLExtracted(const std::string& url); |
| 292 base::FilePath path_; | 298 base::FilePath path_; |
| 293 scoped_ptr<DownloadFileIconExtractor> icon_extractor_; | 299 scoped_ptr<DownloadFileIconExtractor> icon_extractor_; |
| 294 DISALLOW_COPY_AND_ASSIGN(DownloadsGetFileIconFunction); | 300 DISALLOW_COPY_AND_ASSIGN(DownloadsGetFileIconFunction); |
| 295 }; | 301 }; |
| 296 | 302 |
| 297 // Observes a single DownloadManager and many DownloadItems and dispatches | 303 // Observes a single DownloadManager and many DownloadItems and dispatches |
| 298 // onCreated and onErased events. | 304 // onCreated and onErased events. |
| 299 class ExtensionDownloadsEventRouter : public extensions::EventRouter::Observer, | 305 class ExtensionDownloadsEventRouter |
| 300 public content::NotificationObserver, | 306 : public extensions::EventRouter::Observer, |
| 301 public AllDownloadItemNotifier::Observer { | 307 public extensions::ExtensionRegistryObserver, |
| 308 public AllDownloadItemNotifier::Observer { | |
| 302 public: | 309 public: |
| 303 typedef base::Callback<void( | 310 typedef base::Callback<void( |
| 304 const base::FilePath& changed_filename, | 311 const base::FilePath& changed_filename, |
| 305 DownloadPathReservationTracker::FilenameConflictAction)> | 312 DownloadPathReservationTracker::FilenameConflictAction)> |
| 306 FilenameChangedCallback; | 313 FilenameChangedCallback; |
| 307 | 314 |
| 308 // The logic for how to handle conflicting filename suggestions from multiple | 315 // The logic for how to handle conflicting filename suggestions from multiple |
| 309 // extensions is split out here for testing. | 316 // extensions is split out here for testing. |
| 310 static void DetermineFilenameInternal( | 317 static void DetermineFilenameInternal( |
| 311 const base::FilePath& filename, | 318 const base::FilePath& filename, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 Profile* profile; | 383 Profile* profile; |
| 377 }; | 384 }; |
| 378 | 385 |
| 379 private: | 386 private: |
| 380 void DispatchEvent( | 387 void DispatchEvent( |
| 381 const std::string& event_name, | 388 const std::string& event_name, |
| 382 bool include_incognito, | 389 bool include_incognito, |
| 383 const extensions::Event::WillDispatchCallback& will_dispatch_callback, | 390 const extensions::Event::WillDispatchCallback& will_dispatch_callback, |
| 384 base::Value* json_arg); | 391 base::Value* json_arg); |
| 385 | 392 |
| 386 // content::NotificationObserver | 393 virtual void OnExtensionUnloaded( |
|
benjhayden
2014/04/24 17:38:48
// extensions::ExtensionRegistryObserver
limasdf
2014/04/24 18:27:47
Done.
| |
| 387 virtual void Observe(int type, | 394 content::BrowserContext* browser_context, |
| 388 const content::NotificationSource& source, | 395 const extensions::Extension* extension, |
| 389 const content::NotificationDetails& details) OVERRIDE; | 396 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 390 | 397 |
| 391 Profile* profile_; | 398 Profile* profile_; |
| 392 AllDownloadItemNotifier notifier_; | 399 AllDownloadItemNotifier notifier_; |
| 393 std::set<const extensions::Extension*> shelf_disabling_extensions_; | 400 std::set<const extensions::Extension*> shelf_disabling_extensions_; |
| 394 content::NotificationRegistrar registrar_; | 401 |
| 402 ScopedObserver<extensions::ExtensionRegistry, | |
| 403 extensions::ExtensionRegistryObserver> | |
| 404 scoped_extension_registry_observer_; | |
|
not at google - send to devlin
2014/04/24 17:43:41
no scoped_
limasdf
2014/04/24 18:27:47
Done. my bad
| |
| 395 | 405 |
| 396 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); | 406 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); |
| 397 }; | 407 }; |
| 398 | 408 |
| 399 #endif // CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ | 409 #endif // CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ |
| OLD | NEW |