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 #ifndef PRINTING_PRINTING_CONTEXT_H_ | 5 #ifndef PRINTING_PRINTING_CONTEXT_H_ |
6 #define PRINTING_PRINTING_CONTEXT_H_ | 6 #define PRINTING_PRINTING_CONTEXT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback_old.h" | 11 #include "base/callback.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "printing/print_settings.h" | 13 #include "printing/print_settings.h" |
14 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class DictionaryValue; | 17 class DictionaryValue; |
18 } | 18 } |
19 | 19 |
20 namespace printing { | 20 namespace printing { |
21 | 21 |
22 // An abstraction of a printer context, implemented by objects that describe the | 22 // An abstraction of a printer context, implemented by objects that describe the |
23 // user selected printing context. This includes the OS-dependent UI to ask the | 23 // user selected printing context. This includes the OS-dependent UI to ask the |
24 // user about the print settings. Concrete implementations directly talk to the | 24 // user about the print settings. Concrete implementations directly talk to the |
25 // printer and manage the document and page breaks. | 25 // printer and manage the document and page breaks. |
26 class PRINTING_EXPORT PrintingContext { | 26 class PRINTING_EXPORT PrintingContext { |
27 public: | 27 public: |
28 // Tri-state result for user behavior-dependent functions. | 28 // Tri-state result for user behavior-dependent functions. |
29 enum Result { | 29 enum Result { |
30 OK, | 30 OK, |
31 CANCEL, | 31 CANCEL, |
32 FAILED, | 32 FAILED, |
33 }; | 33 }; |
34 | 34 |
35 virtual ~PrintingContext(); | 35 virtual ~PrintingContext(); |
36 | 36 |
37 // Callback of AskUserForSettings, used to notify the PrintJobWorker when | 37 // Callback of AskUserForSettings, used to notify the PrintJobWorker when |
38 // print settings are available. | 38 // print settings are available. |
39 typedef Callback1<Result>::Type PrintSettingsCallback; | 39 typedef base::Callback<void(Result)> PrintSettingsCallback; |
40 | 40 |
41 // Asks the user what printer and format should be used to print. Updates the | 41 // Asks the user what printer and format should be used to print. Updates the |
42 // context with the select device settings. The result of the call is returned | 42 // context with the select device settings. The result of the call is returned |
43 // in the callback. This is necessary for Linux, which only has an | 43 // in the callback. This is necessary for Linux, which only has an |
44 // asynchronous printing API. | 44 // asynchronous printing API. |
45 virtual void AskUserForSettings(gfx::NativeView parent_view, | 45 virtual void AskUserForSettings(gfx::NativeView parent_view, |
46 int max_pages, | 46 int max_pages, |
47 bool has_selection, | 47 bool has_selection, |
48 PrintSettingsCallback* callback) = 0; | 48 const PrintSettingsCallback& callback) = 0; |
49 | 49 |
50 // Selects the user's default printer and format. Updates the context with the | 50 // Selects the user's default printer and format. Updates the context with the |
51 // default device settings. | 51 // default device settings. |
52 virtual Result UseDefaultSettings() = 0; | 52 virtual Result UseDefaultSettings() = 0; |
53 | 53 |
54 // Updates printer related settings. |job_settings| contains all print job | 54 // Updates printer related settings. |job_settings| contains all print job |
55 // settings information. |ranges| has the new page range settings. | 55 // settings information. |ranges| has the new page range settings. |
56 virtual Result UpdatePrinterSettings( | 56 virtual Result UpdatePrinterSettings( |
57 const base::DictionaryValue& job_settings, | 57 const base::DictionaryValue& job_settings, |
58 const PageRanges& ranges) = 0; | 58 const PageRanges& ranges) = 0; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 // The application locale. | 128 // The application locale. |
129 std::string app_locale_; | 129 std::string app_locale_; |
130 | 130 |
131 DISALLOW_COPY_AND_ASSIGN(PrintingContext); | 131 DISALLOW_COPY_AND_ASSIGN(PrintingContext); |
132 }; | 132 }; |
133 | 133 |
134 } // namespace printing | 134 } // namespace printing |
135 | 135 |
136 #endif // PRINTING_PRINTING_CONTEXT_H_ | 136 #endif // PRINTING_PRINTING_CONTEXT_H_ |
OLD | NEW |