Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: printing/printing_context.h

Issue 504763002: Revert of Added PrintingContext::Delegate to get parent view handle and application locale. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/emf_win_unittest.cc ('k') | printing/printing_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 11 #include "base/callback.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/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 // Printing context delegate.
29 class Delegate {
30 public:
31 Delegate() {};
32 virtual ~Delegate() {};
33
34 // Returns parent view to use for modal dialogs.
35 virtual gfx::NativeView GetParentView() = 0;
36
37 // Returns application locale.
38 virtual std::string GetAppLocale() = 0;
39 };
40
41 // Tri-state result for user behavior-dependent functions. 28 // Tri-state result for user behavior-dependent functions.
42 enum Result { 29 enum Result {
43 OK, 30 OK,
44 CANCEL, 31 CANCEL,
45 FAILED, 32 FAILED,
46 }; 33 };
47 34
48 virtual ~PrintingContext(); 35 virtual ~PrintingContext();
49 36
50 // Callback of AskUserForSettings, used to notify the PrintJobWorker when 37 // Callback of AskUserForSettings, used to notify the PrintJobWorker when
51 // print settings are available. 38 // print settings are available.
52 typedef base::Callback<void(Result)> PrintSettingsCallback; 39 typedef base::Callback<void(Result)> PrintSettingsCallback;
53 40
54 // 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
55 // 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
56 // 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
57 // asynchronous printing API. 44 // asynchronous printing API.
58 virtual void AskUserForSettings(int max_pages, 45 virtual void AskUserForSettings(gfx::NativeView parent_view,
46 int max_pages,
59 bool has_selection, 47 bool has_selection,
60 const PrintSettingsCallback& callback) = 0; 48 const PrintSettingsCallback& callback) = 0;
61 49
62 // 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
63 // default device settings. 51 // default device settings.
64 virtual Result UseDefaultSettings() = 0; 52 virtual Result UseDefaultSettings() = 0;
65 53
66 // Updates the context with PDF printer settings. 54 // Updates the context with PDF printer settings.
67 Result UsePdfSettings(); 55 Result UsePdfSettings();
68 56
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // immediately. 91 // immediately.
104 virtual void Cancel() = 0; 92 virtual void Cancel() = 0;
105 93
106 // Releases the native printing context. 94 // Releases the native printing context.
107 virtual void ReleaseContext() = 0; 95 virtual void ReleaseContext() = 0;
108 96
109 // Returns the native context used to print. 97 // Returns the native context used to print.
110 virtual gfx::NativeDrawingContext context() const = 0; 98 virtual gfx::NativeDrawingContext context() const = 0;
111 99
112 // Creates an instance of this object. Implementers of this interface should 100 // Creates an instance of this object. Implementers of this interface should
113 // implement this method to create an object of their implementation. 101 // implement this method to create an object of their implementation. The
114 static scoped_ptr<PrintingContext> Create(Delegate* delegate); 102 // caller owns the returned object.
103 static PrintingContext* Create(const std::string& app_locale);
115 104
116 void set_margin_type(MarginType type); 105 void set_margin_type(MarginType type);
117 106
118 const PrintSettings& settings() const { 107 const PrintSettings& settings() const {
119 return settings_; 108 return settings_;
120 } 109 }
121 110
122 protected: 111 protected:
123 explicit PrintingContext(Delegate* delegate); 112 explicit PrintingContext(const std::string& app_locale);
124 113
125 // Reinitializes the settings for object reuse. 114 // Reinitializes the settings for object reuse.
126 void ResetSettings(); 115 void ResetSettings();
127 116
128 // Does bookkeeping when an error occurs. 117 // Does bookkeeping when an error occurs.
129 PrintingContext::Result OnError(); 118 PrintingContext::Result OnError();
130 119
131 // Complete print context settings. 120 // Complete print context settings.
132 PrintSettings settings_; 121 PrintSettings settings_;
133 122
134 // Printing context delegate.
135 Delegate* delegate_;
136
137 // The dialog box has been dismissed. 123 // The dialog box has been dismissed.
138 volatile bool dialog_box_dismissed_; 124 volatile bool dialog_box_dismissed_;
139 125
140 // Is a print job being done. 126 // Is a print job being done.
141 volatile bool in_print_job_; 127 volatile bool in_print_job_;
142 128
143 // Did the user cancel the print job. 129 // Did the user cancel the print job.
144 volatile bool abort_printing_; 130 volatile bool abort_printing_;
145 131
132 // The application locale.
133 std::string app_locale_;
134
146 private: 135 private:
147 DISALLOW_COPY_AND_ASSIGN(PrintingContext); 136 DISALLOW_COPY_AND_ASSIGN(PrintingContext);
148 }; 137 };
149 138
150 } // namespace printing 139 } // namespace printing
151 140
152 #endif // PRINTING_PRINTING_CONTEXT_H_ 141 #endif // PRINTING_PRINTING_CONTEXT_H_
OLDNEW
« no previous file with comments | « printing/emf_win_unittest.cc ('k') | printing/printing_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698