Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1036)

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.h

Issue 16924017: A few minor changes to the chrome.downloads extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r212092 Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/download/all_download_item_notifier.h" 14 #include "chrome/browser/download/all_download_item_notifier.h"
15 #include "chrome/browser/download/download_danger_prompt.h"
15 #include "chrome/browser/download/download_path_reservation_tracker.h" 16 #include "chrome/browser/download/download_path_reservation_tracker.h"
16 #include "chrome/browser/extensions/event_router.h" 17 #include "chrome/browser/extensions/event_router.h"
17 #include "chrome/browser/extensions/extension_function.h" 18 #include "chrome/browser/extensions/extension_function.h"
18 #include "chrome/common/extensions/api/downloads.h" 19 #include "chrome/common/extensions/api/downloads.h"
19 #include "content/public/browser/download_item.h" 20 #include "content/public/browser/download_item.h"
20 #include "content/public/browser/download_manager.h" 21 #include "content/public/browser/download_manager.h"
21 22
22 class DownloadFileIconExtractor; 23 class DownloadFileIconExtractor;
23 class DownloadQuery; 24 class DownloadQuery;
24 25
25 namespace content { 26 namespace content {
26 class ResourceContext; 27 class ResourceContext;
27 class ResourceDispatcherHost; 28 class ResourceDispatcherHost;
28 } 29 }
29 30
30 // Functions in the chrome.downloads namespace facilitate 31 // Functions in the chrome.downloads namespace facilitate
31 // controlling downloads from extensions. See the full API doc at 32 // controlling downloads from extensions. See the full API doc at
32 // http://goo.gl/6hO1n 33 // http://goo.gl/6hO1n
33 34
34 namespace download_extension_errors { 35 namespace download_extension_errors {
35 36
36 // Errors that can be returned through chrome.runtime.lastError.message. 37 // Errors that can be returned through chrome.runtime.lastError.message.
37 extern const char kGenericError[]; 38 extern const char kEmptyFile[];
38 extern const char kIconNotFoundError[]; 39 extern const char kFileAlreadyDeleted[];
39 extern const char kInvalidDangerTypeError[]; 40 extern const char kFileIsDirectory[];
40 extern const char kInvalidFilenameError[]; 41 extern const char kIconNotFound[];
41 extern const char kInvalidFilterError[]; 42 extern const char kInvalidDangerType[];
42 extern const char kInvalidOperationError[]; 43 extern const char kInvalidFilename[];
43 extern const char kInvalidOrderByError[]; 44 extern const char kInvalidFilter[];
45 extern const char kInvalidHeader[];
46 extern const char kInvalidId[];
47 extern const char kInvalidOrderBy[];
44 extern const char kInvalidQueryLimit[]; 48 extern const char kInvalidQueryLimit[];
45 extern const char kInvalidStateError[]; 49 extern const char kInvalidState[];
46 extern const char kInvalidURLError[]; 50 extern const char kInvalidURL[];
47 extern const char kNotImplementedError[]; 51 extern const char kInvisibleContext[];
48 extern const char kTooManyListenersError[]; 52 extern const char kNotComplete[];
53 extern const char kNotDangerous[];
54 extern const char kNotImplemented[];
55 extern const char kNotInProgress[];
56 extern const char kNotPermittedURL[];
57 extern const char kTooManyListeners[];
58 extern const char kUnexpectedDeterminer[];
49 59
50 } // namespace download_extension_errors 60 } // namespace download_extension_errors
51 61
52 62
53 class DownloadsDownloadFunction : public AsyncExtensionFunction { 63 class DownloadsDownloadFunction : public AsyncExtensionFunction {
54 public: 64 public:
55 DECLARE_EXTENSION_FUNCTION("downloads.download", DOWNLOADS_DOWNLOAD) 65 DECLARE_EXTENSION_FUNCTION("downloads.download", DOWNLOADS_DOWNLOAD)
56 DownloadsDownloadFunction(); 66 DownloadsDownloadFunction();
57 virtual bool RunImpl() OVERRIDE; 67 virtual bool RunImpl() OVERRIDE;
58 68
59 protected: 69 protected:
60 virtual ~DownloadsDownloadFunction(); 70 virtual ~DownloadsDownloadFunction();
61 71
62 private: 72 private:
63 void OnStarted(content::DownloadItem* item, net::Error error); 73 void OnStarted(
74 const base::FilePath& creator_suggested_filename,
75 extensions::api::downloads::FilenameConflictAction
76 creator_conflict_action,
77 content::DownloadItem* item,
78 net::Error error);
64 79
65 DISALLOW_COPY_AND_ASSIGN(DownloadsDownloadFunction); 80 DISALLOW_COPY_AND_ASSIGN(DownloadsDownloadFunction);
66 }; 81 };
67 82
68 class DownloadsSearchFunction : public SyncExtensionFunction { 83 class DownloadsSearchFunction : public SyncExtensionFunction {
69 public: 84 public:
70 DECLARE_EXTENSION_FUNCTION("downloads.search", DOWNLOADS_SEARCH) 85 DECLARE_EXTENSION_FUNCTION("downloads.search", DOWNLOADS_SEARCH)
71 DownloadsSearchFunction(); 86 DownloadsSearchFunction();
72 virtual bool RunImpl() OVERRIDE; 87 virtual bool RunImpl() OVERRIDE;
73 88
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 DownloadsEraseFunction(); 138 DownloadsEraseFunction();
124 virtual bool RunImpl() OVERRIDE; 139 virtual bool RunImpl() OVERRIDE;
125 140
126 protected: 141 protected:
127 virtual ~DownloadsEraseFunction(); 142 virtual ~DownloadsEraseFunction();
128 143
129 private: 144 private:
130 DISALLOW_COPY_AND_ASSIGN(DownloadsEraseFunction); 145 DISALLOW_COPY_AND_ASSIGN(DownloadsEraseFunction);
131 }; 146 };
132 147
148 class DownloadsDeleteFileFunction : public AsyncExtensionFunction {
149 public:
150 DECLARE_EXTENSION_FUNCTION("downloads.deleteFile", DOWNLOADS_DELETEFILE)
151 DownloadsDeleteFileFunction();
152 virtual bool RunImpl() OVERRIDE;
153
154 protected:
155 virtual ~DownloadsDeleteFileFunction();
156
157 private:
158 void DeleteOnFileThread(const base::FilePath& path);
159 void RespondOnUIThread();
160 DISALLOW_COPY_AND_ASSIGN(DownloadsDeleteFileFunction);
161 };
162
133 class DownloadsAcceptDangerFunction : public AsyncExtensionFunction { 163 class DownloadsAcceptDangerFunction : public AsyncExtensionFunction {
134 public: 164 public:
135 DECLARE_EXTENSION_FUNCTION("downloads.acceptDanger", DOWNLOADS_ACCEPTDANGER) 165 DECLARE_EXTENSION_FUNCTION("downloads.acceptDanger", DOWNLOADS_ACCEPTDANGER)
136 DownloadsAcceptDangerFunction(); 166 DownloadsAcceptDangerFunction();
137 virtual bool RunImpl() OVERRIDE; 167 virtual bool RunImpl() OVERRIDE;
138 168
139 protected: 169 protected:
140 virtual ~DownloadsAcceptDangerFunction(); 170 virtual ~DownloadsAcceptDangerFunction();
141 void DangerPromptCallback(bool accept, int download_id); 171 void DangerPromptCallback(int download_id,
172 DownloadDangerPrompt::Action action);
142 173
143 private: 174 private:
144 DISALLOW_COPY_AND_ASSIGN(DownloadsAcceptDangerFunction); 175 DISALLOW_COPY_AND_ASSIGN(DownloadsAcceptDangerFunction);
145 }; 176 };
146 177
147 class DownloadsShowFunction : public AsyncExtensionFunction { 178 class DownloadsShowFunction : public AsyncExtensionFunction {
148 public: 179 public:
149 DECLARE_EXTENSION_FUNCTION("downloads.show", DOWNLOADS_SHOW) 180 DECLARE_EXTENSION_FUNCTION("downloads.show", DOWNLOADS_SHOW)
150 DownloadsShowFunction(); 181 DownloadsShowFunction();
151 virtual bool RunImpl() OVERRIDE; 182 virtual bool RunImpl() OVERRIDE;
(...skipping 24 matching lines...) Expand all
176 DownloadsDragFunction(); 207 DownloadsDragFunction();
177 virtual bool RunImpl() OVERRIDE; 208 virtual bool RunImpl() OVERRIDE;
178 209
179 protected: 210 protected:
180 virtual ~DownloadsDragFunction(); 211 virtual ~DownloadsDragFunction();
181 212
182 private: 213 private:
183 DISALLOW_COPY_AND_ASSIGN(DownloadsDragFunction); 214 DISALLOW_COPY_AND_ASSIGN(DownloadsDragFunction);
184 }; 215 };
185 216
217 class DownloadsSetShelfVisibleFunction : public SyncExtensionFunction {
218 public:
219 DECLARE_EXTENSION_FUNCTION("downloads.setShelfVisible",
220 DOWNLOADS_SETSHELFVISIBLE)
221 DownloadsSetShelfVisibleFunction();
222 virtual bool RunImpl() OVERRIDE;
223
224 protected:
225 virtual ~DownloadsSetShelfVisibleFunction();
226
227 private:
228 DISALLOW_COPY_AND_ASSIGN(DownloadsSetShelfVisibleFunction);
229 };
230
186 class DownloadsGetFileIconFunction : public AsyncExtensionFunction { 231 class DownloadsGetFileIconFunction : public AsyncExtensionFunction {
187 public: 232 public:
188 DECLARE_EXTENSION_FUNCTION("downloads.getFileIcon", DOWNLOADS_GETFILEICON) 233 DECLARE_EXTENSION_FUNCTION("downloads.getFileIcon", DOWNLOADS_GETFILEICON)
189 DownloadsGetFileIconFunction(); 234 DownloadsGetFileIconFunction();
190 virtual bool RunImpl() OVERRIDE; 235 virtual bool RunImpl() OVERRIDE;
191 void SetIconExtractorForTesting(DownloadFileIconExtractor* extractor); 236 void SetIconExtractorForTesting(DownloadFileIconExtractor* extractor);
192 237
193 protected: 238 protected:
194 virtual ~DownloadsGetFileIconFunction(); 239 virtual ~DownloadsGetFileIconFunction();
195 240
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 const extensions::Event::WillDispatchCallback& will_dispatch_callback, 315 const extensions::Event::WillDispatchCallback& will_dispatch_callback,
271 base::Value* json_arg); 316 base::Value* json_arg);
272 317
273 Profile* profile_; 318 Profile* profile_;
274 AllDownloadItemNotifier notifier_; 319 AllDownloadItemNotifier notifier_;
275 320
276 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); 321 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter);
277 }; 322 };
278 323
279 #endif // CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ 324 #endif // CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698