| 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/download/save_package.h" | 5 #include "chrome/browser/download/save_package.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "chrome/browser/renderer_host/render_view_host.h" | 37 #include "chrome/browser/renderer_host/render_view_host.h" |
| 38 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 38 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 39 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 39 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 40 #include "chrome/browser/tab_contents/tab_contents.h" | 40 #include "chrome/browser/tab_contents/tab_contents.h" |
| 41 #include "chrome/browser/tab_contents/tab_util.h" | 41 #include "chrome/browser/tab_contents/tab_util.h" |
| 42 #include "chrome/common/chrome_paths.h" | 42 #include "chrome/common/chrome_paths.h" |
| 43 #include "chrome/common/net/url_request_context_getter.h" | 43 #include "chrome/common/net/url_request_context_getter.h" |
| 44 #include "chrome/common/notification_service.h" | 44 #include "chrome/common/notification_service.h" |
| 45 #include "chrome/common/notification_type.h" | 45 #include "chrome/common/notification_type.h" |
| 46 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
| 47 #include "chrome/common/render_messages.h" |
| 47 #include "chrome/common/url_constants.h" | 48 #include "chrome/common/url_constants.h" |
| 48 #include "grit/generated_resources.h" | 49 #include "grit/generated_resources.h" |
| 49 #include "net/base/io_buffer.h" | 50 #include "net/base/io_buffer.h" |
| 50 #include "net/base/mime_util.h" | 51 #include "net/base/mime_util.h" |
| 51 #include "net/base/net_util.h" | 52 #include "net/base/net_util.h" |
| 52 #include "net/url_request/url_request_context.h" | 53 #include "net/url_request/url_request_context.h" |
| 53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClie
nt.h" | 54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializerClie
nt.h" |
| 54 #include "ui/base/l10n/l10n_util.h" | 55 #include "ui/base/l10n/l10n_util.h" |
| 55 | 56 |
| 56 using base::Time; | 57 using base::Time; |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 // Save as HTML only. | 893 // Save as HTML only. |
| 893 DCHECK(wait_state_ == NET_FILES); | 894 DCHECK(wait_state_ == NET_FILES); |
| 894 DCHECK(save_type_ == SAVE_AS_ONLY_HTML); | 895 DCHECK(save_type_ == SAVE_AS_ONLY_HTML); |
| 895 if (waiting_item_queue_.size()) { | 896 if (waiting_item_queue_.size()) { |
| 896 DCHECK(all_save_items_count_ == waiting_item_queue_.size()); | 897 DCHECK(all_save_items_count_ == waiting_item_queue_.size()); |
| 897 SaveNextFile(false); | 898 SaveNextFile(false); |
| 898 } | 899 } |
| 899 } | 900 } |
| 900 } | 901 } |
| 901 | 902 |
| 903 bool SavePackage::OnMessageReceived(const IPC::Message& message) { |
| 904 bool handled = true; |
| 905 IPC_BEGIN_MESSAGE_MAP(SavePackage, message) |
| 906 IPC_MESSAGE_HANDLER(ViewHostMsg_SendCurrentPageAllSavableResourceLinks, |
| 907 OnReceivedSavableResourceLinksForCurrentPage) |
| 908 IPC_MESSAGE_HANDLER(ViewHostMsg_SendSerializedHtmlData, |
| 909 OnReceivedSerializedHtmlData) |
| 910 IPC_MESSAGE_UNHANDLED(handled = false) |
| 911 IPC_END_MESSAGE_MAP() |
| 912 return handled; |
| 913 } |
| 914 |
| 902 // After finishing all SaveItems which need to get data from net. | 915 // After finishing all SaveItems which need to get data from net. |
| 903 // We collect all URLs which have local storage and send the | 916 // We collect all URLs which have local storage and send the |
| 904 // map:(originalURL:currentLocalPath) to render process (backend). | 917 // map:(originalURL:currentLocalPath) to render process (backend). |
| 905 // Then render process will serialize DOM and send data to us. | 918 // Then render process will serialize DOM and send data to us. |
| 906 void SavePackage::GetSerializedHtmlDataForCurrentPageWithLocalLinks() { | 919 void SavePackage::GetSerializedHtmlDataForCurrentPageWithLocalLinks() { |
| 907 if (wait_state_ != HTML_DATA) | 920 if (wait_state_ != HTML_DATA) |
| 908 return; | 921 return; |
| 909 std::vector<GURL> saved_links; | 922 std::vector<GURL> saved_links; |
| 910 std::vector<FilePath> saved_file_paths; | 923 std::vector<FilePath> saved_file_paths; |
| 911 int successful_started_items_count = 0; | 924 int successful_started_items_count = 0; |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 } | 1395 } |
| 1383 | 1396 |
| 1384 // SelectFileDialog::Listener interface. | 1397 // SelectFileDialog::Listener interface. |
| 1385 void SavePackage::FileSelected(const FilePath& path, | 1398 void SavePackage::FileSelected(const FilePath& path, |
| 1386 int index, void* params) { | 1399 int index, void* params) { |
| 1387 ContinueSave(path, index); | 1400 ContinueSave(path, index); |
| 1388 } | 1401 } |
| 1389 | 1402 |
| 1390 void SavePackage::FileSelectionCanceled(void* params) { | 1403 void SavePackage::FileSelectionCanceled(void* params) { |
| 1391 } | 1404 } |
| OLD | NEW |