OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/download/save_package.h" | 5 #include "content/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 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/download/download_item.h" | 22 #include "chrome/browser/download/download_item.h" |
23 #include "chrome/browser/download/download_item_model.h" | 23 #include "chrome/browser/download/download_item_model.h" |
24 #include "chrome/browser/download/download_manager.h" | 24 #include "chrome/browser/download/download_manager.h" |
25 #include "chrome/browser/download/download_util.h" | 25 #include "chrome/browser/download/download_util.h" |
26 #include "chrome/browser/net/url_fixer_upper.h" | 26 #include "chrome/browser/net/url_fixer_upper.h" |
27 #include "chrome/browser/platform_util.h" | 27 #include "chrome/browser/platform_util.h" |
28 #include "chrome/browser/prefs/pref_member.h" | 28 #include "chrome/browser/prefs/pref_member.h" |
29 #include "chrome/browser/prefs/pref_service.h" | 29 #include "chrome/browser/prefs/pref_service.h" |
30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/browser/tab_contents/tab_util.h" | 31 #include "chrome/browser/tab_contents/tab_util.h" |
32 #include "chrome/browser/ui/download/download_tab_helper.h" | |
33 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 32 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
34 #include "chrome/common/chrome_notification_types.h" | 33 #include "chrome/common/chrome_notification_types.h" |
35 #include "chrome/common/chrome_paths.h" | 34 #include "chrome/common/chrome_paths.h" |
36 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
37 #include "chrome/common/render_messages.h" | 36 #include "chrome/common/render_messages.h" |
38 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
39 #include "content/browser/browser_thread.h" | 38 #include "content/browser/browser_thread.h" |
40 #include "content/browser/content_browser_client.h" | 39 #include "content/browser/content_browser_client.h" |
41 #include "content/browser/download/save_file.h" | 40 #include "content/browser/download/save_file.h" |
42 #include "content/browser/download/save_file_manager.h" | 41 #include "content/browser/download/save_file_manager.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 tab_contents()->profile()->GetDownloadManager(); | 281 tab_contents()->profile()->GetDownloadManager(); |
283 download_ = new DownloadItem(download_manager, | 282 download_ = new DownloadItem(download_manager, |
284 saved_main_file_path_, | 283 saved_main_file_path_, |
285 page_url_, | 284 page_url_, |
286 profile->IsOffTheRecord()); | 285 profile->IsOffTheRecord()); |
287 | 286 |
288 // Transfer the ownership to the download manager. We need the DownloadItem | 287 // Transfer the ownership to the download manager. We need the DownloadItem |
289 // to be alive as long as the Profile is alive. | 288 // to be alive as long as the Profile is alive. |
290 download_manager->SavePageAsDownloadStarted(download_); | 289 download_manager->SavePageAsDownloadStarted(download_); |
291 | 290 |
292 wrapper_->download_tab_helper()->OnStartDownload(download_); | 291 tab_contents()->OnStartDownload(download_); |
293 | 292 |
294 // Check save type and process the save page job. | 293 // Check save type and process the save page job. |
295 if (save_type_ == SAVE_AS_COMPLETE_HTML) { | 294 if (save_type_ == SAVE_AS_COMPLETE_HTML) { |
296 // Get directory | 295 // Get directory |
297 DCHECK(!saved_main_directory_path_.empty()); | 296 DCHECK(!saved_main_directory_path_.empty()); |
298 GetAllSavableResourceLinksForCurrentPage(); | 297 GetAllSavableResourceLinksForCurrentPage(); |
299 } else { | 298 } else { |
300 wait_state_ = NET_FILES; | 299 wait_state_ = NET_FILES; |
301 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? | 300 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? |
302 SaveFileCreateInfo::SAVE_FILE_FROM_FILE : | 301 SaveFileCreateInfo::SAVE_FILE_FROM_FILE : |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 bool SavePackage::IsSavableContents(const std::string& contents_mime_type) { | 1329 bool SavePackage::IsSavableContents(const std::string& contents_mime_type) { |
1331 // WebKit creates Document object when MIME type is application/xhtml+xml, | 1330 // WebKit creates Document object when MIME type is application/xhtml+xml, |
1332 // so we also support this MIME type. | 1331 // so we also support this MIME type. |
1333 return contents_mime_type == "text/html" || | 1332 return contents_mime_type == "text/html" || |
1334 contents_mime_type == "text/xml" || | 1333 contents_mime_type == "text/xml" || |
1335 contents_mime_type == "application/xhtml+xml" || | 1334 contents_mime_type == "application/xhtml+xml" || |
1336 contents_mime_type == "text/plain" || | 1335 contents_mime_type == "text/plain" || |
1337 contents_mime_type == "text/css" || | 1336 contents_mime_type == "text/css" || |
1338 net::IsSupportedJavascriptMimeType(contents_mime_type.c_str()); | 1337 net::IsSupportedJavascriptMimeType(contents_mime_type.c_str()); |
1339 } | 1338 } |
OLD | NEW |