| 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 "printing/printing_context.h" | 5 #include "printing/printing_context.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "printing/page_setup.h" | 9 #include "printing/page_setup.h" |
| 10 #include "printing/page_size_margins.h" | 10 #include "printing/page_size_margins.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 PrintingContext::Result PrintingContext::OnError() { | 40 PrintingContext::Result PrintingContext::OnError() { |
| 41 ResetSettings(); | 41 ResetSettings(); |
| 42 return abort_printing_ ? CANCEL : FAILED; | 42 return abort_printing_ ? CANCEL : FAILED; |
| 43 } | 43 } |
| 44 | 44 |
| 45 PrintingContext::Result PrintingContext::UpdatePrintSettings( | 45 PrintingContext::Result PrintingContext::UpdatePrintSettings( |
| 46 const base::DictionaryValue& job_settings, | 46 const base::DictionaryValue& job_settings, |
| 47 const PageRanges& ranges) { | 47 const PageRanges& ranges) { |
| 48 ResetSettings(); | 48 ResetSettings(); |
| 49 | 49 |
| 50 if (settings_.dpi() == 0) | |
| 51 UseDefaultSettings(); | |
| 52 | |
| 53 if (!PrintSettingsInitializer::InitSettings(job_settings, ranges, | 50 if (!PrintSettingsInitializer::InitSettings(job_settings, ranges, |
| 54 &settings_)) { | 51 &settings_)) { |
| 55 NOTREACHED(); | 52 NOTREACHED(); |
| 56 return OnError(); | 53 return OnError(); |
| 57 } | 54 } |
| 58 | 55 |
| 59 bool print_to_pdf = false; | 56 bool print_to_pdf = false; |
| 60 bool is_cloud_dialog = false; | 57 bool is_cloud_dialog = false; |
| 61 | 58 |
| 62 if (!job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || | 59 if (!job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || |
| 63 !job_settings.GetBoolean(kSettingCloudPrintDialog, &is_cloud_dialog)) { | 60 !job_settings.GetBoolean(kSettingCloudPrintDialog, &is_cloud_dialog)) { |
| 64 NOTREACHED(); | 61 NOTREACHED(); |
| 65 return OnError(); | 62 return OnError(); |
| 66 } | 63 } |
| 67 | 64 |
| 68 bool print_to_cloud = job_settings.HasKey(kSettingCloudPrintId); | 65 bool print_to_cloud = job_settings.HasKey(kSettingCloudPrintId); |
| 69 bool open_in_external_preview = | 66 bool open_in_external_preview = |
| 70 job_settings.HasKey(kSettingOpenPDFInPreview); | 67 job_settings.HasKey(kSettingOpenPDFInPreview); |
| 71 | 68 |
| 72 return UpdatePrinterSettings( | 69 return UpdatePrinterSettings( |
| 73 print_to_pdf || is_cloud_dialog || print_to_cloud, | 70 print_to_pdf || is_cloud_dialog || print_to_cloud, |
| 74 open_in_external_preview); | 71 open_in_external_preview); |
| 75 } | 72 } |
| 76 | 73 |
| 77 } // namespace printing | 74 } // namespace printing |
| OLD | NEW |