| 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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 } | 750 } |
| 751 | 751 |
| 752 // Get the relative directory name. | 752 // Get the relative directory name. |
| 753 std::wstring::size_type last_slash = saved_main_directory_path_.rfind(L'\\'); | 753 std::wstring::size_type last_slash = saved_main_directory_path_.rfind(L'\\'); |
| 754 DCHECK(last_slash != std::wstring::npos); | 754 DCHECK(last_slash != std::wstring::npos); |
| 755 std::wstring relative_dir_name = std::wstring(saved_main_directory_path_, | 755 std::wstring relative_dir_name = std::wstring(saved_main_directory_path_, |
| 756 last_slash + 1); | 756 last_slash + 1); |
| 757 | 757 |
| 758 relative_dir_name = std::wstring(L"./") + relative_dir_name + L"/"; | 758 relative_dir_name = std::wstring(L"./") + relative_dir_name + L"/"; |
| 759 | 759 |
| 760 web_contents_->GetSerializedHtmlDataForCurrentPageWithLocalLinks( | 760 web_contents_->render_view_host()-> |
| 761 saved_links, saved_file_paths, relative_dir_name); | 761 GetSerializedHtmlDataForCurrentPageWithLocalLinks( |
| 762 saved_links, saved_file_paths, relative_dir_name); |
| 762 } | 763 } |
| 763 | 764 |
| 764 // Process the serialized HTML content data of a specified web page | 765 // Process the serialized HTML content data of a specified web page |
| 765 // retrieved from render process. | 766 // retrieved from render process. |
| 766 void SavePackage::ProcessSerializedHtmlData(const GURL& frame_url, | 767 void SavePackage::OnReceivedSerializedHtmlData(const GURL& frame_url, |
| 767 const std::string& data, | 768 const std::string& data, |
| 768 int32 status) { | 769 int32 status) { |
| 769 webkit_glue::DomSerializerDelegate::PageSavingSerializationStatus flag = | 770 webkit_glue::DomSerializerDelegate::PageSavingSerializationStatus flag = |
| 770 static_cast<webkit_glue::DomSerializerDelegate::PageSavingSerializationSta
tus> | 771 static_cast<webkit_glue::DomSerializerDelegate::PageSavingSerializationSta
tus> |
| 771 (status); | 772 (status); |
| 772 // Check current state. | 773 // Check current state. |
| 773 if (wait_state_ != HTML_DATA) | 774 if (wait_state_ != HTML_DATA) |
| 774 return; | 775 return; |
| 775 | 776 |
| 776 int id = tab_id(); | 777 int id = tab_id(); |
| 777 // If the all frames are finished saving, we need to close the | 778 // If the all frames are finished saving, we need to close the |
| 778 // remaining SaveItems. | 779 // remaining SaveItems. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 } | 825 } |
| 825 | 826 |
| 826 // Ask for all savable resource links from backend, include main frame and | 827 // Ask for all savable resource links from backend, include main frame and |
| 827 // sub-frame. | 828 // sub-frame. |
| 828 void SavePackage::GetAllSavableResourceLinksForCurrentPage() { | 829 void SavePackage::GetAllSavableResourceLinksForCurrentPage() { |
| 829 if (wait_state_ != START_PROCESS) | 830 if (wait_state_ != START_PROCESS) |
| 830 return; | 831 return; |
| 831 | 832 |
| 832 wait_state_ = RESOURCES_LIST; | 833 wait_state_ = RESOURCES_LIST; |
| 833 GURL main_page_url(page_url_); | 834 GURL main_page_url(page_url_); |
| 834 web_contents_->GetAllSavableResourceLinksForCurrentPage(main_page_url); | 835 web_contents_->render_view_host()-> |
| 836 GetAllSavableResourceLinksForCurrentPage(main_page_url); |
| 835 } | 837 } |
| 836 | 838 |
| 837 // Give backend the lists which contain all resource links that have local | 839 // Give backend the lists which contain all resource links that have local |
| 838 // storage, after which, render process will serialize DOM for generating | 840 // storage, after which, render process will serialize DOM for generating |
| 839 // HTML data. | 841 // HTML data. |
| 840 void SavePackage::ProcessCurrentPageAllSavableResourceLinks( | 842 void SavePackage::OnReceivedSavableResourceLinksForCurrentPage( |
| 841 const std::vector<GURL>& resources_list, | 843 const std::vector<GURL>& resources_list, |
| 842 const std::vector<GURL>& referrers_list, | 844 const std::vector<GURL>& referrers_list, |
| 843 const std::vector<GURL>& frames_list) { | 845 const std::vector<GURL>& frames_list) { |
| 844 if (wait_state_ != RESOURCES_LIST) | 846 if (wait_state_ != RESOURCES_LIST) |
| 845 return; | 847 return; |
| 846 | 848 |
| 847 DCHECK(resources_list.size() == referrers_list.size()); | 849 DCHECK(resources_list.size() == referrers_list.size()); |
| 848 all_save_items_count_ = static_cast<int>(resources_list.size()) + | 850 all_save_items_count_ = static_cast<int>(resources_list.size()) + |
| 849 static_cast<int>(frames_list.size()); | 851 static_cast<int>(frames_list.size()); |
| 850 | 852 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 if (available_length > dir_path_length) { | 1054 if (available_length > dir_path_length) { |
| 1053 *pure_file_name = | 1055 *pure_file_name = |
| 1054 pure_file_name->substr(0, available_length - dir_path_length); | 1056 pure_file_name->substr(0, available_length - dir_path_length); |
| 1055 return true; | 1057 return true; |
| 1056 } else { | 1058 } else { |
| 1057 pure_file_name->clear(); | 1059 pure_file_name->clear(); |
| 1058 return false; | 1060 return false; |
| 1059 } | 1061 } |
| 1060 } | 1062 } |
| 1061 | 1063 |
| OLD | NEW |