OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/dom_ui/imageburner_ui.h" | 5 #include "chrome/browser/chromeos/dom_ui/imageburner_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/singleton.h" | 14 #include "base/singleton.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/task.h" | 16 #include "base/task.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/browser/browser_thread.h" | 19 #include "chrome/browser/browser_thread.h" |
20 #include "chrome/browser/download/download_types.h" | 20 #include "chrome/browser/download/download_types.h" |
21 #include "chrome/browser/download/download_util.h" | 21 #include "chrome/browser/download/download_util.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/tab_contents/tab_contents.h" | 23 #include "chrome/browser/tab_contents/tab_contents.h" |
24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/jstemplate_builder.h" | 25 #include "chrome/common/jstemplate_builder.h" |
26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
27 #include "grit/browser_resources.h" | 27 #include "grit/browser_resources.h" |
28 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
29 #include "grit/locale_settings.h" | 29 #include "grit/locale_settings.h" |
30 #include "third_party/zlib/contrib/minizip/unzip.h" | |
30 | 31 |
31 | 32 |
33 static const std::string kPropertyPath = "path"; | |
34 static const std::string kPropertyTitle = "title"; | |
35 static const std::string kPropertyDirectory = "isDirectory"; | |
36 static const std::string kImageBaseURL = | |
37 "http://chrome-master.mtv.corp.google.com/chromeos/dev-channel/"; | |
xiyuan
2011/01/25 22:37:22
We should avoid complex object in global scope whe
| |
38 static const char* const kImageFetcherName = "LATEST-x86-generic"; | |
39 static const char* const kImageDownloadURL = | |
40 "https://dl.google.com/dl/chromeos/recovery/latest_mario_beta_channel"; | |
41 static const char* const kImageFileName = "chromeos_image.bin.zip"; | |
42 static const char* const kTempImageFolderName = "chromeos_image"; | |
xiyuan
2011/01/25 22:37:22
Please use const char[] to be consistent.
See chro
| |
43 | |
32 //////////////////////////////////////////////////////////////////////////////// | 44 //////////////////////////////////////////////////////////////////////////////// |
33 // | 45 // |
34 // ImageBurnUIHTMLSource | 46 // ImageBurnUIHTMLSource |
35 // | 47 // |
36 //////////////////////////////////////////////////////////////////////////////// | 48 //////////////////////////////////////////////////////////////////////////////// |
37 | 49 |
38 ImageBurnUIHTMLSource::ImageBurnUIHTMLSource() | 50 class ImageBurnUIHTMLSource : public ChromeURLDataManager::DataSource { |
39 : DataSource(chrome::kChromeUIImageBurnerHost, MessageLoop::current()) { | 51 public: |
40 } | 52 ImageBurnUIHTMLSource() |
53 : DataSource(chrome::kChromeUIImageBurnerHost, MessageLoop::current()) { | |
54 } | |
41 | 55 |
42 void ImageBurnUIHTMLSource::StartDataRequest(const std::string& path, | 56 // Called when the network layer has requested a resource underneath |
43 bool is_off_the_record, | 57 // the path we registered. |
44 int request_id) { | 58 virtual void StartDataRequest(const std::string& path, |
45 DictionaryValue localized_strings; | 59 bool is_off_the_record, |
46 localized_strings.SetString("burnConfirmText1", | 60 int request_id) { |
47 l10n_util::GetStringUTF16(IDS_IMAGEBURN_CONFIM_BURN1)); | 61 DictionaryValue localized_strings; |
48 localized_strings.SetString("burnConfirmText2", | 62 localized_strings.SetString("burnConfirmText1", |
49 l10n_util::GetStringUTF16(IDS_IMAGEBURN_CONFIM_BURN2)); | 63 l10n_util::GetStringUTF16(IDS_IMAGEBURN_CONFIM_BURN1)); |
50 localized_strings.SetString("burnUnsuccessfulMessage", | 64 localized_strings.SetString("burnConfirmText2", |
51 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_UNSUCCESSFUL)); | 65 l10n_util::GetStringUTF16(IDS_IMAGEBURN_CONFIM_BURN2)); |
52 localized_strings.SetString("burnSuccessfulMessage", | 66 localized_strings.SetString("burnUnsuccessfulMessage", |
53 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_SUCCESSFUL)); | 67 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_UNSUCCESSFUL)); |
54 localized_strings.SetString("downloadAbortedMessage", | 68 localized_strings.SetString("burnSuccessfulMessage", |
55 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_UNSUCCESSFUL)); | 69 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_SUCCESSFUL)); |
56 localized_strings.SetString("title", | 70 localized_strings.SetString("downloadAbortedMessage", |
57 l10n_util::GetStringUTF16(IDS_IMAGEBURN_TITLE)); | 71 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_UNSUCCESSFUL)); |
58 localized_strings.SetString("listTitle", | 72 localized_strings.SetString("title", |
59 l10n_util::GetStringUTF16(IDS_IMAGEBURN_ROOT_LIST_TITLE)); | 73 l10n_util::GetStringUTF16(IDS_IMAGEBURN_TITLE)); |
60 localized_strings.SetString("downloadStatusStart", | 74 localized_strings.SetString("listTitle", |
61 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_STARTING_STATUS)); | 75 l10n_util::GetStringUTF16(IDS_IMAGEBURN_ROOT_LIST_TITLE)); |
62 localized_strings.SetString("downloadStatusInProgress", | 76 localized_strings.SetString("downloadStatusStart", |
63 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_IN_PROGRESS_STATUS)); | 77 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_STARTING_STATUS)); |
64 localized_strings.SetString("downloadStatusComplete", | 78 localized_strings.SetString("downloadStatusInProgress", |
65 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_COMPLETE_STATUS)); | 79 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_IN_PROGRESS_STATUS)); |
66 localized_strings.SetString("downloadStatusCanceled", | 80 localized_strings.SetString("downloadStatusComplete", |
67 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_CANCELED_STATUS)); | 81 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_COMPLETE_STATUS)); |
68 localized_strings.SetString("burnStatusStart", | 82 localized_strings.SetString("downloadStatusCanceled", |
69 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_STARTING_STATUS)); | 83 l10n_util::GetStringUTF16(IDS_IMAGEBURN_DOWNLOAD_CANCELED_STATUS)); |
70 localized_strings.SetString("burnStatusInProgress", | 84 localized_strings.SetString("burnStatusStart", |
71 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_IN_PROGRESS_STATUS)); | 85 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_STARTING_STATUS)); |
72 localized_strings.SetString("burnStatusComplete", | 86 localized_strings.SetString("burnStatusInProgress", |
73 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_COMPLETE_STATUS)); | 87 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_IN_PROGRESS_STATUS)); |
74 localized_strings.SetString("burnStatusCanceled", | 88 localized_strings.SetString("burnStatusComplete", |
75 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_CANCELED_STATUS)); | 89 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_COMPLETE_STATUS)); |
90 localized_strings.SetString("burnStatusCanceled", | |
91 l10n_util::GetStringUTF16(IDS_IMAGEBURN_BURN_CANCELED_STATUS)); | |
76 | 92 |
77 SetFontAndTextDirection(&localized_strings); | 93 SetFontAndTextDirection(&localized_strings); |
78 | 94 |
79 static const base::StringPiece imageburn_html( | 95 static const base::StringPiece imageburn_html( |
80 ResourceBundle::GetSharedInstance().GetRawDataResource( | 96 ResourceBundle::GetSharedInstance().GetRawDataResource( |
81 IDR_IMAGEBURNER_HTML)); | 97 IDR_IMAGEBURNER_HTML)); |
82 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( | 98 const std::string full_html = jstemplate_builder::GetI18nTemplateHtml( |
83 imageburn_html, &localized_strings); | 99 imageburn_html, &localized_strings); |
84 | 100 |
85 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 101 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); |
86 html_bytes->data.resize(full_html.size()); | 102 html_bytes->data.resize(full_html.size()); |
87 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); | 103 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); |
88 | 104 |
89 SendResponse(request_id, html_bytes); | 105 SendResponse(request_id, html_bytes); |
90 } | 106 } |
107 | |
108 virtual std::string GetMimeType(const std::string&) const { | |
109 return "text/html"; | |
110 } | |
111 | |
112 private: | |
113 virtual ~ImageBurnUIHTMLSource() {} | |
114 | |
115 DISALLOW_COPY_AND_ASSIGN(ImageBurnUIHTMLSource); | |
116 }; | |
117 | |
118 //////////////////////////////////////////////////////////////////////////////// | |
119 // | |
120 // ImageBurnTaskProxy | |
121 // | |
122 //////////////////////////////////////////////////////////////////////////////// | |
123 | |
124 class ImageBurnTaskProxy | |
125 : public base::RefCountedThreadSafe<ImageBurnTaskProxy> { | |
126 public: | |
127 explicit ImageBurnTaskProxy(const base::WeakPtr<ImageBurnHandler>& handler) | |
128 : handler_(handler) { | |
129 resource_manager_ = ImageBurnResourceManager::GetInstance(); | |
130 } | |
131 | |
132 bool ReportDownloadInitialized() { | |
133 bool initialized = resource_manager_-> CheckImageDownloadStarted(); | |
134 if (!initialized) | |
135 resource_manager_-> ReportImageDownloadStarted(); | |
136 return initialized; | |
137 } | |
138 | |
139 bool CheckDownloadFinished() { | |
140 return resource_manager_->CheckDownloadFinished(); | |
141 } | |
142 | |
143 void BurnImage() { | |
144 if (!resource_manager_->CheckBurnInProgress() && handler_) { | |
145 resource_manager_->SetBurnInProgress(true); | |
146 handler_->BurnImage(); | |
147 } | |
148 } | |
149 | |
150 void FinalizeBurn(bool success) { | |
151 if (handler_) { | |
152 handler_->FinalizeBurn(success); | |
153 resource_manager_->SetBurnInProgress(false); | |
154 } | |
155 } | |
156 | |
157 void CreateImageUrl(TabContents* tab_contents, ImageBurnHandler* downloader) { | |
158 resource_manager_->CreateImageUrl(tab_contents, downloader); | |
159 } | |
160 | |
161 private: | |
162 base::WeakPtr<ImageBurnHandler> handler_; | |
163 ImageBurnResourceManager* resource_manager_; | |
164 | |
165 friend class base::RefCountedThreadSafe<ImageBurnTaskProxy>; | |
166 | |
167 DISALLOW_COPY_AND_ASSIGN(ImageBurnTaskProxy); | |
168 }; | |
91 | 169 |
92 //////////////////////////////////////////////////////////////////////////////// | 170 //////////////////////////////////////////////////////////////////////////////// |
93 // | 171 // |
94 // ImageBurnHandler | 172 // ImageBurnHandler |
95 // | 173 // |
96 //////////////////////////////////////////////////////////////////////////////// | 174 //////////////////////////////////////////////////////////////////////////////// |
97 | 175 |
98 ImageBurnHandler::ImageBurnHandler(TabContents* contents) | 176 ImageBurnHandler::ImageBurnHandler(TabContents* contents) |
99 :tab_contents_(contents), | 177 :tab_contents_(contents), |
100 download_manager_(NULL), | 178 download_manager_(NULL), |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 local_image_file_path_ = download->full_path(); | 260 local_image_file_path_ = download->full_path(); |
183 DownloadCompleted(true); | 261 DownloadCompleted(true); |
184 } | 262 } |
185 | 263 |
186 void ImageBurnHandler::OnDownloadOpened(DownloadItem* download) { | 264 void ImageBurnHandler::OnDownloadOpened(DownloadItem* download) { |
187 if (download->safety_state() == DownloadItem::DANGEROUS) | 265 if (download->safety_state() == DownloadItem::DANGEROUS) |
188 download->DangerousDownloadValidated(); | 266 download->DangerousDownloadValidated(); |
189 } | 267 } |
190 | 268 |
191 void ImageBurnHandler::ModelChanged() { | 269 void ImageBurnHandler::ModelChanged() { |
270 // Find our item and observe it. | |
192 std::vector<DownloadItem*> downloads; | 271 std::vector<DownloadItem*> downloads; |
193 download_manager_->GetTemporaryDownloads( | 272 download_manager_->GetTemporaryDownloads( |
194 burn_resource_manager_->GetLocalImageDirPath(), &downloads); | 273 burn_resource_manager_->GetLocalImageDirPath(), &downloads); |
195 if (download_item_observer_added_) | 274 if (download_item_observer_added_) // Already added. |
196 return; | 275 return; |
197 std::vector<DownloadItem*>::const_iterator it = downloads.begin(); | 276 std::vector<DownloadItem*>::const_iterator it = downloads.begin(); |
198 for (; it != downloads.end(); ++it) { | 277 for (; it != downloads.end(); ++it) { |
199 if ((*it)->url() == *image_download_url_) { | 278 if ((*it)->original_url() == *image_download_url_) { |
279 // Found it. | |
200 download_item_observer_added_ = true; | 280 download_item_observer_added_ = true; |
201 (*it)->AddObserver(this); | 281 (*it)->AddObserver(this); |
202 active_download_item_ = *it; | 282 active_download_item_ = *it; |
203 break; | 283 break; |
204 } | 284 } |
205 } | 285 } |
206 } | 286 } |
207 | 287 |
208 void ImageBurnHandler::HandleGetRoots(const ListValue* args) { | 288 void ImageBurnHandler::HandleGetRoots(const ListValue* args) { |
209 ListValue results_value; | 289 ListValue results_value; |
210 DictionaryValue info_value; | 290 DictionaryValue info_value; |
211 chromeos::MountLibrary* mount_lib = | 291 chromeos::MountLibrary* mount_lib = |
212 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 292 chromeos::CrosLibrary::Get()->GetMountLibrary(); |
213 const chromeos::MountLibrary::DiskVector& disks = mount_lib->disks(); | 293 const chromeos::MountLibrary::DiskVector& disks = mount_lib->disks(); |
214 if (!burn_resource_manager_->CheckBurnInProgress()) { | 294 if (!burn_resource_manager_->CheckBurnInProgress()) { |
215 for (size_t i = 0; i < disks.size(); ++i) { | 295 for (size_t i = 0; i < disks.size(); ++i) { |
216 if (!disks[i].mount_path.empty()) { | 296 if (!disks[i].mount_path.empty()) { |
217 DictionaryValue* page_value = new DictionaryValue(); | |
218 FilePath disk_path = FilePath(disks[i].system_path).DirName(); | 297 FilePath disk_path = FilePath(disks[i].system_path).DirName(); |
219 std::string title = "/dev/" + disk_path.BaseName().value(); | 298 std::string title = "/dev/" + disk_path.BaseName().value(); |
220 page_value->SetString(kPropertyTitle, title); | 299 if (!mount_lib->IsBootPath(title.c_str())) { |
221 page_value->SetString(kPropertyPath, title); | 300 DictionaryValue* page_value = new DictionaryValue(); |
222 page_value->SetBoolean(kPropertyDirectory, true); | 301 page_value->SetString(kPropertyTitle, title); |
223 results_value.Append(page_value); | 302 page_value->SetString(kPropertyPath, title); |
303 page_value->SetBoolean(kPropertyDirectory, true); | |
304 results_value.Append(page_value); | |
305 } | |
224 } | 306 } |
225 } | 307 } |
226 } | 308 } |
227 info_value.SetString("functionCall", "getRoots"); | 309 info_value.SetString("functionCall", "getRoots"); |
228 info_value.SetString(kPropertyPath, ""); | 310 info_value.SetString(kPropertyPath, ""); |
229 dom_ui_->CallJavascriptFunction(L"browseFileResult", | 311 dom_ui_->CallJavascriptFunction(L"browseFileResult", |
230 info_value, results_value); | 312 info_value, results_value); |
231 } | 313 } |
232 | 314 |
233 void ImageBurnHandler::HandleDownloadImage(const ListValue* args) { | 315 void ImageBurnHandler::HandleDownloadImage(const ListValue* args) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 signal_value.SetString("state", "IN_PROGRESS"); | 358 signal_value.SetString("state", "IN_PROGRESS"); |
277 signal_value.SetString("path", image_target_.value()); | 359 signal_value.SetString("path", image_target_.value()); |
278 signal_value.SetInteger("received", 0); | 360 signal_value.SetInteger("received", 0); |
279 signal_value.SetString("progress_status_text", ""); | 361 signal_value.SetString("progress_status_text", ""); |
280 dom_ui_->CallJavascriptFunction(L"burnProgressUpdated", signal_value); | 362 dom_ui_->CallJavascriptFunction(L"burnProgressUpdated", signal_value); |
281 } | 363 } |
282 } | 364 } |
283 | 365 |
284 void ImageBurnHandler::FinalizeBurn(bool successful) { | 366 void ImageBurnHandler::FinalizeBurn(bool successful) { |
285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
286 if (successful) | 368 dom_ui_->CallJavascriptFunction(successful ? |
287 dom_ui_->CallJavascriptFunction(L"burnSuccessful"); | 369 L"burnSuccessful" : L"burnUnsuccessful"); |
288 else | |
289 dom_ui_->CallJavascriptFunction(L"burnUnsuccessful"); | |
290 } | 370 } |
291 | 371 |
292 void ImageBurnHandler::UpdateBurnProgress(int64 total_burnt, | 372 void ImageBurnHandler::UpdateBurnProgress(int64 total_burnt, |
293 int64 image_size, | 373 int64 image_size, |
294 const std::string& path, | 374 const std::string& path, |
295 chromeos::BurnEventType event) { | 375 chromeos::BurnEventType event) { |
296 DictionaryValue progress_value; | 376 DictionaryValue progress_value; |
297 progress_value.SetString("progress_status_text", | 377 progress_value.SetString("progress_status_text", |
298 GetBurnProgressText(total_burnt, image_size)); | 378 GetBurnProgressText(total_burnt, image_size)); |
299 if (event == chromeos::BURN_UPDATED) | 379 if (event == chromeos::BURN_UPDATED) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 image_target_ = FilePath(image_dest); | 466 image_target_ = FilePath(image_dest); |
387 } | 467 } |
388 | 468 |
389 void ImageBurnHandler::CreateLocalImagePath() { | 469 void ImageBurnHandler::CreateLocalImagePath() { |
390 local_image_file_path_ = | 470 local_image_file_path_ = |
391 burn_resource_manager_->GetLocalImageDirPath().Append(kImageFileName); | 471 burn_resource_manager_->GetLocalImageDirPath().Append(kImageFileName); |
392 } | 472 } |
393 | 473 |
394 //////////////////////////////////////////////////////////////////////////////// | 474 //////////////////////////////////////////////////////////////////////////////// |
395 // | 475 // |
396 // ImageBurnTaskProxy | |
397 // | |
398 //////////////////////////////////////////////////////////////////////////////// | |
399 ImageBurnTaskProxy::ImageBurnTaskProxy( | |
400 const base::WeakPtr<ImageBurnHandler>& handler) | |
401 : handler_(handler) { | |
402 resource_manager_ = ImageBurnResourceManager::GetInstance(); | |
403 } | |
404 | |
405 bool ImageBurnTaskProxy::ReportDownloadInitialized() { | |
406 bool initialized = resource_manager_-> CheckImageDownloadStarted(); | |
407 if (!initialized) | |
408 resource_manager_-> ReportImageDownloadStarted(); | |
409 return initialized; | |
410 } | |
411 | |
412 bool ImageBurnTaskProxy::CheckDownloadFinished() { | |
413 return resource_manager_->CheckDownloadFinished(); | |
414 } | |
415 | |
416 void ImageBurnTaskProxy:: BurnImage() { | |
417 if (!resource_manager_->CheckBurnInProgress() && handler_) { | |
418 resource_manager_->SetBurnInProgress(true); | |
419 handler_->BurnImage(); | |
420 } | |
421 } | |
422 | |
423 void ImageBurnTaskProxy::FinalizeBurn(bool success) { | |
424 if (handler_) { | |
425 handler_->FinalizeBurn(success); | |
426 resource_manager_->SetBurnInProgress(false); | |
427 } | |
428 } | |
429 | |
430 void ImageBurnTaskProxy::CreateImageUrl(TabContents* tab_contents, | |
431 ImageBurnHandler* downloader) { | |
432 resource_manager_->CreateImageUrl(tab_contents, downloader); | |
433 } | |
434 | |
435 | |
436 //////////////////////////////////////////////////////////////////////////////// | |
437 // | |
438 // ImageBurnResourceManager | 476 // ImageBurnResourceManager |
439 // | 477 // |
440 //////////////////////////////////////////////////////////////////////////////// | 478 //////////////////////////////////////////////////////////////////////////////// |
441 | 479 |
442 ImageBurnResourceManager::ImageBurnResourceManager() | 480 ImageBurnResourceManager::ImageBurnResourceManager() |
443 : image_download_started_(false), | 481 : image_download_started_(false), |
444 image_download_finished_(false), | 482 image_download_finished_(false), |
445 burn_in_progress_(false), | 483 burn_in_progress_(false), |
446 download_manager_(NULL), | 484 download_manager_(NULL), |
447 download_item_observer_added_(false), | 485 download_item_observer_added_(false), |
448 active_download_item_(NULL), | 486 active_download_item_(NULL), |
449 image_url_(NULL), | 487 image_url_(new GURL(kImageDownloadURL)), |
450 image_fetcher_url_(kImageBaseURL + kImageFetcherName), | 488 image_fetcher_url_(kImageBaseURL + kImageFetcherName), |
451 image_url_fetching_requested_(false), | 489 image_url_fetching_requested_(false), |
452 image_url_fetched_(false) { | 490 image_url_fetched_(true) { |
453 local_image_dir_file_path_.clear(); | 491 local_image_dir_file_path_.clear(); |
454 image_fecher_local_path_ = GetLocalImageDirPath().Append(kImageFetcherName); | 492 image_fecher_local_path_ = GetLocalImageDirPath().Append(kImageFetcherName); |
455 } | 493 } |
456 | 494 |
457 ImageBurnResourceManager::~ImageBurnResourceManager() { | 495 ImageBurnResourceManager::~ImageBurnResourceManager() { |
458 if (!local_image_dir_file_path_.empty()) { | 496 if (!local_image_dir_file_path_.empty()) { |
459 file_util::Delete(local_image_dir_file_path_, true); | 497 file_util::Delete(local_image_dir_file_path_, true); |
460 } | 498 } |
461 if (active_download_item_) { | 499 if (active_download_item_) { |
462 active_download_item_->RemoveObserver(this); | 500 active_download_item_->RemoveObserver(this); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 ImageBurnHandler* handler = new ImageBurnHandler(contents); | 651 ImageBurnHandler* handler = new ImageBurnHandler(contents); |
614 AddMessageHandler((handler)->Attach(this)); | 652 AddMessageHandler((handler)->Attach(this)); |
615 ImageBurnUIHTMLSource* html_source = new ImageBurnUIHTMLSource(); | 653 ImageBurnUIHTMLSource* html_source = new ImageBurnUIHTMLSource(); |
616 BrowserThread::PostTask( | 654 BrowserThread::PostTask( |
617 BrowserThread::IO, FROM_HERE, | 655 BrowserThread::IO, FROM_HERE, |
618 NewRunnableMethod( | 656 NewRunnableMethod( |
619 ChromeURLDataManager::GetInstance(), | 657 ChromeURLDataManager::GetInstance(), |
620 &ChromeURLDataManager::AddDataSource, | 658 &ChromeURLDataManager::AddDataSource, |
621 make_scoped_refptr(html_source))); | 659 make_scoped_refptr(html_source))); |
622 } | 660 } |
OLD | NEW |