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 #include "chrome/browser/printing/printer_query.h" | 5 #include "chrome/browser/printing/printer_query.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 int PrinterQuery::cookie() const { | 62 int PrinterQuery::cookie() const { |
63 return cookie_; | 63 return cookie_; |
64 } | 64 } |
65 | 65 |
66 void PrinterQuery::GetSettings( | 66 void PrinterQuery::GetSettings( |
67 GetSettingsAskParam ask_user_for_settings, | 67 GetSettingsAskParam ask_user_for_settings, |
68 int expected_page_count, | 68 int expected_page_count, |
69 bool has_selection, | 69 bool has_selection, |
70 MarginType margin_type, | 70 MarginType margin_type, |
| 71 bool is_scripted, |
71 const base::Closure& callback) { | 72 const base::Closure& callback) { |
72 DCHECK(RunsTasksOnCurrentThread()); | 73 DCHECK(RunsTasksOnCurrentThread()); |
73 DCHECK(!is_print_dialog_box_shown_); | 74 DCHECK(!is_print_dialog_box_shown_ || !is_scripted); |
74 | 75 |
75 StartWorker(callback); | 76 StartWorker(callback); |
76 | 77 |
77 // Real work is done in PrintJobWorker::GetSettings(). | 78 // Real work is done in PrintJobWorker::GetSettings(). |
78 is_print_dialog_box_shown_ = ask_user_for_settings == ASK_USER; | 79 is_print_dialog_box_shown_ = |
| 80 ask_user_for_settings == GetSettingsAskParam::ASK_USER; |
79 worker_->PostTask(FROM_HERE, | 81 worker_->PostTask(FROM_HERE, |
80 base::Bind(&PrintJobWorker::GetSettings, | 82 base::Bind(&PrintJobWorker::GetSettings, |
81 base::Unretained(worker_.get()), | 83 base::Unretained(worker_.get()), |
82 is_print_dialog_box_shown_, | 84 is_print_dialog_box_shown_, |
83 expected_page_count, | 85 expected_page_count, |
84 has_selection, | 86 has_selection, |
85 margin_type)); | 87 margin_type, |
| 88 is_scripted)); |
86 } | 89 } |
87 | 90 |
88 void PrinterQuery::SetSettings(scoped_ptr<base::DictionaryValue> new_settings, | 91 void PrinterQuery::SetSettings(scoped_ptr<base::DictionaryValue> new_settings, |
89 const base::Closure& callback) { | 92 const base::Closure& callback) { |
90 StartWorker(callback); | 93 StartWorker(callback); |
91 | 94 |
92 worker_->PostTask(FROM_HERE, | 95 worker_->PostTask(FROM_HERE, |
93 base::Bind(&PrintJobWorker::SetSettings, | 96 base::Bind(&PrintJobWorker::SetSettings, |
94 base::Unretained(worker_.get()), | 97 base::Unretained(worker_.get()), |
95 base::Passed(&new_settings))); | 98 base::Passed(&new_settings))); |
(...skipping 23 matching lines...) Expand all Loading... |
119 | 122 |
120 bool PrinterQuery::is_callback_pending() const { | 123 bool PrinterQuery::is_callback_pending() const { |
121 return !callback_.is_null(); | 124 return !callback_.is_null(); |
122 } | 125 } |
123 | 126 |
124 bool PrinterQuery::is_valid() const { | 127 bool PrinterQuery::is_valid() const { |
125 return worker_.get() != NULL; | 128 return worker_.get() != NULL; |
126 } | 129 } |
127 | 130 |
128 } // namespace printing | 131 } // namespace printing |
OLD | NEW |