| 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/print_job_worker.h" | 5 #include "chrome/browser/printing/print_job_worker.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // on the I/O thread. | 127 // on the I/O thread. |
| 128 DCHECK(owner_->RunsTasksOnCurrentThread()); | 128 DCHECK(owner_->RunsTasksOnCurrentThread()); |
| 129 Stop(); | 129 Stop(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) { | 132 void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) { |
| 133 DCHECK(page_number_ == PageNumber::npos()); | 133 DCHECK(page_number_ == PageNumber::npos()); |
| 134 owner_ = new_owner; | 134 owner_ = new_owner; |
| 135 } | 135 } |
| 136 | 136 |
| 137 void PrintJobWorker::GetSettings( | 137 void PrintJobWorker::GetSettings(bool ask_user_for_settings, |
| 138 bool ask_user_for_settings, | 138 int document_page_count, |
| 139 int document_page_count, | 139 bool has_selection, |
| 140 bool has_selection, | 140 MarginType margin_type, |
| 141 MarginType margin_type, | 141 bool is_scripted, |
| 142 bool is_scripted) { | 142 bool is_modifiable) { |
| 143 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 143 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 144 DCHECK_EQ(page_number_, PageNumber::npos()); | 144 DCHECK_EQ(page_number_, PageNumber::npos()); |
| 145 | 145 |
| 146 // Recursive task processing is needed for the dialog in case it needs to be | 146 // Recursive task processing is needed for the dialog in case it needs to be |
| 147 // destroyed by a task. | 147 // destroyed by a task. |
| 148 // TODO(thestig): This code is wrong. SetNestableTasksAllowed(true) is needed | 148 // TODO(thestig): This code is wrong. SetNestableTasksAllowed(true) is needed |
| 149 // on the thread where the PrintDlgEx is called, and definitely both calls | 149 // on the thread where the PrintDlgEx is called, and definitely both calls |
| 150 // should happen on the same thread. See http://crbug.com/73466 | 150 // should happen on the same thread. See http://crbug.com/73466 |
| 151 // MessageLoop::current()->SetNestableTasksAllowed(true); | 151 // MessageLoop::current()->SetNestableTasksAllowed(true); |
| 152 printing_context_->set_margin_type(margin_type); | 152 printing_context_->set_margin_type(margin_type); |
| 153 printing_context_->set_is_modifiable(is_modifiable); |
| 153 | 154 |
| 154 // When we delegate to a destination, we don't ask the user for settings. | 155 // When we delegate to a destination, we don't ask the user for settings. |
| 155 // TODO(mad): Ask the destination for settings. | 156 // TODO(mad): Ask the destination for settings. |
| 156 if (ask_user_for_settings) { | 157 if (ask_user_for_settings) { |
| 157 BrowserThread::PostTask( | 158 BrowserThread::PostTask( |
| 158 BrowserThread::UI, FROM_HERE, | 159 BrowserThread::UI, FROM_HERE, |
| 159 base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), | 160 base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), |
| 160 base::Bind(&PrintJobWorker::GetSettingsWithUI, | 161 base::Bind(&PrintJobWorker::GetSettingsWithUI, |
| 161 base::Unretained(this), | 162 base::Unretained(this), |
| 162 document_page_count, | 163 document_page_count, |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 JobEventDetails::FAILED, | 434 JobEventDetails::FAILED, |
| 434 base::RetainedRef(document_), nullptr)); | 435 base::RetainedRef(document_), nullptr)); |
| 435 Cancel(); | 436 Cancel(); |
| 436 | 437 |
| 437 // Makes sure the variables are reinitialized. | 438 // Makes sure the variables are reinitialized. |
| 438 document_ = NULL; | 439 document_ = NULL; |
| 439 page_number_ = PageNumber::npos(); | 440 page_number_ = PageNumber::npos(); |
| 440 } | 441 } |
| 441 | 442 |
| 442 } // namespace printing | 443 } // namespace printing |
| OLD | NEW |