| 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_UI_WEBUI_CHROMEOS_IMAGEBURNER_WEBUI_HANDLER_H_ | 6 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGEBURNER_WEBUI_HANDLER_H_ |
| 7 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGEBURNER_WEBUI_HANDLER_H_ | 7 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGEBURNER_WEBUI_HANDLER_H_ |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/chromeos/cros/burn_library.h" | 15 #include "chrome/browser/chromeos/cros/burn_library.h" |
| 16 #include "chrome/browser/chromeos/cros/cros_library.h" | 16 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 17 #include "chrome/browser/chromeos/cros/mount_library.h" | |
| 18 #include "chrome/browser/chromeos/cros/network_library.h" | 17 #include "chrome/browser/chromeos/cros/network_library.h" |
| 18 #include "chrome/browser/chromeos/dbus/cros_disks_client.h" |
| 19 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 19 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 20 #include "chrome/browser/ui/webui/chromeos/imageburner/imageburner_utils.h" | 20 #include "chrome/browser/ui/webui/chromeos/imageburner/imageburner_utils.h" |
| 21 #include "content/browser/download/download_item.h" | 21 #include "content/browser/download/download_item.h" |
| 22 #include "content/browser/download/download_manager.h" | 22 #include "content/browser/download/download_manager.h" |
| 23 #include "content/browser/tab_contents/tab_contents.h" | 23 #include "content/browser/tab_contents/tab_contents.h" |
| 24 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
| 25 | 25 |
| 26 using content::BrowserThread; | 26 using content::BrowserThread; |
| 27 | 27 |
| 28 namespace imageburner { | 28 namespace imageburner { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 base::WeakPtr<Delegate> delegate_; | 68 base::WeakPtr<Delegate> delegate_; |
| 69 | 69 |
| 70 friend class base::RefCountedThreadSafe<WebUIHandlerTaskProxy>; | 70 friend class base::RefCountedThreadSafe<WebUIHandlerTaskProxy>; |
| 71 ~WebUIHandlerTaskProxy(); | 71 ~WebUIHandlerTaskProxy(); |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(WebUIHandlerTaskProxy); | 73 DISALLOW_COPY_AND_ASSIGN(WebUIHandlerTaskProxy); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 class WebUIHandler | 76 class WebUIHandler |
| 77 : public WebUIMessageHandler, | 77 : public WebUIMessageHandler, |
| 78 public chromeos::MountLibrary::Observer, | 78 public chromeos::CrosDisksClient::Observer, |
| 79 public chromeos::BurnLibrary::Observer, | 79 public chromeos::BurnLibrary::Observer, |
| 80 public chromeos::NetworkLibrary::NetworkManagerObserver, | 80 public chromeos::NetworkLibrary::NetworkManagerObserver, |
| 81 public DownloadItem::Observer, | 81 public DownloadItem::Observer, |
| 82 public DownloadManager::Observer, | 82 public DownloadManager::Observer, |
| 83 public Downloader::Listener, | 83 public Downloader::Listener, |
| 84 public StateMachine::Observer, | 84 public StateMachine::Observer, |
| 85 public WebUIHandlerTaskProxy::Delegate, | 85 public WebUIHandlerTaskProxy::Delegate, |
| 86 public BurnManager::Delegate { | 86 public BurnManager::Delegate { |
| 87 public: | 87 public: |
| 88 explicit WebUIHandler(TabContents* contents); | 88 explicit WebUIHandler(TabContents* contents); |
| 89 virtual ~WebUIHandler(); | 89 virtual ~WebUIHandler(); |
| 90 | 90 |
| 91 // WebUIMessageHandler implementation. | 91 // WebUIMessageHandler implementation. |
| 92 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; | 92 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; |
| 93 virtual void RegisterMessages() OVERRIDE; | 93 virtual void RegisterMessages() OVERRIDE; |
| 94 | 94 |
| 95 // chromeos::MountLibrary::Observer interface. | 95 // chromeos::CrosDisksClient::Observer interface. |
| 96 virtual void DiskChanged(chromeos::MountLibraryEventType event, | 96 virtual void DiskChanged(chromeos::CrosDisksClientEventType event, |
| 97 const chromeos::MountLibrary::Disk* disk) OVERRIDE; | 97 const chromeos::CrosDisksClient::Disk* disk) |
| 98 virtual void DeviceChanged(chromeos::MountLibraryEventType event, | 98 OVERRIDE; |
| 99 virtual void DeviceChanged(chromeos::CrosDisksClientEventType event, |
| 99 const std::string& device_path) OVERRIDE { | 100 const std::string& device_path) OVERRIDE { |
| 100 } | 101 } |
| 101 virtual void MountCompleted(chromeos::MountLibrary::MountEvent event_type, | 102 virtual void MountCompleted(chromeos::CrosDisksClient::MountEvent event_type, |
| 102 chromeos::MountError error_code, | 103 chromeos::MountError error_code, |
| 103 const chromeos::MountLibrary::MountPointInfo& mount_info) OVERRIDE { | 104 const chromeos::CrosDisksClient::MountPointInfo& mount_info) OVERRIDE { |
| 104 } | 105 } |
| 105 | 106 |
| 106 // chromeos::BurnLibrary::Observer interface. | 107 // chromeos::BurnLibrary::Observer interface. |
| 107 virtual void BurnProgressUpdated(chromeos::BurnLibrary* object, | 108 virtual void BurnProgressUpdated(chromeos::BurnLibrary* object, |
| 108 chromeos::BurnEvent evt, | 109 chromeos::BurnEvent evt, |
| 109 const ImageBurnStatus& status) OVERRIDE; | 110 const ImageBurnStatus& status) OVERRIDE; |
| 110 | 111 |
| 111 // chromeos::NetworkLibrary::NetworkManagerObserver interface. | 112 // chromeos::NetworkLibrary::NetworkManagerObserver interface. |
| 112 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj) OVERRIDE; | 113 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj) OVERRIDE; |
| 113 | 114 |
| 114 // DownloadItem::Observer interface. | 115 // DownloadItem::Observer interface. |
| 115 virtual void OnDownloadUpdated(DownloadItem* download) OVERRIDE; | 116 virtual void OnDownloadUpdated(DownloadItem* download) OVERRIDE; |
| 116 virtual void OnDownloadOpened(DownloadItem* download) OVERRIDE; | 117 virtual void OnDownloadOpened(DownloadItem* download) OVERRIDE; |
| 117 | 118 |
| 118 // DownloadManager::Observer interface. | 119 // DownloadManager::Observer interface. |
| 119 virtual void ModelChanged() OVERRIDE; | 120 virtual void ModelChanged() OVERRIDE; |
| 120 | 121 |
| 121 // Downloader::Listener interface. | 122 // Downloader::Listener interface. |
| 122 virtual void OnBurnDownloadStarted(bool success) OVERRIDE; | 123 virtual void OnBurnDownloadStarted(bool success) OVERRIDE; |
| 123 | 124 |
| 124 // StateMachine::Observer interface. | 125 // StateMachine::Observer interface. |
| 125 virtual void OnBurnStateChanged(StateMachine::State new_state) | 126 virtual void OnBurnStateChanged(StateMachine::State new_state) |
| 126 OVERRIDE; | 127 OVERRIDE; |
| 127 virtual void OnError(int error_message_id) OVERRIDE; | 128 virtual void OnError(int error_message_id) OVERRIDE; |
| 128 | 129 |
| 129 private: | 130 private: |
| 130 void CreateDiskValue(const chromeos::MountLibrary::Disk& disk, | 131 void CreateDiskValue(const chromeos::CrosDisksClient::Disk& disk, |
| 131 DictionaryValue* disk_value); | 132 DictionaryValue* disk_value); |
| 132 | 133 |
| 133 // Callback for the "getRoots" message. | 134 // Callback for the "getRoots" message. |
| 134 void HandleGetDevices(const ListValue* args); | 135 void HandleGetDevices(const ListValue* args); |
| 135 | 136 |
| 136 // Callback for the webuiInitialized message. | 137 // Callback for the webuiInitialized message. |
| 137 void HandleWebUIInitialized(const ListValue* args); | 138 void HandleWebUIInitialized(const ListValue* args); |
| 138 | 139 |
| 139 // Callback for the "cancelBurnImage" message. | 140 // Callback for the "cancelBurnImage" message. |
| 140 void HandleCancelBurnImage(const ListValue* args); | 141 void HandleCancelBurnImage(const ListValue* args); |
| 141 | 142 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 BurnManager* burn_manager_; | 206 BurnManager* burn_manager_; |
| 206 StateMachine* state_machine_; | 207 StateMachine* state_machine_; |
| 207 bool observing_burn_lib_; | 208 bool observing_burn_lib_; |
| 208 bool working_; | 209 bool working_; |
| 209 | 210 |
| 210 DISALLOW_COPY_AND_ASSIGN(WebUIHandler); | 211 DISALLOW_COPY_AND_ASSIGN(WebUIHandler); |
| 211 }; | 212 }; |
| 212 | 213 |
| 213 } // namespace imageburner. | 214 } // namespace imageburner. |
| 214 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGEBURNER_WEBUI_HANDLER_H_ | 215 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGEBURNER_WEBUI_HANDLER_H_ |
| 215 | |
| OLD | NEW |