| 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..34a3483b5e41ba79c37265728b9b66f9ab14364e 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);
|
| +
|
| + // Regardless of whether the following call fails or not, the javascript
|
| + // call will return since startPendingPrint will make it return immediately
|
| + // in case of error.
|
| + if (tab)
|
| + tab->SetPendingPrint();
|
| + }
|
| +#endif
|
| +
|
| printing_context_->AskUserForSettings(
|
| document_page_count,
|
| has_selection,
|
| + is_scripted,
|
| base::Bind(&PrintJobWorker::GetSettingsWithUIDone,
|
| base::Unretained(this)));
|
| }
|
|
|