Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: content/browser/download/save_package.cc

Issue 12084075: SavePackageFilePickerChromeOS should only force MHTML when saving HTML, not when saving text/image/… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r185696 Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/download/save_page_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 298
299 // Check save type and process the save page job. 299 // Check save type and process the save page job.
300 if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) { 300 if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) {
301 // Get directory 301 // Get directory
302 DCHECK(!saved_main_directory_path_.empty()); 302 DCHECK(!saved_main_directory_path_.empty());
303 GetAllSavableResourceLinksForCurrentPage(); 303 GetAllSavableResourceLinksForCurrentPage();
304 } else if (save_type_ == SAVE_PAGE_TYPE_AS_MHTML) { 304 } else if (save_type_ == SAVE_PAGE_TYPE_AS_MHTML) {
305 web_contents()->GenerateMHTML(saved_main_file_path_, base::Bind( 305 web_contents()->GenerateMHTML(saved_main_file_path_, base::Bind(
306 &SavePackage::OnMHTMLGenerated, this)); 306 &SavePackage::OnMHTMLGenerated, this));
307 } else { 307 } else {
308 DCHECK_EQ(SAVE_PAGE_TYPE_AS_ONLY_HTML, save_type_) << save_type_;
308 wait_state_ = NET_FILES; 309 wait_state_ = NET_FILES;
309 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ? 310 SaveFileCreateInfo::SaveFileSource save_source = page_url_.SchemeIsFile() ?
310 SaveFileCreateInfo::SAVE_FILE_FROM_FILE : 311 SaveFileCreateInfo::SAVE_FILE_FROM_FILE :
311 SaveFileCreateInfo::SAVE_FILE_FROM_NET; 312 SaveFileCreateInfo::SAVE_FILE_FROM_NET;
312 SaveItem* save_item = new SaveItem(page_url_, 313 SaveItem* save_item = new SaveItem(page_url_,
313 Referrer(), 314 Referrer(),
314 this, 315 this,
315 save_source); 316 save_source);
316 // Add this item to waiting list. 317 // Add this item to waiting list.
317 waiting_item_queue_.push(save_item); 318 waiting_item_queue_.push(save_item);
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 suggested_path, 1355 suggested_path,
1355 default_extension, 1356 default_extension,
1356 can_save_as_complete, 1357 can_save_as_complete,
1357 base::Bind(&SavePackage::OnPathPicked, AsWeakPtr())); 1358 base::Bind(&SavePackage::OnPathPicked, AsWeakPtr()));
1358 } 1359 }
1359 1360
1360 void SavePackage::OnPathPicked( 1361 void SavePackage::OnPathPicked(
1361 const base::FilePath& final_name, 1362 const base::FilePath& final_name,
1362 SavePageType type, 1363 SavePageType type,
1363 const SavePackageDownloadCreatedCallback& download_created_callback) { 1364 const SavePackageDownloadCreatedCallback& download_created_callback) {
1365 DCHECK((type == SAVE_PAGE_TYPE_AS_ONLY_HTML) ||
1366 (type == SAVE_PAGE_TYPE_AS_MHTML) ||
1367 (type == SAVE_PAGE_TYPE_AS_COMPLETE_HTML)) << type;
1364 // Ensure the filename is safe. 1368 // Ensure the filename is safe.
1365 saved_main_file_path_ = final_name; 1369 saved_main_file_path_ = final_name;
1366 // TODO(asanka): This call may block on IO and shouldn't be made 1370 // TODO(asanka): This call may block on IO and shouldn't be made
1367 // from the UI thread. See http://crbug.com/61827. 1371 // from the UI thread. See http://crbug.com/61827.
1368 net::GenerateSafeFileName(web_contents()->GetContentsMimeType(), false, 1372 net::GenerateSafeFileName(web_contents()->GetContentsMimeType(), false,
1369 &saved_main_file_path_); 1373 &saved_main_file_path_);
1370 1374
1371 saved_main_directory_path_ = saved_main_file_path_.DirName(); 1375 saved_main_directory_path_ = saved_main_file_path_.DirName();
1372 save_type_ = type; 1376 save_type_ = type;
1373 if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) { 1377 if (save_type_ == SAVE_PAGE_TYPE_AS_COMPLETE_HTML) {
(...skipping 21 matching lines...) Expand all
1395 1399
1396 void SavePackage::FinalizeDownloadEntry() { 1400 void SavePackage::FinalizeDownloadEntry() {
1397 DCHECK(download_); 1401 DCHECK(download_);
1398 DCHECK(download_manager_); 1402 DCHECK(download_manager_);
1399 1403
1400 download_manager_->OnSavePackageSuccessfullyFinished(download_); 1404 download_manager_->OnSavePackageSuccessfullyFinished(download_);
1401 StopObservation(); 1405 StopObservation();
1402 } 1406 }
1403 1407
1404 } // namespace content 1408 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/download/save_page_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698