OLD | NEW |
---|---|
1 // Copyright (c) 2010 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/values.h" | |
8 #include "printing/print_job_constants.h" | |
9 | |
7 namespace printing { | 10 namespace printing { |
8 | 11 |
9 PrintingContext::PrintingContext(const std::string& app_locale) | 12 PrintingContext::PrintingContext(const std::string& app_locale) |
10 : dialog_box_dismissed_(false), | 13 : dialog_box_dismissed_(false), |
11 in_print_job_(false), | 14 in_print_job_(false), |
12 abort_printing_(false), | 15 abort_printing_(false), |
13 app_locale_(app_locale) { | 16 app_locale_(app_locale) { |
14 } | 17 } |
15 | 18 |
16 PrintingContext::~PrintingContext() { | 19 PrintingContext::~PrintingContext() { |
17 } | 20 } |
18 | 21 |
19 void PrintingContext::ResetSettings() { | 22 void PrintingContext::ResetSettings() { |
20 ReleaseContext(); | 23 ReleaseContext(); |
21 | 24 |
22 settings_.Clear(); | 25 settings_.Clear(); |
23 | 26 |
24 in_print_job_ = false; | 27 in_print_job_ = false; |
25 dialog_box_dismissed_ = false; | 28 dialog_box_dismissed_ = false; |
26 abort_printing_ = false; | 29 abort_printing_ = false; |
27 } | 30 } |
28 | 31 |
32 bool PrintingContext::GetSettingsFromDict(const DictionaryValue& settings, | |
33 bool* landscape, | |
34 string16* printerName) { | |
35 bool ret = true; | |
36 if (landscape) | |
37 ret &= (settings.GetBoolean(kSettingLandscape, landscape)); | |
Lei Zhang
2011/03/30 22:12:00
nit: you probably don't need to outer parenthesis,
kmadhusu
2011/03/30 22:18:47
Done.
| |
38 | |
39 if (printerName) | |
40 ret &= (settings.GetString(kSettingPrinterName, printerName)); | |
41 | |
42 return ret; | |
43 } | |
44 | |
29 PrintingContext::Result PrintingContext::OnError() { | 45 PrintingContext::Result PrintingContext::OnError() { |
30 ResetSettings(); | 46 ResetSettings(); |
31 return abort_printing_ ? CANCEL : FAILED; | 47 return abort_printing_ ? CANCEL : FAILED; |
32 } | 48 } |
33 | 49 |
34 } // namespace printing | 50 } // namespace printing |
OLD | NEW |