Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <map> | |
| 10 #include <set> | |
| 11 #include <string> | |
| 12 | |
| 13 #include "base/memory/singleton.h" | |
| 14 #include "chrome/browser/download/download_item.h" | |
| 15 #include "chrome/browser/download/download_manager.h" | |
| 16 #include "chrome/browser/extensions/extension_function.h" | |
| 17 | |
| 18 namespace base { | |
| 19 class DictionaryValue; | |
| 20 } | |
| 21 class ResourceDispatcherHost; | |
| 22 class TabContents; | |
| 23 namespace content { | |
| 24 class ResourceContext; | |
| 25 } | |
| 26 | |
| 27 // Functions in the chrome.experimental.downloads namespace facilitate | |
| 28 // controlling downloads from extensions. See the full API doc at | |
| 29 // http://goo.gl/6hO1n | |
| 30 | |
| 31 class DownloadsDownloadFunction : public AsyncExtensionFunction { | |
| 32 public: | |
| 33 DownloadsDownloadFunction() | |
| 34 : save_as_(false), | |
| 35 extra_headers_(NULL), | |
| 36 rdh_(NULL), | |
| 37 resource_context_(NULL), | |
| 38 render_process_host_id_(0), | |
| 39 render_view_host_routing_id_(0), | |
| 40 dl_id_(-1), | |
| 41 dl_error_(0) { | |
| 42 } | |
| 43 virtual ~DownloadsDownloadFunction() {} | |
| 44 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.download"); | |
| 45 | |
| 46 virtual bool RunImpl() OVERRIDE; | |
| 47 | |
| 48 private: | |
| 49 std::string url_; | |
| 50 std::string filename_; | |
| 51 bool save_as_; | |
| 52 base::DictionaryValue* extra_headers_; | |
| 53 std::string method_; | |
| 54 std::string post_body_; | |
| 55 | |
| 56 ResourceDispatcherHost* rdh_; | |
| 57 const content::ResourceContext* resource_context_; | |
| 58 int render_process_host_id_; | |
| 59 int render_view_host_routing_id_; | |
| 60 | |
| 61 int dl_id_; | |
|
Mihai Parparita -not on Chrome
2011/08/09 19:51:42
Nit: These can be removed for now.
benjhayden
2011/08/09 20:59:50
Done.
| |
| 62 int dl_error_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(DownloadsDownloadFunction); | |
| 65 }; | |
| 66 | |
| 67 class DownloadsSearchFunction : public SyncExtensionFunction { | |
| 68 public: | |
| 69 DownloadsSearchFunction() {} | |
| 70 virtual ~DownloadsSearchFunction() {} | |
| 71 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.search"); | |
| 72 | |
| 73 virtual bool RunImpl() OVERRIDE; | |
| 74 | |
| 75 private: | |
| 76 DISALLOW_COPY_AND_ASSIGN(DownloadsSearchFunction); | |
| 77 }; | |
| 78 | |
| 79 class DownloadsPauseFunction : public SyncExtensionFunction { | |
| 80 public: | |
| 81 DownloadsPauseFunction() {} | |
| 82 virtual ~DownloadsPauseFunction() {} | |
| 83 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.pause"); | |
| 84 | |
| 85 virtual bool RunImpl() OVERRIDE; | |
| 86 | |
| 87 private: | |
| 88 DISALLOW_COPY_AND_ASSIGN(DownloadsPauseFunction); | |
| 89 }; | |
| 90 | |
| 91 class DownloadsResumeFunction : public AsyncExtensionFunction { | |
| 92 public: | |
| 93 DownloadsResumeFunction() {} | |
| 94 virtual ~DownloadsResumeFunction() {} | |
| 95 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.resume"); | |
| 96 | |
| 97 virtual bool RunImpl() OVERRIDE; | |
| 98 | |
| 99 private: | |
| 100 DISALLOW_COPY_AND_ASSIGN(DownloadsResumeFunction); | |
| 101 }; | |
| 102 | |
| 103 class DownloadsCancelFunction : public AsyncExtensionFunction { | |
| 104 public: | |
| 105 DownloadsCancelFunction() {} | |
| 106 virtual ~DownloadsCancelFunction() {} | |
| 107 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.cancel"); | |
| 108 | |
| 109 virtual bool RunImpl() OVERRIDE; | |
| 110 | |
| 111 private: | |
| 112 DISALLOW_COPY_AND_ASSIGN(DownloadsCancelFunction); | |
| 113 }; | |
| 114 | |
| 115 class DownloadsEraseFunction : public AsyncExtensionFunction { | |
| 116 public: | |
| 117 DownloadsEraseFunction() {} | |
| 118 virtual ~DownloadsEraseFunction() {} | |
| 119 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.erase"); | |
| 120 | |
| 121 virtual bool RunImpl() OVERRIDE; | |
| 122 | |
| 123 private: | |
| 124 DISALLOW_COPY_AND_ASSIGN(DownloadsEraseFunction); | |
| 125 }; | |
| 126 | |
| 127 class DownloadsSetDestinationFunction : public AsyncExtensionFunction { | |
| 128 public: | |
| 129 DownloadsSetDestinationFunction() {} | |
| 130 virtual ~DownloadsSetDestinationFunction() {} | |
| 131 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.setDestination"); | |
| 132 | |
| 133 virtual bool RunImpl() OVERRIDE; | |
| 134 | |
| 135 private: | |
| 136 DISALLOW_COPY_AND_ASSIGN(DownloadsSetDestinationFunction); | |
| 137 }; | |
| 138 | |
| 139 class DownloadsAcceptDangerFunction : public AsyncExtensionFunction { | |
| 140 public: | |
| 141 DownloadsAcceptDangerFunction() {} | |
| 142 virtual ~DownloadsAcceptDangerFunction() {} | |
| 143 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.acceptDanger"); | |
| 144 | |
| 145 virtual bool RunImpl() OVERRIDE; | |
| 146 | |
| 147 private: | |
| 148 DISALLOW_COPY_AND_ASSIGN(DownloadsAcceptDangerFunction); | |
| 149 }; | |
| 150 | |
| 151 class DownloadsShowFunction : public AsyncExtensionFunction { | |
| 152 public: | |
| 153 DownloadsShowFunction() {} | |
| 154 virtual ~DownloadsShowFunction() {} | |
| 155 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.show"); | |
| 156 | |
| 157 virtual bool RunImpl() OVERRIDE; | |
| 158 | |
| 159 private: | |
| 160 DISALLOW_COPY_AND_ASSIGN(DownloadsShowFunction); | |
| 161 }; | |
| 162 | |
| 163 class DownloadsDragFunction : public AsyncExtensionFunction { | |
| 164 public: | |
| 165 DownloadsDragFunction() {} | |
| 166 virtual ~DownloadsDragFunction() {} | |
| 167 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.drag"); | |
| 168 | |
| 169 virtual bool RunImpl() OVERRIDE; | |
| 170 | |
| 171 private: | |
| 172 DISALLOW_COPY_AND_ASSIGN(DownloadsDragFunction); | |
| 173 }; | |
| 174 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ | |
| OLD | NEW |