Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ |
| 7 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 8 | #include <set> |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 9 | #include <string> |
| 10 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 11 | #include "base/files/file_path.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 12 | #include "base/memory/singleton.h" |
Torne (Richard Coles) | 5e3f23d | 2013-06-11 16:24:11 +0100 | [diff] [blame] | 13 | #include "base/strings/string16.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 14 | #include "base/values.h" |
| 15 | #include "chrome/browser/download/all_download_item_notifier.h" |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 16 | #include "chrome/browser/download/download_danger_prompt.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 17 | #include "chrome/browser/download/download_path_reservation_tracker.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 18 | #include "chrome/browser/extensions/event_router.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 19 | #include "chrome/browser/extensions/extension_function.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 20 | #include "chrome/common/extensions/api/downloads.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 21 | #include "content/public/browser/download_item.h" |
| 22 | #include "content/public/browser/download_manager.h" |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 23 | #include "content/public/browser/notification_observer.h" |
| 24 | #include "content/public/browser/notification_registrar.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 25 | |
| 26 | class DownloadFileIconExtractor; |
| 27 | class DownloadQuery; |
| 28 | |
| 29 | namespace content { |
| 30 | class ResourceContext; |
| 31 | class ResourceDispatcherHost; |
| 32 | } |
| 33 | |
| 34 | // Functions in the chrome.downloads namespace facilitate |
| 35 | // controlling downloads from extensions. See the full API doc at |
| 36 | // http://goo.gl/6hO1n |
| 37 | |
| 38 | namespace download_extension_errors { |
| 39 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 40 | // Errors that can be returned through chrome.runtime.lastError.message. |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 41 | extern const char kEmptyFile[]; |
| 42 | extern const char kFileAlreadyDeleted[]; |
| 43 | extern const char kIconNotFound[]; |
| 44 | extern const char kInvalidDangerType[]; |
| 45 | extern const char kInvalidFilename[]; |
| 46 | extern const char kInvalidFilter[]; |
| 47 | extern const char kInvalidHeader[]; |
| 48 | extern const char kInvalidId[]; |
| 49 | extern const char kInvalidOrderBy[]; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 50 | extern const char kInvalidQueryLimit[]; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 51 | extern const char kInvalidState[]; |
| 52 | extern const char kInvalidURL[]; |
| 53 | extern const char kInvisibleContext[]; |
| 54 | extern const char kNotComplete[]; |
| 55 | extern const char kNotDangerous[]; |
| 56 | extern const char kNotInProgress[]; |
| 57 | extern const char kNotResumable[]; |
| 58 | extern const char kOpenPermission[]; |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 59 | extern const char kShelfDisabled[]; |
| 60 | extern const char kShelfPermission[]; |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 61 | extern const char kTooManyListeners[]; |
| 62 | extern const char kUnexpectedDeterminer[]; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 63 | |
| 64 | } // namespace download_extension_errors |
| 65 | |
| 66 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 67 | class DownloadedByExtension : public base::SupportsUserData::Data { |
| 68 | public: |
| 69 | static DownloadedByExtension* Get(content::DownloadItem* item); |
| 70 | |
| 71 | DownloadedByExtension(content::DownloadItem* item, |
| 72 | const std::string& id, |
| 73 | const std::string& name); |
| 74 | |
| 75 | const std::string& id() const { return id_; } |
| 76 | const std::string& name() const { return name_; } |
| 77 | |
| 78 | private: |
| 79 | static const char kKey[]; |
| 80 | |
| 81 | std::string id_; |
| 82 | std::string name_; |
| 83 | |
| 84 | DISALLOW_COPY_AND_ASSIGN(DownloadedByExtension); |
| 85 | }; |
| 86 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 87 | class DownloadsDownloadFunction : public AsyncExtensionFunction { |
| 88 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 89 | DECLARE_EXTENSION_FUNCTION("downloads.download", DOWNLOADS_DOWNLOAD) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 90 | DownloadsDownloadFunction(); |
| 91 | virtual bool RunImpl() OVERRIDE; |
| 92 | |
| 93 | protected: |
| 94 | virtual ~DownloadsDownloadFunction(); |
| 95 | |
| 96 | private: |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 97 | void OnStarted( |
| 98 | const base::FilePath& creator_suggested_filename, |
| 99 | extensions::api::downloads::FilenameConflictAction |
| 100 | creator_conflict_action, |
| 101 | content::DownloadItem* item, |
| 102 | net::Error error); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 103 | |
| 104 | DISALLOW_COPY_AND_ASSIGN(DownloadsDownloadFunction); |
| 105 | }; |
| 106 | |
| 107 | class DownloadsSearchFunction : public SyncExtensionFunction { |
| 108 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 109 | DECLARE_EXTENSION_FUNCTION("downloads.search", DOWNLOADS_SEARCH) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 110 | DownloadsSearchFunction(); |
| 111 | virtual bool RunImpl() OVERRIDE; |
| 112 | |
| 113 | protected: |
| 114 | virtual ~DownloadsSearchFunction(); |
| 115 | |
| 116 | private: |
| 117 | DISALLOW_COPY_AND_ASSIGN(DownloadsSearchFunction); |
| 118 | }; |
| 119 | |
| 120 | class DownloadsPauseFunction : public SyncExtensionFunction { |
| 121 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 122 | DECLARE_EXTENSION_FUNCTION("downloads.pause", DOWNLOADS_PAUSE) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 123 | DownloadsPauseFunction(); |
| 124 | virtual bool RunImpl() OVERRIDE; |
| 125 | |
| 126 | protected: |
| 127 | virtual ~DownloadsPauseFunction(); |
| 128 | |
| 129 | private: |
| 130 | DISALLOW_COPY_AND_ASSIGN(DownloadsPauseFunction); |
| 131 | }; |
| 132 | |
| 133 | class DownloadsResumeFunction : public SyncExtensionFunction { |
| 134 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 135 | DECLARE_EXTENSION_FUNCTION("downloads.resume", DOWNLOADS_RESUME) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 136 | DownloadsResumeFunction(); |
| 137 | virtual bool RunImpl() OVERRIDE; |
| 138 | |
| 139 | protected: |
| 140 | virtual ~DownloadsResumeFunction(); |
| 141 | |
| 142 | private: |
| 143 | DISALLOW_COPY_AND_ASSIGN(DownloadsResumeFunction); |
| 144 | }; |
| 145 | |
| 146 | class DownloadsCancelFunction : public SyncExtensionFunction { |
| 147 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 148 | DECLARE_EXTENSION_FUNCTION("downloads.cancel", DOWNLOADS_CANCEL) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 149 | DownloadsCancelFunction(); |
| 150 | virtual bool RunImpl() OVERRIDE; |
| 151 | |
| 152 | protected: |
| 153 | virtual ~DownloadsCancelFunction(); |
| 154 | |
| 155 | private: |
| 156 | DISALLOW_COPY_AND_ASSIGN(DownloadsCancelFunction); |
| 157 | }; |
| 158 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 159 | class DownloadsEraseFunction : public SyncExtensionFunction { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 160 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 161 | DECLARE_EXTENSION_FUNCTION("downloads.erase", DOWNLOADS_ERASE) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 162 | DownloadsEraseFunction(); |
| 163 | virtual bool RunImpl() OVERRIDE; |
| 164 | |
| 165 | protected: |
| 166 | virtual ~DownloadsEraseFunction(); |
| 167 | |
| 168 | private: |
| 169 | DISALLOW_COPY_AND_ASSIGN(DownloadsEraseFunction); |
| 170 | }; |
| 171 | |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 172 | class DownloadsRemoveFileFunction : public AsyncExtensionFunction, |
| 173 | public content::DownloadItem::Observer { |
| 174 | public: |
| 175 | DECLARE_EXTENSION_FUNCTION("downloads.removeFile", DOWNLOADS_REMOVEFILE) |
| 176 | DownloadsRemoveFileFunction(); |
| 177 | virtual bool RunImpl() OVERRIDE; |
| 178 | |
| 179 | protected: |
| 180 | virtual ~DownloadsRemoveFileFunction(); |
| 181 | |
| 182 | private: |
| 183 | virtual void OnDownloadUpdated(content::DownloadItem* item) OVERRIDE; |
| 184 | virtual void OnDownloadDestroyed(content::DownloadItem* item) OVERRIDE; |
| 185 | |
| 186 | content::DownloadItem* item_; |
| 187 | |
| 188 | DISALLOW_COPY_AND_ASSIGN(DownloadsRemoveFileFunction); |
| 189 | }; |
| 190 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 191 | class DownloadsAcceptDangerFunction : public AsyncExtensionFunction { |
| 192 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 193 | DECLARE_EXTENSION_FUNCTION("downloads.acceptDanger", DOWNLOADS_ACCEPTDANGER) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 194 | DownloadsAcceptDangerFunction(); |
| 195 | virtual bool RunImpl() OVERRIDE; |
| 196 | |
| 197 | protected: |
| 198 | virtual ~DownloadsAcceptDangerFunction(); |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 199 | void DangerPromptCallback(int download_id, |
| 200 | DownloadDangerPrompt::Action action); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 201 | |
| 202 | private: |
| 203 | DISALLOW_COPY_AND_ASSIGN(DownloadsAcceptDangerFunction); |
| 204 | }; |
| 205 | |
| 206 | class DownloadsShowFunction : public AsyncExtensionFunction { |
| 207 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 208 | DECLARE_EXTENSION_FUNCTION("downloads.show", DOWNLOADS_SHOW) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 209 | DownloadsShowFunction(); |
| 210 | virtual bool RunImpl() OVERRIDE; |
| 211 | |
| 212 | protected: |
| 213 | virtual ~DownloadsShowFunction(); |
| 214 | |
| 215 | private: |
| 216 | DISALLOW_COPY_AND_ASSIGN(DownloadsShowFunction); |
| 217 | }; |
| 218 | |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 219 | class DownloadsShowDefaultFolderFunction : public AsyncExtensionFunction { |
| 220 | public: |
| 221 | DECLARE_EXTENSION_FUNCTION( |
| 222 | "downloads.showDefaultFolder", DOWNLOADS_SHOWDEFAULTFOLDER) |
| 223 | DownloadsShowDefaultFolderFunction(); |
| 224 | virtual bool RunImpl() OVERRIDE; |
| 225 | |
| 226 | protected: |
| 227 | virtual ~DownloadsShowDefaultFolderFunction(); |
| 228 | |
| 229 | private: |
| 230 | DISALLOW_COPY_AND_ASSIGN(DownloadsShowDefaultFolderFunction); |
| 231 | }; |
| 232 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 233 | class DownloadsOpenFunction : public SyncExtensionFunction { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 234 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 235 | DECLARE_EXTENSION_FUNCTION("downloads.open", DOWNLOADS_OPEN) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 236 | DownloadsOpenFunction(); |
| 237 | virtual bool RunImpl() OVERRIDE; |
| 238 | |
| 239 | protected: |
| 240 | virtual ~DownloadsOpenFunction(); |
| 241 | |
| 242 | private: |
| 243 | DISALLOW_COPY_AND_ASSIGN(DownloadsOpenFunction); |
| 244 | }; |
| 245 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 246 | class DownloadsSetShelfEnabledFunction : public SyncExtensionFunction { |
| 247 | public: |
| 248 | DECLARE_EXTENSION_FUNCTION("downloads.setShelfEnabled", |
| 249 | DOWNLOADS_SETSHELFENABLED) |
| 250 | DownloadsSetShelfEnabledFunction(); |
| 251 | virtual bool RunImpl() OVERRIDE; |
| 252 | |
| 253 | protected: |
| 254 | virtual ~DownloadsSetShelfEnabledFunction(); |
| 255 | |
| 256 | private: |
| 257 | DISALLOW_COPY_AND_ASSIGN(DownloadsSetShelfEnabledFunction); |
| 258 | }; |
| 259 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 260 | class DownloadsDragFunction : public AsyncExtensionFunction { |
| 261 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 262 | DECLARE_EXTENSION_FUNCTION("downloads.drag", DOWNLOADS_DRAG) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 263 | DownloadsDragFunction(); |
| 264 | virtual bool RunImpl() OVERRIDE; |
| 265 | |
| 266 | protected: |
| 267 | virtual ~DownloadsDragFunction(); |
| 268 | |
| 269 | private: |
| 270 | DISALLOW_COPY_AND_ASSIGN(DownloadsDragFunction); |
| 271 | }; |
| 272 | |
| 273 | class DownloadsGetFileIconFunction : public AsyncExtensionFunction { |
| 274 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 275 | DECLARE_EXTENSION_FUNCTION("downloads.getFileIcon", DOWNLOADS_GETFILEICON) |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 276 | DownloadsGetFileIconFunction(); |
| 277 | virtual bool RunImpl() OVERRIDE; |
| 278 | void SetIconExtractorForTesting(DownloadFileIconExtractor* extractor); |
| 279 | |
| 280 | protected: |
| 281 | virtual ~DownloadsGetFileIconFunction(); |
| 282 | |
| 283 | private: |
| 284 | void OnIconURLExtracted(const std::string& url); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 285 | base::FilePath path_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 286 | scoped_ptr<DownloadFileIconExtractor> icon_extractor_; |
| 287 | DISALLOW_COPY_AND_ASSIGN(DownloadsGetFileIconFunction); |
| 288 | }; |
| 289 | |
| 290 | // Observes a single DownloadManager and many DownloadItems and dispatches |
| 291 | // onCreated and onErased events. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 292 | class ExtensionDownloadsEventRouter : public extensions::EventRouter::Observer, |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 293 | public content::NotificationObserver, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 294 | public AllDownloadItemNotifier::Observer { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 295 | public: |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 296 | typedef base::Callback<void( |
| 297 | const base::FilePath& changed_filename, |
| 298 | DownloadPathReservationTracker::FilenameConflictAction)> |
| 299 | FilenameChangedCallback; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 300 | |
| 301 | // A downloads.onDeterminingFilename listener has returned. If the extension |
| 302 | // wishes to override the download's filename, then |filename| will be |
| 303 | // non-empty. |filename| will be interpreted as a relative path, appended to |
| 304 | // the default downloads directory. If the extension wishes to overwrite any |
| 305 | // existing files, then |overwrite| will be true. Returns true on success, |
| 306 | // false otherwise. |
| 307 | static bool DetermineFilename( |
| 308 | Profile* profile, |
| 309 | bool include_incognito, |
| 310 | const std::string& ext_id, |
| 311 | int download_id, |
| 312 | const base::FilePath& filename, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 313 | extensions::api::downloads::FilenameConflictAction conflict_action, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 314 | std::string* error); |
| 315 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 316 | explicit ExtensionDownloadsEventRouter( |
| 317 | Profile* profile, content::DownloadManager* manager); |
| 318 | virtual ~ExtensionDownloadsEventRouter(); |
| 319 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 320 | void SetShelfEnabled(const extensions::Extension* extension, bool enabled); |
| 321 | bool IsShelfEnabled() const; |
| 322 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 323 | // Called by ChromeDownloadManagerDelegate during the filename determination |
| 324 | // process, allows extensions to change the item's target filename. If no |
| 325 | // extension wants to change the target filename, then |no_change| will be |
| 326 | // called and the filename determination process will continue as normal. If |
| 327 | // an extension wants to change the target filename, then |change| will be |
| 328 | // called with the new filename and a flag indicating whether the new file |
| 329 | // should overwrite any old files of the same name. |
| 330 | void OnDeterminingFilename( |
| 331 | content::DownloadItem* item, |
| 332 | const base::FilePath& suggested_path, |
| 333 | const base::Closure& no_change, |
| 334 | const FilenameChangedCallback& change); |
| 335 | |
| 336 | // AllDownloadItemNotifier::Observer |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 337 | virtual void OnDownloadCreated( |
| 338 | content::DownloadManager* manager, |
| 339 | content::DownloadItem* download_item) OVERRIDE; |
| 340 | virtual void OnDownloadUpdated( |
| 341 | content::DownloadManager* manager, |
| 342 | content::DownloadItem* download_item) OVERRIDE; |
| 343 | virtual void OnDownloadRemoved( |
| 344 | content::DownloadManager* manager, |
| 345 | content::DownloadItem* download_item) OVERRIDE; |
| 346 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 347 | // extensions::EventRouter::Observer |
| 348 | virtual void OnListenerRemoved( |
| 349 | const extensions::EventListenerInfo& details) OVERRIDE; |
| 350 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 351 | // Used for testing. |
| 352 | struct DownloadsNotificationSource { |
| 353 | std::string event_name; |
| 354 | Profile* profile; |
| 355 | }; |
| 356 | |
| 357 | private: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 358 | void DispatchEvent( |
| 359 | const char* event_name, |
| 360 | bool include_incognito, |
| 361 | const extensions::Event::WillDispatchCallback& will_dispatch_callback, |
| 362 | base::Value* json_arg); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 363 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 364 | // content::NotificationObserver |
| 365 | virtual void Observe(int type, |
| 366 | const content::NotificationSource& source, |
| 367 | const content::NotificationDetails& details) OVERRIDE; |
| 368 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 369 | Profile* profile_; |
| 370 | AllDownloadItemNotifier notifier_; |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 371 | std::set<const extensions::Extension*> shelf_disabling_extensions_; |
| 372 | content::NotificationRegistrar registrar_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 373 | |
| 374 | DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); |
| 375 | }; |
| 376 | |
| 377 | #endif // CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ |