| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/download/save_package.h" | 5 #include "chrome/browser/download/save_package.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/download/save_file_manager.h" | 21 #include "chrome/browser/download/save_file_manager.h" |
| 22 #include "chrome/browser/download/save_item.h" | 22 #include "chrome/browser/download/save_item.h" |
| 23 #include "chrome/browser/profile.h" | 23 #include "chrome/browser/profile.h" |
| 24 #include "chrome/browser/renderer_host/render_process_host.h" | 24 #include "chrome/browser/renderer_host/render_process_host.h" |
| 25 #include "chrome/browser/renderer_host/render_view_host.h" | 25 #include "chrome/browser/renderer_host/render_view_host.h" |
| 26 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 26 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 27 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 27 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 28 #include "chrome/browser/tab_contents/tab_contents.h" | 28 #include "chrome/browser/tab_contents/tab_contents.h" |
| 29 #include "chrome/browser/tab_contents/tab_util.h" | 29 #include "chrome/browser/tab_contents/tab_util.h" |
| 30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 31 #include "chrome/common/notification_service.h" |
| 32 #include "chrome/common/notification_type.h" |
| 31 #include "chrome/common/platform_util.h" | 33 #include "chrome/common/platform_util.h" |
| 32 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 33 #include "chrome/common/pref_service.h" | 35 #include "chrome/common/pref_service.h" |
| 34 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
| 35 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
| 36 #include "net/base/io_buffer.h" | 38 #include "net/base/io_buffer.h" |
| 37 #include "net/base/mime_util.h" | 39 #include "net/base/mime_util.h" |
| 38 #include "net/base/net_util.h" | 40 #include "net/base/net_util.h" |
| 39 #include "net/url_request/url_request_context.h" | 41 #include "net/url_request/url_request_context.h" |
| 40 #include "webkit/glue/dom_serializer_delegate.h" | 42 #include "webkit/glue/dom_serializer_delegate.h" |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 for (SaveUrlItemMap::iterator it = saved_failed_items_.begin(); | 596 for (SaveUrlItemMap::iterator it = saved_failed_items_.begin(); |
| 595 it != saved_failed_items_.end(); ++it) | 597 it != saved_failed_items_.end(); ++it) |
| 596 save_ids.push_back(it->second->save_id()); | 598 save_ids.push_back(it->second->save_id()); |
| 597 | 599 |
| 598 file_manager_->GetSaveLoop()->PostTask(FROM_HERE, | 600 file_manager_->GetSaveLoop()->PostTask(FROM_HERE, |
| 599 NewRunnableMethod(file_manager_, | 601 NewRunnableMethod(file_manager_, |
| 600 &SaveFileManager::RemoveSavedFileFromFileMap, | 602 &SaveFileManager::RemoveSavedFileFromFileMap, |
| 601 save_ids)); | 603 save_ids)); |
| 602 | 604 |
| 603 download_->Finished(all_save_items_count_); | 605 download_->Finished(all_save_items_count_); |
| 606 |
| 607 NotificationService::current()->Notify( |
| 608 NotificationType::SAVE_PACKAGE_SUCCESSFULLY_FINISHED, |
| 609 Source<SavePackage>(this), |
| 610 Details<GURL>(&page_url_)); |
| 604 } | 611 } |
| 605 | 612 |
| 606 // Called for updating end state. | 613 // Called for updating end state. |
| 607 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) { | 614 void SavePackage::SaveFinished(int32 save_id, int64 size, bool is_success) { |
| 608 // Because we might have canceled this saving job before, | 615 // Because we might have canceled this saving job before, |
| 609 // so we might not find corresponding SaveItem. Just ignore it. | 616 // so we might not find corresponding SaveItem. Just ignore it. |
| 610 SaveItem* save_item = LookupItemInProcessBySaveId(save_id); | 617 SaveItem* save_item = LookupItemInProcessBySaveId(save_id); |
| 611 if (!save_item) | 618 if (!save_item) |
| 612 return; | 619 return; |
| 613 | 620 |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 int index, void* params) { | 1200 int index, void* params) { |
| 1194 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); | 1201 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); |
| 1195 ContinueSave(save_params, path, index); | 1202 ContinueSave(save_params, path, index); |
| 1196 delete save_params; | 1203 delete save_params; |
| 1197 } | 1204 } |
| 1198 | 1205 |
| 1199 void SavePackage::FileSelectionCanceled(void* params) { | 1206 void SavePackage::FileSelectionCanceled(void* params) { |
| 1200 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); | 1207 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); |
| 1201 delete save_params; | 1208 delete save_params; |
| 1202 } | 1209 } |
| OLD | NEW |