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 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
23 #include "chrome/browser/printing/print_job.h" | 23 #include "chrome/browser/printing/print_job.h" |
24 #include "chrome/common/features.h" | |
25 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
26 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
28 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
29 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
30 #include "printing/print_job_constants.h" | 29 #include "printing/print_job_constants.h" |
31 #include "printing/printed_document.h" | 30 #include "printing/printed_document.h" |
32 #include "printing/printed_page.h" | 31 #include "printing/printed_page.h" |
33 #include "printing/printing_utils.h" | 32 #include "printing/printing_utils.h" |
34 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
35 | 34 |
36 #if BUILDFLAG(ANDROID_JAVA_UI) | 35 #if defined(OS_ANDROID) |
37 #include "chrome/browser/android/tab_android.h" | 36 #include "chrome/browser/android/tab_android.h" |
38 #endif | 37 #endif |
39 | 38 |
40 using content::BrowserThread; | 39 using content::BrowserThread; |
41 | 40 |
42 namespace printing { | 41 namespace printing { |
43 | 42 |
44 namespace { | 43 namespace { |
45 | 44 |
46 // Helper function to ensure |owner| is valid until at least |callback| returns. | 45 // Helper function to ensure |owner| is valid until at least |callback| returns. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 printing_context_->settings(), | 211 printing_context_->settings(), |
213 result)); | 212 result)); |
214 } | 213 } |
215 | 214 |
216 void PrintJobWorker::GetSettingsWithUI( | 215 void PrintJobWorker::GetSettingsWithUI( |
217 int document_page_count, | 216 int document_page_count, |
218 bool has_selection, | 217 bool has_selection, |
219 bool is_scripted) { | 218 bool is_scripted) { |
220 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 219 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
221 | 220 |
222 #if BUILDFLAG(ANDROID_JAVA_UI) | 221 #if defined(OS_ANDROID) |
223 if (is_scripted) { | 222 if (is_scripted) { |
224 PrintingContextDelegate* printing_context_delegate = | 223 PrintingContextDelegate* printing_context_delegate = |
225 static_cast<PrintingContextDelegate*>(printing_context_delegate_.get()); | 224 static_cast<PrintingContextDelegate*>(printing_context_delegate_.get()); |
226 content::WebContents* web_contents = | 225 content::WebContents* web_contents = |
227 printing_context_delegate->GetWebContents(); | 226 printing_context_delegate->GetWebContents(); |
228 TabAndroid* tab = | 227 TabAndroid* tab = |
229 web_contents ? TabAndroid::FromWebContents(web_contents) : nullptr; | 228 web_contents ? TabAndroid::FromWebContents(web_contents) : nullptr; |
230 | 229 |
231 // Regardless of whether the following call fails or not, the javascript | 230 // Regardless of whether the following call fails or not, the javascript |
232 // call will return since startPendingPrint will make it return immediately | 231 // call will return since startPendingPrint will make it return immediately |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 JobEventDetails::FAILED, | 433 JobEventDetails::FAILED, |
435 base::RetainedRef(document_), nullptr)); | 434 base::RetainedRef(document_), nullptr)); |
436 Cancel(); | 435 Cancel(); |
437 | 436 |
438 // Makes sure the variables are reinitialized. | 437 // Makes sure the variables are reinitialized. |
439 document_ = NULL; | 438 document_ = NULL; |
440 page_number_ = PageNumber::npos(); | 439 page_number_ = PageNumber::npos(); |
441 } | 440 } |
442 | 441 |
443 } // namespace printing | 442 } // namespace printing |
OLD | NEW |