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