diff options
author | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-28 18:36:09 +0000 |
---|---|---|
committer | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-28 18:36:09 +0000 |
commit | f1d784d6938b8fe8e0d257e41b26341992c2552c (patch) | |
tree | e8a57be7f78ffa26e886c5814d989d0a8da3893d /chrome/browser/extensions/api/downloads/downloads_api.h | |
parent | 3c919d6ac5b262904d6598fc2418d7c0358aad57 (diff) | |
download | chromium_src-f1d784d6938b8fe8e0d257e41b26341992c2552c.zip chromium_src-f1d784d6938b8fe8e0d257e41b26341992c2552c.tar.gz chromium_src-f1d784d6938b8fe8e0d257e41b26341992c2552c.tar.bz2 |
A few minor changes to the chrome.downloads extension API
Reviewers:
jhawkins: webui
Done:
asanka: */download/*
jam: content/public/*
asargent: */extensions/*
Replaced the "Invalid operation" error message with more specific and helpful messages
Add DownloadItem.referrer
Add DownloadItem.estimatedEndTime
Add DownloadItem.canResume
Change DownloadQuery.limit to default to 1000
Change 'conflict_action' to 'conflictAction'.
Change DownloadQuery.orderBy and DownloadQuery.query to arrays of strings
Remove DownloadItem.dangerAccepted in favor of DownloadItem.danger == 'accepted'
Add showDefaultFolder().
Disallow access to packaged_apps.
download() now updates the Download.Sources histogram. http://crbug.com/240322
Document using startedAfter and limit to page through search() results.
DownloadItem.error is now a string enum instead of mysterious numbers.
Add downloads.removeFile(id) and DownloadItem::DeleteFile() so that the file may be deleted separately from the history entry.
Calling open() for dangerous downloads has always been guaranteed to return kInvalidOperation because unaccepted dangerous downloads cannot transition to state='complete', and open() returns kInvalidOperation for incomplete items.
We can wait until after launch to figure out whether there needs to be some mechanism to allow extensions to override the request header blacklist. This seems like an edge case for which we may never receive feature requests.
Staged docs preview: http://basho.cam.corp.google.com:8000/extensions/downloads.html#type-DownloadItem
BUG=240322
R=asanka@chromium.org, asargent@chromium.org, jam@chromium.org
Review URL: https://codereview.chromium.org/16924017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214133 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/downloads/downloads_api.h')
-rw-r--r-- | chrome/browser/extensions/api/downloads/downloads_api.h | 74 |
1 files changed, 61 insertions, 13 deletions
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.h b/chrome/browser/extensions/api/downloads/downloads_api.h index 77b7777..465148c1 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api.h +++ b/chrome/browser/extensions/api/downloads/downloads_api.h @@ -12,6 +12,7 @@ #include "base/strings/string16.h" #include "base/values.h" #include "chrome/browser/download/all_download_item_notifier.h" +#include "chrome/browser/download/download_danger_prompt.h" #include "chrome/browser/download/download_path_reservation_tracker.h" #include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/extension_function.h" @@ -34,18 +35,26 @@ class ResourceDispatcherHost; namespace download_extension_errors { // Errors that can be returned through chrome.runtime.lastError.message. -extern const char kGenericError[]; -extern const char kIconNotFoundError[]; -extern const char kInvalidDangerTypeError[]; -extern const char kInvalidFilenameError[]; -extern const char kInvalidFilterError[]; -extern const char kInvalidOperationError[]; -extern const char kInvalidOrderByError[]; +extern const char kEmptyFile[]; +extern const char kFileAlreadyDeleted[]; +extern const char kIconNotFound[]; +extern const char kInvalidDangerType[]; +extern const char kInvalidFilename[]; +extern const char kInvalidFilter[]; +extern const char kInvalidHeader[]; +extern const char kInvalidId[]; +extern const char kInvalidOrderBy[]; extern const char kInvalidQueryLimit[]; -extern const char kInvalidStateError[]; -extern const char kInvalidURLError[]; -extern const char kNotImplementedError[]; -extern const char kTooManyListenersError[]; +extern const char kInvalidState[]; +extern const char kInvalidURL[]; +extern const char kInvisibleContext[]; +extern const char kNotComplete[]; +extern const char kNotDangerous[]; +extern const char kNotInProgress[]; +extern const char kNotResumable[]; +extern const char kOpenPermission[]; +extern const char kTooManyListeners[]; +extern const char kUnexpectedDeterminer[]; } // namespace download_extension_errors @@ -60,7 +69,12 @@ class DownloadsDownloadFunction : public AsyncExtensionFunction { virtual ~DownloadsDownloadFunction(); private: - void OnStarted(content::DownloadItem* item, net::Error error); + void OnStarted( + const base::FilePath& creator_suggested_filename, + extensions::api::downloads::FilenameConflictAction + creator_conflict_action, + content::DownloadItem* item, + net::Error error); DISALLOW_COPY_AND_ASSIGN(DownloadsDownloadFunction); }; @@ -130,6 +144,25 @@ class DownloadsEraseFunction : public SyncExtensionFunction { DISALLOW_COPY_AND_ASSIGN(DownloadsEraseFunction); }; +class DownloadsRemoveFileFunction : public AsyncExtensionFunction, + public content::DownloadItem::Observer { + public: + DECLARE_EXTENSION_FUNCTION("downloads.removeFile", DOWNLOADS_REMOVEFILE) + DownloadsRemoveFileFunction(); + virtual bool RunImpl() OVERRIDE; + + protected: + virtual ~DownloadsRemoveFileFunction(); + + private: + virtual void OnDownloadUpdated(content::DownloadItem* item) OVERRIDE; + virtual void OnDownloadDestroyed(content::DownloadItem* item) OVERRIDE; + + content::DownloadItem* item_; + + DISALLOW_COPY_AND_ASSIGN(DownloadsRemoveFileFunction); +}; + class DownloadsAcceptDangerFunction : public AsyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION("downloads.acceptDanger", DOWNLOADS_ACCEPTDANGER) @@ -138,7 +171,8 @@ class DownloadsAcceptDangerFunction : public AsyncExtensionFunction { protected: virtual ~DownloadsAcceptDangerFunction(); - void DangerPromptCallback(bool accept, int download_id); + void DangerPromptCallback(int download_id, + DownloadDangerPrompt::Action action); private: DISALLOW_COPY_AND_ASSIGN(DownloadsAcceptDangerFunction); @@ -157,6 +191,20 @@ class DownloadsShowFunction : public AsyncExtensionFunction { DISALLOW_COPY_AND_ASSIGN(DownloadsShowFunction); }; +class DownloadsShowDefaultFolderFunction : public AsyncExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION( + "downloads.showDefaultFolder", DOWNLOADS_SHOWDEFAULTFOLDER) + DownloadsShowDefaultFolderFunction(); + virtual bool RunImpl() OVERRIDE; + + protected: + virtual ~DownloadsShowDefaultFolderFunction(); + + private: + DISALLOW_COPY_AND_ASSIGN(DownloadsShowDefaultFolderFunction); +}; + class DownloadsOpenFunction : public SyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION("downloads.open", DOWNLOADS_OPEN) |