Chromium Code Reviews| 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 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| 1031 | 1031 |
| 1032 base::i18n::ReplaceIllegalCharactersInPath(&print_job_title, '_'); | 1032 base::i18n::ReplaceIllegalCharactersInPath(&print_job_title, '_'); |
| 1033 base::FilePath default_filename(print_job_title); | 1033 // Take at most 251 characters - need 4 for the extension and max length |
|
Lei Zhang
2017/04/05 20:06:07
We may want to use PATH_MAX instead. On Windows th
| |
| 1034 // on most platforms is 255. | |
| 1035 base::FilePath default_filename(print_job_title.substr(0, 251)); | |
| 1034 default_filename = | 1036 default_filename = |
| 1035 default_filename.ReplaceExtension(FILE_PATH_LITERAL("pdf")); | 1037 default_filename.ReplaceExtension(FILE_PATH_LITERAL("pdf")); |
| 1036 | 1038 |
| 1037 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 1039 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 1038 bool prompt_user = !cmdline->HasSwitch(switches::kKioskModePrinting); | 1040 bool prompt_user = !cmdline->HasSwitch(switches::kKioskModePrinting); |
| 1039 SelectFile(default_filename, prompt_user); | 1041 SelectFile(default_filename, prompt_user); |
| 1040 } | 1042 } |
| 1041 } | 1043 } |
| 1042 | 1044 |
| 1043 void PrintPreviewHandler::HandleHidePreview(const base::ListValue* /*args*/) { | 1045 void PrintPreviewHandler::HandleHidePreview(const base::ListValue* /*args*/) { |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1794 | 1796 |
| 1795 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1797 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
| 1796 if (gaia_cookie_manager_service_) | 1798 if (gaia_cookie_manager_service_) |
| 1797 gaia_cookie_manager_service_->RemoveObserver(this); | 1799 gaia_cookie_manager_service_->RemoveObserver(this); |
| 1798 } | 1800 } |
| 1799 | 1801 |
| 1800 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1802 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
| 1801 const base::Closure& closure) { | 1803 const base::Closure& closure) { |
| 1802 pdf_file_saved_closure_ = closure; | 1804 pdf_file_saved_closure_ = closure; |
| 1803 } | 1805 } |
| OLD | NEW |