| OLD | NEW |
| 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 "chrome/browser/ui/webui/print_preview/print_preview_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( | 1383 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( |
| 1384 preview_web_contents()->GetBrowserContext()); | 1384 preview_web_contents()->GetBrowserContext()); |
| 1385 base::FilePath file_path = download_prefs->SaveFilePath(); | 1385 base::FilePath file_path = download_prefs->SaveFilePath(); |
| 1386 printing::StickySettings* sticky_settings = GetStickySettings(); | 1386 printing::StickySettings* sticky_settings = GetStickySettings(); |
| 1387 sticky_settings->SaveInPrefs(Profile::FromBrowserContext( | 1387 sticky_settings->SaveInPrefs(Profile::FromBrowserContext( |
| 1388 preview_web_contents()->GetBrowserContext())->GetPrefs()); | 1388 preview_web_contents()->GetBrowserContext())->GetPrefs()); |
| 1389 // Handle the no prompting case. Like the dialog prompt, this function | 1389 // Handle the no prompting case. Like the dialog prompt, this function |
| 1390 // returns and eventually FileSelected() gets called. | 1390 // returns and eventually FileSelected() gets called. |
| 1391 if (!prompt_user) { | 1391 if (!prompt_user) { |
| 1392 base::PostTaskWithTraitsAndReplyWithResult( | 1392 base::PostTaskWithTraitsAndReplyWithResult( |
| 1393 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 1393 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 1394 base::TaskPriority::BACKGROUND), | |
| 1395 base::Bind(&GetUniquePath, | 1394 base::Bind(&GetUniquePath, |
| 1396 download_prefs->SaveFilePath().Append(default_filename)), | 1395 download_prefs->SaveFilePath().Append(default_filename)), |
| 1397 base::Bind(&PrintPreviewHandler::OnGotUniqueFileName, | 1396 base::Bind(&PrintPreviewHandler::OnGotUniqueFileName, |
| 1398 weak_factory_.GetWeakPtr())); | 1397 weak_factory_.GetWeakPtr())); |
| 1399 return; | 1398 return; |
| 1400 } | 1399 } |
| 1401 | 1400 |
| 1402 // Otherwise prompt the user. | 1401 // Otherwise prompt the user. |
| 1403 ui::SelectFileDialog::FileTypeInfo file_type_info; | 1402 ui::SelectFileDialog::FileTypeInfo file_type_info; |
| 1404 file_type_info.extensions.resize(1); | 1403 file_type_info.extensions.resize(1); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 | 1451 |
| 1453 void PrintPreviewHandler::PostPrintToPdfTask() { | 1452 void PrintPreviewHandler::PostPrintToPdfTask() { |
| 1454 scoped_refptr<base::RefCountedBytes> data; | 1453 scoped_refptr<base::RefCountedBytes> data; |
| 1455 base::string16 title; | 1454 base::string16 title; |
| 1456 if (!GetPreviewDataAndTitle(&data, &title)) { | 1455 if (!GetPreviewDataAndTitle(&data, &title)) { |
| 1457 NOTREACHED() << "Preview data was checked before file dialog."; | 1456 NOTREACHED() << "Preview data was checked before file dialog."; |
| 1458 return; | 1457 return; |
| 1459 } | 1458 } |
| 1460 | 1459 |
| 1461 base::PostTaskWithTraits( | 1460 base::PostTaskWithTraits( |
| 1462 FROM_HERE, | 1461 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 1463 base::TaskTraits().MayBlock().WithPriority( | |
| 1464 base::TaskPriority::BACKGROUND), | |
| 1465 base::BindOnce(&PrintToPdfCallback, data, print_to_pdf_path_, | 1462 base::BindOnce(&PrintToPdfCallback, data, print_to_pdf_path_, |
| 1466 pdf_file_saved_closure_)); | 1463 pdf_file_saved_closure_)); |
| 1467 print_to_pdf_path_.clear(); | 1464 print_to_pdf_path_.clear(); |
| 1468 ClosePreviewDialog(); | 1465 ClosePreviewDialog(); |
| 1469 } | 1466 } |
| 1470 | 1467 |
| 1471 void PrintPreviewHandler::FileSelectionCanceled(void* params) { | 1468 void PrintPreviewHandler::FileSelectionCanceled(void* params) { |
| 1472 print_preview_ui()->OnFileSelectionCancelled(); | 1469 print_preview_ui()->OnFileSelectionCancelled(); |
| 1473 } | 1470 } |
| 1474 | 1471 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 | 1776 |
| 1780 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1777 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
| 1781 if (gaia_cookie_manager_service_) | 1778 if (gaia_cookie_manager_service_) |
| 1782 gaia_cookie_manager_service_->RemoveObserver(this); | 1779 gaia_cookie_manager_service_->RemoveObserver(this); |
| 1783 } | 1780 } |
| 1784 | 1781 |
| 1785 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1782 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
| 1786 const base::Closure& closure) { | 1783 const base::Closure& closure) { |
| 1787 pdf_file_saved_closure_ = closure; | 1784 pdf_file_saved_closure_ = closure; |
| 1788 } | 1785 } |
| OLD | NEW |