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