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 virtual ~DownloadsDownloadFunction(); |
| 35 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.download"); |
| 36 |
| 37 virtual bool RunImpl() OVERRIDE; |
| 38 |
| 39 private: |
| 40 std::string url_; |
| 41 std::string filename_; |
| 42 bool save_as_; |
| 43 base::DictionaryValue* extra_headers_; |
| 44 std::string method_; |
| 45 std::string post_body_; |
| 46 |
| 47 ResourceDispatcherHost* rdh_; |
| 48 const content::ResourceContext* resource_context_; |
| 49 int render_process_host_id_; |
| 50 int render_view_host_routing_id_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(DownloadsDownloadFunction); |
| 53 }; |
| 54 |
| 55 class DownloadsSearchFunction : public SyncExtensionFunction { |
| 56 public: |
| 57 DownloadsSearchFunction(); |
| 58 virtual ~DownloadsSearchFunction(); |
| 59 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.search"); |
| 60 |
| 61 virtual bool RunImpl() OVERRIDE; |
| 62 |
| 63 private: |
| 64 DISALLOW_COPY_AND_ASSIGN(DownloadsSearchFunction); |
| 65 }; |
| 66 |
| 67 class DownloadsPauseFunction : public SyncExtensionFunction { |
| 68 public: |
| 69 DownloadsPauseFunction(); |
| 70 virtual ~DownloadsPauseFunction(); |
| 71 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.pause"); |
| 72 |
| 73 virtual bool RunImpl() OVERRIDE; |
| 74 |
| 75 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(DownloadsPauseFunction); |
| 77 }; |
| 78 |
| 79 class DownloadsResumeFunction : public AsyncExtensionFunction { |
| 80 public: |
| 81 DownloadsResumeFunction(); |
| 82 virtual ~DownloadsResumeFunction(); |
| 83 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.resume"); |
| 84 |
| 85 virtual bool RunImpl() OVERRIDE; |
| 86 |
| 87 private: |
| 88 DISALLOW_COPY_AND_ASSIGN(DownloadsResumeFunction); |
| 89 }; |
| 90 |
| 91 class DownloadsCancelFunction : public AsyncExtensionFunction { |
| 92 public: |
| 93 DownloadsCancelFunction(); |
| 94 virtual ~DownloadsCancelFunction(); |
| 95 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.cancel"); |
| 96 |
| 97 virtual bool RunImpl() OVERRIDE; |
| 98 |
| 99 private: |
| 100 DISALLOW_COPY_AND_ASSIGN(DownloadsCancelFunction); |
| 101 }; |
| 102 |
| 103 class DownloadsEraseFunction : public AsyncExtensionFunction { |
| 104 public: |
| 105 DownloadsEraseFunction(); |
| 106 virtual ~DownloadsEraseFunction(); |
| 107 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.erase"); |
| 108 |
| 109 virtual bool RunImpl() OVERRIDE; |
| 110 |
| 111 private: |
| 112 DISALLOW_COPY_AND_ASSIGN(DownloadsEraseFunction); |
| 113 }; |
| 114 |
| 115 class DownloadsSetDestinationFunction : public AsyncExtensionFunction { |
| 116 public: |
| 117 DownloadsSetDestinationFunction(); |
| 118 virtual ~DownloadsSetDestinationFunction(); |
| 119 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.setDestination"); |
| 120 |
| 121 virtual bool RunImpl() OVERRIDE; |
| 122 |
| 123 private: |
| 124 DISALLOW_COPY_AND_ASSIGN(DownloadsSetDestinationFunction); |
| 125 }; |
| 126 |
| 127 class DownloadsAcceptDangerFunction : public AsyncExtensionFunction { |
| 128 public: |
| 129 DownloadsAcceptDangerFunction(); |
| 130 virtual ~DownloadsAcceptDangerFunction(); |
| 131 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.acceptDanger"); |
| 132 |
| 133 virtual bool RunImpl() OVERRIDE; |
| 134 |
| 135 private: |
| 136 DISALLOW_COPY_AND_ASSIGN(DownloadsAcceptDangerFunction); |
| 137 }; |
| 138 |
| 139 class DownloadsShowFunction : public AsyncExtensionFunction { |
| 140 public: |
| 141 DownloadsShowFunction(); |
| 142 virtual ~DownloadsShowFunction(); |
| 143 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.show"); |
| 144 |
| 145 virtual bool RunImpl() OVERRIDE; |
| 146 |
| 147 private: |
| 148 DISALLOW_COPY_AND_ASSIGN(DownloadsShowFunction); |
| 149 }; |
| 150 |
| 151 class DownloadsDragFunction : public AsyncExtensionFunction { |
| 152 public: |
| 153 DownloadsDragFunction(); |
| 154 virtual ~DownloadsDragFunction(); |
| 155 DECLARE_EXTENSION_FUNCTION_NAME("experimental.downloads.drag"); |
| 156 |
| 157 virtual bool RunImpl() OVERRIDE; |
| 158 |
| 159 private: |
| 160 DISALLOW_COPY_AND_ASSIGN(DownloadsDragFunction); |
| 161 }; |
| 162 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOWNLOADS_API_H_ |
OLD | NEW |