OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_PRINTING_PRINTER_QUERY_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_PRINTER_QUERY_H_ |
6 #define CHROME_BROWSER_PRINTING_PRINTER_QUERY_H_ | 6 #define CHROME_BROWSER_PRINTING_PRINTER_QUERY_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 public: | 25 public: |
26 // GetSettings() UI parameter. | 26 // GetSettings() UI parameter. |
27 enum GetSettingsAskParam { | 27 enum GetSettingsAskParam { |
28 DEFAULTS, | 28 DEFAULTS, |
29 ASK_USER, | 29 ASK_USER, |
30 }; | 30 }; |
31 | 31 |
32 PrinterQuery(int render_process_id, int render_view_id); | 32 PrinterQuery(int render_process_id, int render_view_id); |
33 | 33 |
34 // PrintJobWorkerOwner implementation. | 34 // PrintJobWorkerOwner implementation. |
35 virtual void GetSettingsDone(const PrintSettings& new_settings, | 35 void GetSettingsDone(const PrintSettings& new_settings, |
36 PrintingContext::Result result) override; | 36 PrintingContext::Result result) override; |
37 virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) override; | 37 PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) override; |
38 virtual const PrintSettings& settings() const override; | 38 const PrintSettings& settings() const override; |
39 virtual int cookie() const override; | 39 int cookie() const override; |
40 | 40 |
41 // Initializes the printing context. It is fine to call this function multiple | 41 // Initializes the printing context. It is fine to call this function multiple |
42 // times to reinitialize the settings. |web_contents_observer| can be queried | 42 // times to reinitialize the settings. |web_contents_observer| can be queried |
43 // to find the owner of the print setting dialog box. It is unused when | 43 // to find the owner of the print setting dialog box. It is unused when |
44 // |ask_for_user_settings| is DEFAULTS. | 44 // |ask_for_user_settings| is DEFAULTS. |
45 void GetSettings( | 45 void GetSettings( |
46 GetSettingsAskParam ask_user_for_settings, | 46 GetSettingsAskParam ask_user_for_settings, |
47 int expected_page_count, | 47 int expected_page_count, |
48 bool has_selection, | 48 bool has_selection, |
49 MarginType margin_type, | 49 MarginType margin_type, |
50 const base::Closure& callback); | 50 const base::Closure& callback); |
51 | 51 |
52 // Updates the current settings with |new_settings| dictionary values. | 52 // Updates the current settings with |new_settings| dictionary values. |
53 void SetSettings(scoped_ptr<base::DictionaryValue> new_settings, | 53 void SetSettings(scoped_ptr<base::DictionaryValue> new_settings, |
54 const base::Closure& callback); | 54 const base::Closure& callback); |
55 | 55 |
56 // Stops the worker thread since the client is done with this object. | 56 // Stops the worker thread since the client is done with this object. |
57 void StopWorker(); | 57 void StopWorker(); |
58 | 58 |
59 // Returns true if a GetSettings() call is pending completion. | 59 // Returns true if a GetSettings() call is pending completion. |
60 bool is_callback_pending() const; | 60 bool is_callback_pending() const; |
61 | 61 |
62 PrintingContext::Result last_status() const { return last_status_; } | 62 PrintingContext::Result last_status() const { return last_status_; } |
63 | 63 |
64 // Returns if a worker thread is still associated to this instance. | 64 // Returns if a worker thread is still associated to this instance. |
65 bool is_valid() const; | 65 bool is_valid() const; |
66 | 66 |
67 private: | 67 private: |
68 virtual ~PrinterQuery(); | 68 ~PrinterQuery() override; |
69 | 69 |
70 // Lazy create the worker thread. There is one worker thread per print job. | 70 // Lazy create the worker thread. There is one worker thread per print job. |
71 void StartWorker(const base::Closure& callback); | 71 void StartWorker(const base::Closure& callback); |
72 | 72 |
73 // All the UI is done in a worker thread because many Win32 print functions | 73 // All the UI is done in a worker thread because many Win32 print functions |
74 // are blocking and enters a message loop without your consent. There is one | 74 // are blocking and enters a message loop without your consent. There is one |
75 // worker thread per print job. | 75 // worker thread per print job. |
76 scoped_ptr<PrintJobWorker> worker_; | 76 scoped_ptr<PrintJobWorker> worker_; |
77 | 77 |
78 // Cache of the print context settings for access in the UI thread. | 78 // Cache of the print context settings for access in the UI thread. |
(...skipping 10 matching lines...) Expand all Loading... |
89 | 89 |
90 // Callback waiting to be run. | 90 // Callback waiting to be run. |
91 base::Closure callback_; | 91 base::Closure callback_; |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(PrinterQuery); | 93 DISALLOW_COPY_AND_ASSIGN(PrinterQuery); |
94 }; | 94 }; |
95 | 95 |
96 } // namespace printing | 96 } // namespace printing |
97 | 97 |
98 #endif // CHROME_BROWSER_PRINTING_PRINTER_QUERY_H_ | 98 #endif // CHROME_BROWSER_PRINTING_PRINTER_QUERY_H_ |
OLD | NEW |