| 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/values.h" | 8 #include "base/values.h" |
| 9 #include "printing/print_job_constants.h" |
| 8 | 10 |
| 9 namespace printing { | 11 namespace printing { |
| 10 | 12 |
| 11 PrintingContext::PrintingContext(const std::string& app_locale) | 13 PrintingContext::PrintingContext(const std::string& app_locale) |
| 12 : dialog_box_dismissed_(false), | 14 : dialog_box_dismissed_(false), |
| 13 in_print_job_(false), | 15 in_print_job_(false), |
| 14 abort_printing_(false), | 16 abort_printing_(false), |
| 15 app_locale_(app_locale) { | 17 app_locale_(app_locale) { |
| 16 } | 18 } |
| 17 | 19 |
| 18 PrintingContext::~PrintingContext() { | 20 PrintingContext::~PrintingContext() { |
| 19 } | 21 } |
| 20 | 22 |
| 21 void PrintingContext::ResetSettings() { | 23 void PrintingContext::ResetSettings() { |
| 22 ReleaseContext(); | 24 ReleaseContext(); |
| 23 | 25 |
| 24 settings_.Clear(); | 26 settings_.Clear(); |
| 25 | 27 |
| 26 in_print_job_ = false; | 28 in_print_job_ = false; |
| 27 dialog_box_dismissed_ = false; | 29 dialog_box_dismissed_ = false; |
| 28 abort_printing_ = false; | 30 abort_printing_ = false; |
| 29 } | 31 } |
| 30 | 32 |
| 31 PrintingContext::Result PrintingContext::OnError() { | 33 PrintingContext::Result PrintingContext::OnError() { |
| 32 ResetSettings(); | 34 ResetSettings(); |
| 33 return abort_printing_ ? CANCEL : FAILED; | 35 return abort_printing_ ? CANCEL : FAILED; |
| 34 } | 36 } |
| 35 | 37 |
| 38 void PrintingContext::GetHeaderFooterInfo( |
| 39 const base::DictionaryValue& settings, |
| 40 base::DictionaryValue* header_footer_info) { |
| 41 bool display_header_footer; |
| 42 if (!settings.GetBoolean(printing::kSettingHeaderFooterEnabled, |
| 43 &display_header_footer)) { |
| 44 NOTREACHED(); |
| 45 } |
| 46 header_footer_info->SetBoolean(printing::kSettingHeaderFooterEnabled, |
| 47 display_header_footer); |
| 48 if (display_header_footer) { |
| 49 string16 title; |
| 50 std::string url; |
| 51 if (!settings.GetString(printing::kSettingHeaderFooterTitle, &title) || |
| 52 !settings.GetString(printing::kSettingHeaderFooterURL, &url)) { |
| 53 NOTREACHED(); |
| 54 } |
| 55 header_footer_info->SetString(printing::kSettingHeaderFooterURL, url); |
| 56 header_footer_info->SetString(printing::kSettingHeaderFooterTitle, title); |
| 57 } |
| 58 } |
| 59 |
| 36 } // namespace printing | 60 } // namespace printing |
| OLD | NEW |