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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } else { | 107 } else { |
108 BrowserThread::PostTask( | 108 BrowserThread::PostTask( |
109 BrowserThread::UI, FROM_HERE, | 109 BrowserThread::UI, FROM_HERE, |
110 base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), | 110 base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), |
111 base::Bind(&PrintJobWorker::UseDefaultSettings, | 111 base::Bind(&PrintJobWorker::UseDefaultSettings, |
112 base::Unretained(this)))); | 112 base::Unretained(this)))); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 void PrintJobWorker::SetSettings( | 116 void PrintJobWorker::SetSettings( |
117 const base::DictionaryValue* const new_settings) { | 117 scoped_ptr<PrintingUIWebContentsObserver> web_contents_observer, |
| 118 scoped_ptr<base::DictionaryValue> new_settings) { |
118 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 119 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
119 | 120 |
120 BrowserThread::PostTask( | 121 BrowserThread::PostTask( |
121 BrowserThread::UI, | 122 BrowserThread::UI, |
122 FROM_HERE, | 123 FROM_HERE, |
123 base::Bind(&HoldRefCallback, | 124 base::Bind(&HoldRefCallback, |
124 make_scoped_refptr(owner_), | 125 make_scoped_refptr(owner_), |
125 base::Bind(&PrintJobWorker::UpdatePrintSettings, | 126 base::Bind(&PrintJobWorker::UpdatePrintSettings, |
126 base::Unretained(this), | 127 base::Unretained(this), |
127 base::Owned(new_settings)))); | 128 base::Passed(&web_contents_observer), |
| 129 base::Passed(&new_settings)))); |
128 } | 130 } |
129 | 131 |
130 void PrintJobWorker::UpdatePrintSettings( | 132 void PrintJobWorker::UpdatePrintSettings( |
131 const base::DictionaryValue* const new_settings) { | 133 scoped_ptr<PrintingUIWebContentsObserver> web_contents_observer, |
132 PrintingContext::Result result = | 134 scoped_ptr<base::DictionaryValue> new_settings) { |
133 printing_context_->UpdatePrintSettings(*new_settings); | 135 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 136 PrintingContext::Result result = printing_context_->UpdatePrintSettings( |
| 137 *new_settings, |
| 138 web_contents_observer ? web_contents_observer->GetParentView() : NULL); |
134 GetSettingsDone(result); | 139 GetSettingsDone(result); |
135 } | 140 } |
136 | 141 |
137 void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) { | 142 void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) { |
138 // Most PrintingContext functions may start a message loop and process | 143 // Most PrintingContext functions may start a message loop and process |
139 // message recursively, so disable recursive task processing. | 144 // message recursively, so disable recursive task processing. |
140 // TODO(thestig): See above comment. SetNestableTasksAllowed(false) needs to | 145 // TODO(thestig): See above comment. SetNestableTasksAllowed(false) needs to |
141 // be called on the same thread as the previous call. See | 146 // be called on the same thread as the previous call. See |
142 // http://crbug.com/73466 | 147 // http://crbug.com/73466 |
143 // MessageLoop::current()->SetNestableTasksAllowed(false); | 148 // MessageLoop::current()->SetNestableTasksAllowed(false); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 document_, | 394 document_, |
390 scoped_refptr<PrintedPage>())); | 395 scoped_refptr<PrintedPage>())); |
391 Cancel(); | 396 Cancel(); |
392 | 397 |
393 // Makes sure the variables are reinitialized. | 398 // Makes sure the variables are reinitialized. |
394 document_ = NULL; | 399 document_ = NULL; |
395 page_number_ = PageNumber::npos(); | 400 page_number_ = PageNumber::npos(); |
396 } | 401 } |
397 | 402 |
398 } // namespace printing | 403 } // namespace printing |
OLD | NEW |