| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 #ifndef CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ | 6 #ifndef CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ |
| 7 #define CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ | 7 #define CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/dom_ui/dom_ui.h" | 21 #include "chrome/browser/dom_ui/dom_ui.h" |
| 22 #include "chrome/browser/download/download_item.h" | 22 #include "chrome/browser/download/download_item.h" |
| 23 #include "chrome/browser/download/download_manager.h" | 23 #include "chrome/browser/download/download_manager.h" |
| 24 #include "chrome/browser/download/download_util.h" | 24 #include "chrome/browser/download/download_util.h" |
| 25 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
| 26 #include "net/base/file_stream.h" | 26 #include "net/base/file_stream.h" |
| 27 #include "ui/base/dragdrop/download_file_interface.h" | 27 #include "ui/base/dragdrop/download_file_interface.h" |
| 28 | 28 |
| 29 template <typename T> struct DefaultSingletonTraits; | 29 template <typename T> struct DefaultSingletonTraits; |
| 30 | 30 |
| 31 static const std::string kPropertyPath = "path"; | |
| 32 static const std::string kPropertyTitle = "title"; | |
| 33 static const std::string kPropertyDirectory = "isDirectory"; | |
| 34 static const std::string kImageBaseURL = | |
| 35 "http://chrome-master.mtv.corp.google.com/chromeos/dev-channel/"; | |
| 36 static const std::string kImageFetcherName = "LATEST-x86-generic"; | |
| 37 static const std::string kImageFileName = "chromeos_image.bin.gz"; | |
| 38 static const std::string kTempImageFolderName = "chromeos_image"; | |
| 39 | |
| 40 class ImageBurnResourceManager; | 31 class ImageBurnResourceManager; |
| 41 class TabContents; | 32 class TabContents; |
| 42 | 33 |
| 43 class ImageBurnUIHTMLSource : public ChromeURLDataManager::DataSource { | |
| 44 public: | |
| 45 ImageBurnUIHTMLSource(); | |
| 46 | |
| 47 // Called when the network layer has requested a resource underneath | |
| 48 // the path we registered. | |
| 49 virtual void StartDataRequest(const std::string& path, | |
| 50 bool is_off_the_record, | |
| 51 int request_id); | |
| 52 virtual std::string GetMimeType(const std::string&) const { | |
| 53 return "text/html"; | |
| 54 } | |
| 55 | |
| 56 private: | |
| 57 ~ImageBurnUIHTMLSource() {} | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(ImageBurnUIHTMLSource); | |
| 60 }; | |
| 61 | |
| 62 class ImageBurnHandler : public DOMMessageHandler, | 34 class ImageBurnHandler : public DOMMessageHandler, |
| 63 public chromeos::MountLibrary::Observer, | 35 public chromeos::MountLibrary::Observer, |
| 64 public chromeos::BurnLibrary::Observer, | 36 public chromeos::BurnLibrary::Observer, |
| 65 public DownloadManager::Observer, | 37 public DownloadManager::Observer, |
| 66 public DownloadItem::Observer, | 38 public DownloadItem::Observer, |
| 67 public base::SupportsWeakPtr<ImageBurnHandler> { | 39 public base::SupportsWeakPtr<ImageBurnHandler> { |
| 68 public: | 40 public: |
| 69 explicit ImageBurnHandler(TabContents* contents); | 41 explicit ImageBurnHandler(TabContents* contents); |
| 70 virtual ~ImageBurnHandler(); | 42 virtual ~ImageBurnHandler(); |
| 71 | 43 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 DownloadManager* download_manager_; | 102 DownloadManager* download_manager_; |
| 131 bool download_item_observer_added_; | 103 bool download_item_observer_added_; |
| 132 DownloadItem* active_download_item_; | 104 DownloadItem* active_download_item_; |
| 133 ImageBurnResourceManager* burn_resource_manager_; | 105 ImageBurnResourceManager* burn_resource_manager_; |
| 134 | 106 |
| 135 friend class ImageBurnTaskProxy; | 107 friend class ImageBurnTaskProxy; |
| 136 | 108 |
| 137 DISALLOW_COPY_AND_ASSIGN(ImageBurnHandler); | 109 DISALLOW_COPY_AND_ASSIGN(ImageBurnHandler); |
| 138 }; | 110 }; |
| 139 | 111 |
| 140 class ImageBurnTaskProxy | |
| 141 : public base::RefCountedThreadSafe<ImageBurnTaskProxy> { | |
| 142 public: | |
| 143 explicit ImageBurnTaskProxy(const base::WeakPtr<ImageBurnHandler>& handler); | |
| 144 | |
| 145 bool ReportDownloadInitialized(); | |
| 146 bool CheckDownloadFinished(); | |
| 147 void BurnImage(); | |
| 148 void FinalizeBurn(bool success); | |
| 149 | |
| 150 void CreateImageUrl(TabContents* tab_contents, ImageBurnHandler* downloader); | |
| 151 | |
| 152 private: | |
| 153 base::WeakPtr<ImageBurnHandler> handler_; | |
| 154 ImageBurnResourceManager* resource_manager_; | |
| 155 | |
| 156 friend class base::RefCountedThreadSafe<ImageBurnTaskProxy>; | |
| 157 | |
| 158 DISALLOW_COPY_AND_ASSIGN(ImageBurnTaskProxy); | |
| 159 }; | |
| 160 | |
| 161 class ImageBurnResourceManager : public DownloadManager::Observer, | 112 class ImageBurnResourceManager : public DownloadManager::Observer, |
| 162 public DownloadItem::Observer { | 113 public DownloadItem::Observer { |
| 163 public: | 114 public: |
| 164 // Returns the singleton instance. | 115 // Returns the singleton instance. |
| 165 static ImageBurnResourceManager* GetInstance(); | 116 static ImageBurnResourceManager* GetInstance(); |
| 166 | 117 |
| 167 // DownloadItem::Observer interface | 118 // DownloadItem::Observer interface |
| 168 virtual void OnDownloadUpdated(DownloadItem* download); | 119 virtual void OnDownloadUpdated(DownloadItem* download); |
| 169 virtual void OnDownloadFileCompleted(DownloadItem* download); | 120 virtual void OnDownloadFileCompleted(DownloadItem* download); |
| 170 virtual void OnDownloadOpened(DownloadItem* download); | 121 virtual void OnDownloadOpened(DownloadItem* download); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 }; | 168 }; |
| 218 | 169 |
| 219 class ImageBurnUI : public DOMUI { | 170 class ImageBurnUI : public DOMUI { |
| 220 public: | 171 public: |
| 221 explicit ImageBurnUI(TabContents* contents); | 172 explicit ImageBurnUI(TabContents* contents); |
| 222 | 173 |
| 223 private: | 174 private: |
| 224 DISALLOW_COPY_AND_ASSIGN(ImageBurnUI); | 175 DISALLOW_COPY_AND_ASSIGN(ImageBurnUI); |
| 225 }; | 176 }; |
| 226 #endif // CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ | 177 #endif // CHROME_BROWSER_CHROMEOS_DOM_UI_IMAGEBURNER_UI_H_ |
| OLD | NEW |