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_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_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 // http://goo.gl/6hO1n |
| 28 |
| 29 class DownloadsDownloadFunction : public AsyncExtensionFunction { |
| 30 public: |
| 31 DownloadsDownloadFunction() |
| 32 : options_(NULL), |
| 33 save_as_(false), |
| 34 extra_headers_(NULL), |
| 35 dl_man_(NULL), |
| 36 rdh_(NULL), |
| 37 tab_contents_(NULL), |
| 38 resource_context_(NULL), |
| 39 render_process_host_id_(0), |
| 40 render_view_host_routing_id_(0), |
| 41 products_(NULL), |
| 42 dl_id_(-1), |
| 43 dl_error_(0) { |
| 44 } |
| 45 virtual ~DownloadsDownloadFunction() {} |
| 46 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.download"); |
| 47 |
| 48 virtual bool RunImpl() OVERRIDE; |
| 49 |
| 50 private: |
| 51 void BeginDownloadOnIOThread(); |
| 52 void OnStarted(int dl_id, int error); |
| 53 void RespondOnUIThread(); |
| 54 |
| 55 base::DictionaryValue* options_; |
| 56 std::string url_; |
| 57 std::string filename_; |
| 58 bool save_as_; |
| 59 base::DictionaryValue* extra_headers_; |
| 60 std::string method_; |
| 61 std::string post_body_; |
| 62 |
| 63 DownloadManager* dl_man_; |
| 64 ResourceDispatcherHost* rdh_; |
| 65 TabContents* tab_contents_; |
| 66 const content::ResourceContext* resource_context_; |
| 67 int render_process_host_id_; |
| 68 int render_view_host_routing_id_; |
| 69 |
| 70 base::DictionaryValue* products_; |
| 71 int dl_id_; |
| 72 int dl_error_; |
| 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(DownloadsDownloadFunction); |
| 75 }; |
| 76 |
| 77 class DownloadsSearchFunction : public SyncExtensionFunction { |
| 78 public: |
| 79 DownloadsSearchFunction() {} |
| 80 virtual ~DownloadsSearchFunction() {} |
| 81 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.search"); |
| 82 |
| 83 virtual bool RunImpl() OVERRIDE; |
| 84 |
| 85 private: |
| 86 DISALLOW_COPY_AND_ASSIGN(DownloadsSearchFunction); |
| 87 }; |
| 88 |
| 89 class DownloadsPauseFunction : public SyncExtensionFunction { |
| 90 public: |
| 91 DownloadsPauseFunction() {} |
| 92 virtual ~DownloadsPauseFunction() {} |
| 93 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.pause"); |
| 94 |
| 95 virtual bool RunImpl() OVERRIDE; |
| 96 |
| 97 private: |
| 98 DISALLOW_COPY_AND_ASSIGN(DownloadsPauseFunction); |
| 99 }; |
| 100 |
| 101 class DownloadsResumeFunction : public AsyncExtensionFunction { |
| 102 public: |
| 103 DownloadsResumeFunction() {} |
| 104 virtual ~DownloadsResumeFunction() {} |
| 105 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.resume"); |
| 106 |
| 107 virtual bool RunImpl() OVERRIDE; |
| 108 |
| 109 private: |
| 110 DISALLOW_COPY_AND_ASSIGN(DownloadsResumeFunction); |
| 111 }; |
| 112 |
| 113 class DownloadsCancelFunction : public AsyncExtensionFunction { |
| 114 public: |
| 115 DownloadsCancelFunction() {} |
| 116 virtual ~DownloadsCancelFunction() {} |
| 117 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.cancel"); |
| 118 |
| 119 virtual bool RunImpl() OVERRIDE; |
| 120 |
| 121 private: |
| 122 DISALLOW_COPY_AND_ASSIGN(DownloadsCancelFunction); |
| 123 }; |
| 124 |
| 125 class DownloadsEraseFunction : public AsyncExtensionFunction { |
| 126 public: |
| 127 DownloadsEraseFunction() {} |
| 128 virtual ~DownloadsEraseFunction() {} |
| 129 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.erase"); |
| 130 |
| 131 virtual bool RunImpl() OVERRIDE; |
| 132 |
| 133 private: |
| 134 DISALLOW_COPY_AND_ASSIGN(DownloadsEraseFunction); |
| 135 }; |
| 136 |
| 137 class DownloadsSetDestinationFunction : public AsyncExtensionFunction { |
| 138 public: |
| 139 DownloadsSetDestinationFunction() {} |
| 140 virtual ~DownloadsSetDestinationFunction() {} |
| 141 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.setDestination"); |
| 142 |
| 143 virtual bool RunImpl() OVERRIDE; |
| 144 |
| 145 private: |
| 146 DISALLOW_COPY_AND_ASSIGN(DownloadsSetDestinationFunction); |
| 147 }; |
| 148 |
| 149 class DownloadsAcceptDangerFunction : public AsyncExtensionFunction { |
| 150 public: |
| 151 DownloadsAcceptDangerFunction() {} |
| 152 virtual ~DownloadsAcceptDangerFunction() {} |
| 153 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.acceptDanger"); |
| 154 |
| 155 virtual bool RunImpl() OVERRIDE; |
| 156 |
| 157 private: |
| 158 DISALLOW_COPY_AND_ASSIGN(DownloadsAcceptDangerFunction); |
| 159 }; |
| 160 |
| 161 class DownloadsShowFunction : public AsyncExtensionFunction { |
| 162 public: |
| 163 DownloadsShowFunction() {} |
| 164 virtual ~DownloadsShowFunction() {} |
| 165 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.show"); |
| 166 |
| 167 virtual bool RunImpl() OVERRIDE; |
| 168 |
| 169 private: |
| 170 DISALLOW_COPY_AND_ASSIGN(DownloadsShowFunction); |
| 171 }; |
| 172 |
| 173 class DownloadsDragFunction : public AsyncExtensionFunction { |
| 174 public: |
| 175 DownloadsDragFunction() {} |
| 176 virtual ~DownloadsDragFunction() {} |
| 177 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.drag"); |
| 178 |
| 179 virtual bool RunImpl() OVERRIDE; |
| 180 |
| 181 private: |
| 182 DISALLOW_COPY_AND_ASSIGN(DownloadsDragFunction); |
| 183 }; |
| 184 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_H_ |
OLD | NEW |