| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/webui/chromeos/imageburner/imageburner_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/imageburner/imageburner_ui.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 namespace chromeos { | 26 namespace chromeos { |
| 27 namespace imageburner { | 27 namespace imageburner { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 const char kPropertyDevicePath[] = "devicePath"; | 31 const char kPropertyDevicePath[] = "devicePath"; |
| 32 const char kPropertyFilePath[] = "filePath"; | 32 const char kPropertyFilePath[] = "filePath"; |
| 33 const char kPropertyLabel[] = "label"; | 33 const char kPropertyLabel[] = "label"; |
| 34 const char kPropertyPath[] = "path"; | 34 const char kPropertyPath[] = "path"; |
| 35 const char kPropertyDeviceType[] = "type"; |
| 35 | 36 |
| 36 // Link displayed on imageburner ui. | 37 // Link displayed on imageburner ui. |
| 37 const char kMoreInfoLink[] = | 38 const char kMoreInfoLink[] = |
| 38 "http://www.chromium.org/chromium-os/chromiumos-design-docs/recovery-mode"; | 39 "http://www.chromium.org/chromium-os/chromiumos-design-docs/recovery-mode"; |
| 39 | 40 |
| 40 ChromeWebUIDataSource* CreateImageburnerUIHTMLSource() { | 41 ChromeWebUIDataSource* CreateImageburnerUIHTMLSource() { |
| 41 ChromeWebUIDataSource* source = | 42 ChromeWebUIDataSource* source = |
| 42 new ChromeWebUIDataSource(chrome::kChromeUIImageBurnerHost); | 43 new ChromeWebUIDataSource(chrome::kChromeUIImageBurnerHost); |
| 43 | 44 |
| 44 source->AddLocalizedString("headerTitle", IDS_IMAGEBURN_HEADER_TITLE); | 45 source->AddLocalizedString("headerTitle", IDS_IMAGEBURN_HEADER_TITLE); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 184 } |
| 184 | 185 |
| 185 private: | 186 private: |
| 186 void CreateDiskValue(const disks::DiskMountManager::Disk& disk, | 187 void CreateDiskValue(const disks::DiskMountManager::Disk& disk, |
| 187 DictionaryValue* disk_value) { | 188 DictionaryValue* disk_value) { |
| 188 string16 label = ASCIIToUTF16(disk.drive_label()); | 189 string16 label = ASCIIToUTF16(disk.drive_label()); |
| 189 base::i18n::AdjustStringForLocaleDirection(&label); | 190 base::i18n::AdjustStringForLocaleDirection(&label); |
| 190 disk_value->SetString(std::string(kPropertyLabel), label); | 191 disk_value->SetString(std::string(kPropertyLabel), label); |
| 191 disk_value->SetString(std::string(kPropertyFilePath), disk.file_path()); | 192 disk_value->SetString(std::string(kPropertyFilePath), disk.file_path()); |
| 192 disk_value->SetString(std::string(kPropertyDevicePath), disk.device_path()); | 193 disk_value->SetString(std::string(kPropertyDevicePath), disk.device_path()); |
| 194 disk_value->SetString(std::string(kPropertyDeviceType), |
| 195 disks::DiskMountManager::DeviceTypeToString(disk.device_type())); |
| 193 } | 196 } |
| 194 | 197 |
| 195 // Callback for the "getDevices" message. | 198 // Callback for the "getDevices" message. |
| 196 void HandleGetDevices(const ListValue* args) { | 199 void HandleGetDevices(const ListValue* args) { |
| 197 const std::vector<disks::DiskMountManager::Disk> disks | 200 const std::vector<disks::DiskMountManager::Disk> disks |
| 198 = burn_controller_->GetBurnableDevices(); | 201 = burn_controller_->GetBurnableDevices(); |
| 199 ListValue results_value; | 202 ListValue results_value; |
| 200 for (size_t i = 0; i != disks.size(); ++i) { | 203 for (size_t i = 0; i != disks.size(); ++i) { |
| 201 DictionaryValue* disk_value = new DictionaryValue(); | 204 DictionaryValue* disk_value = new DictionaryValue(); |
| 202 CreateDiskValue(disks[i], disk_value); | 205 CreateDiskValue(disks[i], disk_value); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 324 |
| 322 ImageBurnUI::ImageBurnUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 325 ImageBurnUI::ImageBurnUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 323 chromeos::imageburner::WebUIHandler* handler = | 326 chromeos::imageburner::WebUIHandler* handler = |
| 324 new chromeos::imageburner::WebUIHandler(web_ui->GetWebContents()); | 327 new chromeos::imageburner::WebUIHandler(web_ui->GetWebContents()); |
| 325 web_ui->AddMessageHandler(handler); | 328 web_ui->AddMessageHandler(handler); |
| 326 | 329 |
| 327 Profile* profile = Profile::FromWebUI(web_ui); | 330 Profile* profile = Profile::FromWebUI(web_ui); |
| 328 profile->GetChromeURLDataManager()->AddDataSource( | 331 profile->GetChromeURLDataManager()->AddDataSource( |
| 329 chromeos::imageburner::CreateImageburnerUIHTMLSource()); | 332 chromeos::imageburner::CreateImageburnerUIHTMLSource()); |
| 330 } | 333 } |
| OLD | NEW |