Chromium Code Reviews| Index: chrome/browser/printing/print_job_worker.cc |
| diff --git a/chrome/browser/printing/print_job_worker.cc b/chrome/browser/printing/print_job_worker.cc |
| index 3f277c594182f0c9904fb903c3e1e70b1436946d..a0c713bc9130cc2721b7f836abdfd2d5e457aab6 100644 |
| --- a/chrome/browser/printing/print_job_worker.cc |
| +++ b/chrome/browser/printing/print_job_worker.cc |
| @@ -24,6 +24,10 @@ |
| #include "printing/printing_utils.h" |
| #include "ui/base/l10n/l10n_util.h" |
| +#if defined(OS_ANDROID) |
| +#include "chrome/browser/android/tab_android.h" |
| +#endif |
| + |
| using content::BrowserThread; |
| namespace printing { |
| @@ -120,7 +124,8 @@ void PrintJobWorker::GetSettings( |
| bool ask_user_for_settings, |
| int document_page_count, |
| bool has_selection, |
| - MarginType margin_type) { |
| + MarginType margin_type, |
| + bool is_scripted) { |
| DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| DCHECK_EQ(page_number_, PageNumber::npos()); |
| @@ -141,7 +146,8 @@ void PrintJobWorker::GetSettings( |
| base::Bind(&PrintJobWorker::GetSettingsWithUI, |
| base::Unretained(this), |
| document_page_count, |
| - has_selection))); |
| + has_selection, |
| + is_scripted))); |
| } else { |
| BrowserThread::PostTask( |
| BrowserThread::UI, FROM_HERE, |
| @@ -193,11 +199,30 @@ void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) { |
| void PrintJobWorker::GetSettingsWithUI( |
| int document_page_count, |
| - bool has_selection) { |
| + bool has_selection, |
| + bool is_scripted) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + |
| +#if defined(OS_ANDROID) |
| + if (is_scripted) { |
| + PrintingContextDelegate* printing_context_delegate = |
| + static_cast<PrintingContextDelegate*>(printing_context_delegate_.get()); |
| + content::WebContents* web_contents = |
| + printing_context_delegate->GetWebContents(); |
| + TabAndroid* tab = TabAndroid::FromWebContents(web_contents); |
| + if (tab) { |
| + // If the following method fails (print not supported by policy, print |
| + // in progress...) or is not called, attempting to start a pending print |
| + // does nothing and will notify that printing is finished. |
|
Bernhard Bauer
2014/12/15 10:44:59
I'm not particularly familiar with this code, but
dgn
2014/12/15 13:16:24
Initially, the comment was there to clarify what h
|
| + tab->SetPendingPrint(); |
| + } |
| + } |
| +#endif |
| + |
| printing_context_->AskUserForSettings( |
| document_page_count, |
| has_selection, |
| + is_scripted, |
| base::Bind(&PrintJobWorker::GetSettingsWithUIDone, |
| base::Unretained(this))); |
| } |