| 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 16 matching lines...) Expand all Loading... |
| 27 #include "base/strings/string_number_conversions.h" | 27 #include "base/strings/string_number_conversions.h" |
| 28 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" |
| 29 #include "base/strings/utf_string_conversions.h" | 29 #include "base/strings/utf_string_conversions.h" |
| 30 #include "base/task_scheduler/post_task.h" | 30 #include "base/task_scheduler/post_task.h" |
| 31 #include "base/threading/thread.h" | 31 #include "base/threading/thread.h" |
| 32 #include "base/values.h" | 32 #include "base/values.h" |
| 33 #include "build/build_config.h" | 33 #include "build/build_config.h" |
| 34 #include "chrome/browser/app_mode/app_mode_utils.h" | 34 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 35 #include "chrome/browser/browser_process.h" | 35 #include "chrome/browser/browser_process.h" |
| 36 #include "chrome/browser/download/download_prefs.h" | 36 #include "chrome/browser/download/download_prefs.h" |
| 37 #include "chrome/browser/platform_util.h" | |
| 38 #include "chrome/browser/printing/print_dialog_cloud.h" | 37 #include "chrome/browser/printing/print_dialog_cloud.h" |
| 39 #include "chrome/browser/printing/print_error_dialog.h" | 38 #include "chrome/browser/printing/print_error_dialog.h" |
| 40 #include "chrome/browser/printing/print_job_manager.h" | 39 #include "chrome/browser/printing/print_job_manager.h" |
| 41 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 40 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 42 #include "chrome/browser/printing/print_view_manager.h" | 41 #include "chrome/browser/printing/print_view_manager.h" |
| 43 #include "chrome/browser/printing/printer_manager_dialog.h" | 42 #include "chrome/browser/printing/printer_manager_dialog.h" |
| 44 #include "chrome/browser/profiles/profile.h" | 43 #include "chrome/browser/profiles/profile.h" |
| 45 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" | 44 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" |
| 46 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 45 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 47 #include "chrome/browser/signin/signin_manager_factory.h" | 46 #include "chrome/browser/signin/signin_manager_factory.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #include "content/public/browser/web_ui.h" | 78 #include "content/public/browser/web_ui.h" |
| 80 #include "google_apis/gaia/oauth2_token_service.h" | 79 #include "google_apis/gaia/oauth2_token_service.h" |
| 81 #include "net/base/url_util.h" | 80 #include "net/base/url_util.h" |
| 82 #include "printing/backend/print_backend.h" | 81 #include "printing/backend/print_backend.h" |
| 83 #include "printing/backend/print_backend_consts.h" | 82 #include "printing/backend/print_backend_consts.h" |
| 84 #include "printing/features/features.h" | 83 #include "printing/features/features.h" |
| 85 #include "printing/print_settings.h" | 84 #include "printing/print_settings.h" |
| 86 #include "printing/printing_context.h" | 85 #include "printing/printing_context.h" |
| 87 #include "printing/units.h" | 86 #include "printing/units.h" |
| 88 #include "third_party/icu/source/i18n/unicode/ulocdata.h" | 87 #include "third_party/icu/source/i18n/unicode/ulocdata.h" |
| 88 #include "ui/gfx/view_util.h" |
| 89 | 89 |
| 90 #if defined(OS_CHROMEOS) | 90 #if defined(OS_CHROMEOS) |
| 91 #include "chrome/browser/chromeos/printing/printers_manager.h" | 91 #include "chrome/browser/chromeos/printing/printers_manager.h" |
| 92 #include "chrome/browser/chromeos/printing/printers_manager_factory.h" | 92 #include "chrome/browser/chromeos/printing/printers_manager_factory.h" |
| 93 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" | 93 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
| 94 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" | 94 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" |
| 95 #include "chrome/common/url_constants.h" | 95 #include "chrome/common/url_constants.h" |
| 96 #include "chromeos/printing/printer_configuration.h" | 96 #include "chromeos/printing/printer_configuration.h" |
| 97 #endif | 97 #endif |
| 98 | 98 |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 NOTREACHED(); | 1009 NOTREACHED(); |
| 1010 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) | 1010 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 1011 } | 1011 } |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 void PrintPreviewHandler::PrintToPdf() { | 1014 void PrintPreviewHandler::PrintToPdf() { |
| 1015 if (!print_to_pdf_path_.empty()) { | 1015 if (!print_to_pdf_path_.empty()) { |
| 1016 // User has already selected a path, no need to show the dialog again. | 1016 // User has already selected a path, no need to show the dialog again. |
| 1017 PostPrintToPdfTask(); | 1017 PostPrintToPdfTask(); |
| 1018 } else if (!select_file_dialog_.get() || | 1018 } else if (!select_file_dialog_.get() || |
| 1019 !select_file_dialog_->IsRunning(platform_util::GetTopLevel( | 1019 !select_file_dialog_->IsRunning( |
| 1020 preview_web_contents()->GetNativeView()))) { | 1020 gfx::GetTopLevel(preview_web_contents()->GetNativeView()))) { |
| 1021 // Pre-populating select file dialog with print job title. | 1021 // Pre-populating select file dialog with print job title. |
| 1022 base::string16 print_job_title_utf16 = | 1022 base::string16 print_job_title_utf16 = |
| 1023 print_preview_ui()->initiator_title(); | 1023 print_preview_ui()->initiator_title(); |
| 1024 | 1024 |
| 1025 #if defined(OS_WIN) | 1025 #if defined(OS_WIN) |
| 1026 base::FilePath::StringType print_job_title(print_job_title_utf16); | 1026 base::FilePath::StringType print_job_title(print_job_title_utf16); |
| 1027 #elif defined(OS_POSIX) | 1027 #elif defined(OS_POSIX) |
| 1028 base::FilePath::StringType print_job_title = | 1028 base::FilePath::StringType print_job_title = |
| 1029 base::UTF16ToUTF8(print_job_title_utf16); | 1029 base::UTF16ToUTF8(print_job_title_utf16); |
| 1030 #endif | 1030 #endif |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 } | 1415 } |
| 1416 | 1416 |
| 1417 // Otherwise prompt the user. | 1417 // Otherwise prompt the user. |
| 1418 ui::SelectFileDialog::FileTypeInfo file_type_info; | 1418 ui::SelectFileDialog::FileTypeInfo file_type_info; |
| 1419 file_type_info.extensions.resize(1); | 1419 file_type_info.extensions.resize(1); |
| 1420 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("pdf")); | 1420 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("pdf")); |
| 1421 | 1421 |
| 1422 select_file_dialog_ = | 1422 select_file_dialog_ = |
| 1423 ui::SelectFileDialog::Create(this, nullptr /*policy already checked*/); | 1423 ui::SelectFileDialog::Create(this, nullptr /*policy already checked*/); |
| 1424 select_file_dialog_->SelectFile( | 1424 select_file_dialog_->SelectFile( |
| 1425 ui::SelectFileDialog::SELECT_SAVEAS_FILE, | 1425 ui::SelectFileDialog::SELECT_SAVEAS_FILE, base::string16(), |
| 1426 base::string16(), | 1426 download_prefs->SaveFilePath().Append(default_filename), &file_type_info, |
| 1427 download_prefs->SaveFilePath().Append(default_filename), | 1427 0, base::FilePath::StringType(), |
| 1428 &file_type_info, | 1428 gfx::GetTopLevel(preview_web_contents()->GetNativeView()), NULL); |
| 1429 0, | |
| 1430 base::FilePath::StringType(), | |
| 1431 platform_util::GetTopLevel(preview_web_contents()->GetNativeView()), | |
| 1432 NULL); | |
| 1433 } | 1429 } |
| 1434 | 1430 |
| 1435 void PrintPreviewHandler::OnGotUniqueFileName(const base::FilePath& path) { | 1431 void PrintPreviewHandler::OnGotUniqueFileName(const base::FilePath& path) { |
| 1436 FileSelected(path, 0, nullptr); | 1432 FileSelected(path, 0, nullptr); |
| 1437 } | 1433 } |
| 1438 | 1434 |
| 1439 void PrintPreviewHandler::OnPrintPreviewFailed() { | 1435 void PrintPreviewHandler::OnPrintPreviewFailed() { |
| 1440 if (reported_failed_preview_) | 1436 if (reported_failed_preview_) |
| 1441 return; | 1437 return; |
| 1442 reported_failed_preview_ = true; | 1438 reported_failed_preview_ = true; |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 | 1794 |
| 1799 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1795 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
| 1800 if (gaia_cookie_manager_service_) | 1796 if (gaia_cookie_manager_service_) |
| 1801 gaia_cookie_manager_service_->RemoveObserver(this); | 1797 gaia_cookie_manager_service_->RemoveObserver(this); |
| 1802 } | 1798 } |
| 1803 | 1799 |
| 1804 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1800 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
| 1805 const base::Closure& closure) { | 1801 const base::Closure& closure) { |
| 1806 pdf_file_saved_closure_ = closure; | 1802 pdf_file_saved_closure_ = closure; |
| 1807 } | 1803 } |
| OLD | NEW |