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 #include "chrome/browser/ui/webui/chromeos/imageburner/imageburner_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/imageburner/imageburner_ui.h" |
6 #include "chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h" | 6 |
| 7 #include <string> |
| 8 #include <vector> |
7 | 9 |
8 #include "base/bind.h" | 10 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
10 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
11 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
12 #include "base/task.h" | |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "chrome/browser/chromeos/system/statistics_provider.h" | 16 #include "chrome/browser/chromeos/system/statistics_provider.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h" |
17 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 19 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
18 #include "chrome/common/jstemplate_builder.h" | 20 #include "chrome/common/jstemplate_builder.h" |
19 #include "chrome/common/time_format.h" | 21 #include "chrome/common/time_format.h" |
20 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
21 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
22 #include "grit/browser_resources.h" | 24 #include "grit/browser_resources.h" |
23 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
24 #include "grit/locale_settings.h" | 26 #include "grit/locale_settings.h" |
25 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
(...skipping 13 matching lines...) Expand all Loading... |
40 | 42 |
41 // 3.9GB. It is less than 4GB because true device size ussually varies a little. | 43 // 3.9GB. It is less than 4GB because true device size ussually varies a little. |
42 const uint64 kMinDeviceSize = static_cast<uint64>(3.9) * 1000 * 1000 * 1000; | 44 const uint64 kMinDeviceSize = static_cast<uint64>(3.9) * 1000 * 1000 * 1000; |
43 | 45 |
44 // Link displayed on imageburner ui. | 46 // Link displayed on imageburner ui. |
45 const char kMoreInfoLink[] = | 47 const char kMoreInfoLink[] = |
46 "http://www.chromium.org/chromium-os/chromiumos-design-docs/recovery-mode"; | 48 "http://www.chromium.org/chromium-os/chromiumos-design-docs/recovery-mode"; |
47 | 49 |
48 namespace { | 50 namespace { |
49 | 51 |
50 ChromeWebUIDataSource *CreateImageburnerUIHTMLSource() { | 52 ChromeWebUIDataSource* CreateImageburnerUIHTMLSource() { |
51 ChromeWebUIDataSource *source = | 53 ChromeWebUIDataSource* source = |
52 new ChromeWebUIDataSource(chrome::kChromeUIImageBurnerHost); | 54 new ChromeWebUIDataSource(chrome::kChromeUIImageBurnerHost); |
53 | 55 |
54 source->AddLocalizedString("headerTitle", IDS_IMAGEBURN_HEADER_TITLE); | 56 source->AddLocalizedString("headerTitle", IDS_IMAGEBURN_HEADER_TITLE); |
55 source->AddLocalizedString("headerDescription", | 57 source->AddLocalizedString("headerDescription", |
56 IDS_IMAGEBURN_HEADER_DESCRIPTION); | 58 IDS_IMAGEBURN_HEADER_DESCRIPTION); |
57 source->AddLocalizedString("headerLink", IDS_IMAGEBURN_HEADER_LINK); | 59 source->AddLocalizedString("headerLink", IDS_IMAGEBURN_HEADER_LINK); |
58 source->AddLocalizedString("statusDevicesNone", | 60 source->AddLocalizedString("statusDevicesNone", |
59 IDS_IMAGEBURN_NO_DEVICES_STATUS); | 61 IDS_IMAGEBURN_NO_DEVICES_STATUS); |
60 source->AddLocalizedString("warningDevicesNone", | 62 source->AddLocalizedString("warningDevicesNone", |
61 IDS_IMAGEBURN_NO_DEVICES_WARNING); | 63 IDS_IMAGEBURN_NO_DEVICES_WARNING); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 return; | 354 return; |
353 working_ = true; | 355 working_ = true; |
354 // Send progress signal now so ui doesn't hang in intial state until we get | 356 // Send progress signal now so ui doesn't hang in intial state until we get |
355 // config file | 357 // config file |
356 SendProgressSignal(DOWNLOAD, 0, 0, NULL); | 358 SendProgressSignal(DOWNLOAD, 0, 0, NULL); |
357 if (burn_manager_->GetImageDir().empty()) { | 359 if (burn_manager_->GetImageDir().empty()) { |
358 // Create image dir on File thread. | 360 // Create image dir on File thread. |
359 scoped_refptr<WebUIHandlerTaskProxy> task = new WebUIHandlerTaskProxy(this); | 361 scoped_refptr<WebUIHandlerTaskProxy> task = new WebUIHandlerTaskProxy(this); |
360 BrowserThread::PostTask( | 362 BrowserThread::PostTask( |
361 BrowserThread::FILE, FROM_HERE, | 363 BrowserThread::FILE, FROM_HERE, |
362 NewRunnableMethod(task.get(), &WebUIHandlerTaskProxy::CreateImageDir)); | 364 base::Bind(&WebUIHandlerTaskProxy::CreateImageDir, task.get())); |
363 } else { | 365 } else { |
364 ImageDirCreatedOnUIThread(true); | 366 ImageDirCreatedOnUIThread(true); |
365 } | 367 } |
366 } | 368 } |
367 | 369 |
368 void WebUIHandler::CreateImageDirOnFileThread() { | 370 void WebUIHandler::CreateImageDirOnFileThread() { |
369 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
370 burn_manager_->CreateImageDir(this); | 372 burn_manager_->CreateImageDir(this); |
371 } | 373 } |
372 | 374 |
373 void WebUIHandler::OnImageDirCreated(bool success) { | 375 void WebUIHandler::OnImageDirCreated(bool success) { |
374 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 376 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
375 // Transfer to UI thread. | 377 // Transfer to UI thread. |
376 scoped_refptr<WebUIHandlerTaskProxy> task = new WebUIHandlerTaskProxy(this); | 378 scoped_refptr<WebUIHandlerTaskProxy> task = new WebUIHandlerTaskProxy(this); |
377 BrowserThread::PostTask( | 379 BrowserThread::PostTask( |
378 BrowserThread::UI, FROM_HERE, | 380 BrowserThread::UI, FROM_HERE, |
379 NewRunnableMethod(task.get(), &WebUIHandlerTaskProxy::OnImageDirCreated, | 381 base::Bind(&WebUIHandlerTaskProxy::OnImageDirCreated, |
380 success)); | 382 task.get(), success)); |
381 } | 383 } |
382 | 384 |
383 void WebUIHandler::ImageDirCreatedOnUIThread(bool success) { | 385 void WebUIHandler::ImageDirCreatedOnUIThread(bool success) { |
384 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
385 if (success) { | 387 if (success) { |
386 zip_image_file_path_ = | 388 zip_image_file_path_ = |
387 burn_manager_->GetImageDir().Append(kImageZipFileName); | 389 burn_manager_->GetImageDir().Append(kImageZipFileName); |
388 burn_manager_->FetchConfigFile(tab_contents_, this); | 390 burn_manager_->FetchConfigFile(tab_contents_, this); |
389 } else { | 391 } else { |
390 DownloadCompleted(success); | 392 DownloadCompleted(success); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 //////////////////////////////////////////////////////////////////////////////// | 640 //////////////////////////////////////////////////////////////////////////////// |
639 | 641 |
640 ImageBurnUI::ImageBurnUI(TabContents* contents) : ChromeWebUI(contents) { | 642 ImageBurnUI::ImageBurnUI(TabContents* contents) : ChromeWebUI(contents) { |
641 imageburner::WebUIHandler* handler = new imageburner::WebUIHandler(contents); | 643 imageburner::WebUIHandler* handler = new imageburner::WebUIHandler(contents); |
642 AddMessageHandler((handler)->Attach(this)); | 644 AddMessageHandler((handler)->Attach(this)); |
643 | 645 |
644 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 646 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
645 profile->GetChromeURLDataManager()->AddDataSource( | 647 profile->GetChromeURLDataManager()->AddDataSource( |
646 CreateImageburnerUIHTMLSource()); | 648 CreateImageburnerUIHTMLSource()); |
647 } | 649 } |
OLD | NEW |