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