OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 24 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
25 #include "chrome/browser/tab_contents/tab_util.h" | 25 #include "chrome/browser/tab_contents/tab_util.h" |
26 #include "chrome/browser/tab_contents/web_contents.h" | 26 #include "chrome/browser/tab_contents/web_contents.h" |
27 #include "chrome/browser/views/download_shelf_view.h" | 27 #include "chrome/browser/views/download_shelf_view.h" |
28 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/l10n_util.h" | 29 #include "chrome/common/l10n_util.h" |
30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
31 #include "chrome/common/pref_service.h" | 31 #include "chrome/common/pref_service.h" |
32 #include "chrome/common/stl_util-inl.h" | 32 #include "chrome/common/stl_util-inl.h" |
33 #include "chrome/common/win_util.h" | 33 #include "chrome/common/win_util.h" |
| 34 #include "net/base/io_buffer.h" |
34 #include "net/base/mime_util.h" | 35 #include "net/base/mime_util.h" |
35 #include "net/base/net_util.h" | 36 #include "net/base/net_util.h" |
36 #include "net/url_request/url_request_context.h" | 37 #include "net/url_request/url_request_context.h" |
37 #include "webkit/glue/dom_serializer_delegate.h" | 38 #include "webkit/glue/dom_serializer_delegate.h" |
38 | 39 |
39 #include "generated_resources.h" | 40 #include "generated_resources.h" |
40 | 41 |
41 using base::Time; | 42 using base::Time; |
42 | 43 |
43 namespace { | 44 namespace { |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 | 806 |
806 std::wstring current_frame_url = UTF8ToWide(frame_url.spec()); | 807 std::wstring current_frame_url = UTF8ToWide(frame_url.spec()); |
807 SaveUrlItemMap::iterator it = in_progress_items_.find(current_frame_url); | 808 SaveUrlItemMap::iterator it = in_progress_items_.find(current_frame_url); |
808 if (it == in_progress_items_.end()) | 809 if (it == in_progress_items_.end()) |
809 return; | 810 return; |
810 SaveItem* save_item = it->second; | 811 SaveItem* save_item = it->second; |
811 DCHECK(save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM); | 812 DCHECK(save_item->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_DOM); |
812 | 813 |
813 if (!data.empty()) { | 814 if (!data.empty()) { |
814 // Prepare buffer for saving HTML data. | 815 // Prepare buffer for saving HTML data. |
815 char* new_data = static_cast<char*>(new char[data.size()]); | 816 net::IOBuffer* new_data = new net::IOBuffer(data.size()); |
816 memcpy(new_data, data.data(), data.size()); | 817 memcpy(new_data->data(), data.data(), data.size()); |
817 | 818 |
818 // Call write file functionality in file thread. | 819 // Call write file functionality in file thread. |
819 file_manager_->GetSaveLoop()->PostTask(FROM_HERE, | 820 file_manager_->GetSaveLoop()->PostTask(FROM_HERE, |
820 NewRunnableMethod(file_manager_, | 821 NewRunnableMethod(file_manager_, |
821 &SaveFileManager::UpdateSaveProgress, | 822 &SaveFileManager::UpdateSaveProgress, |
822 save_item->save_id(), | 823 save_item->save_id(), |
823 new_data, | 824 new_data, |
824 static_cast<int>(data.size()))); | 825 static_cast<int>(data.size()))); |
825 } | 826 } |
826 | 827 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 | 1094 |
1094 if (available_length > dir_path_length) { | 1095 if (available_length > dir_path_length) { |
1095 *pure_file_name = | 1096 *pure_file_name = |
1096 pure_file_name->substr(0, available_length - dir_path_length); | 1097 pure_file_name->substr(0, available_length - dir_path_length); |
1097 return true; | 1098 return true; |
1098 } else { | 1099 } else { |
1099 pure_file_name->clear(); | 1100 pure_file_name->clear(); |
1100 return false; | 1101 return false; |
1101 } | 1102 } |
1102 } | 1103 } |
OLD | NEW |