| 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 ee8cddea181a9a759182b4d828a3d4a45ae424da..87ffac28e1edf13de129b5812eccae1532490d74 100644
|
| --- a/chrome/browser/printing/print_job_worker.cc
|
| +++ b/chrome/browser/printing/print_job_worker.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/compiler_specific.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/values.h"
|
| +#include "chrome/browser/android/tab_android.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/printing/print_job.h"
|
| @@ -44,6 +45,8 @@ class PrintingContextDelegate : public PrintingContext::Delegate {
|
| gfx::NativeView GetParentView() override;
|
| std::string GetAppLocale() override;
|
|
|
| + void ShowSystemDialog() override;
|
| +
|
| private:
|
| int render_process_id_;
|
| int render_view_id_;
|
| @@ -72,6 +75,22 @@ std::string PrintingContextDelegate::GetAppLocale() {
|
| return g_browser_process->GetApplicationLocale();
|
| }
|
|
|
| +void PrintingContextDelegate::ShowSystemDialog() {
|
| + LOG(INFO) << "DGN PrintingContextDelegate::ShowSystemDialog";
|
| +#if defined(OS_ANDROID)
|
| + // Tab (Printable) needed to print. How to call it without the tab directly?
|
| + // Removing the dependency on chrome would make it easier to move it to
|
| + // printing_context_android
|
| + content::RenderViewHost* view = content::RenderViewHost::FromID(
|
| + render_process_id_, render_view_id_);
|
| + DCHECK(view);
|
| + content::WebContents* wc = content::WebContents::FromRenderViewHost(view);
|
| + TabAndroid* tab = TabAndroid::FromWebContents(wc);
|
| + if (tab) tab->ShowPrintDialog();
|
| +#endif
|
| +}
|
| +
|
| +
|
| void NotificationCallback(PrintJobWorkerOwner* print_job,
|
| JobEventDetails::Type detail_type,
|
| PrintedDocument* document,
|
| @@ -112,13 +131,15 @@ void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) {
|
| }
|
|
|
| void PrintJobWorker::GetSettings(
|
| - bool ask_user_for_settings,
|
| + GetSettingsAskParam ask_user_for_settings,
|
| int document_page_count,
|
| bool has_selection,
|
| MarginType margin_type) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
| DCHECK_EQ(page_number_, PageNumber::npos());
|
|
|
| + LOG(INFO) << "DGN GetSettings - askParam: " << ask_user_for_settings;
|
| +
|
| // Recursive task processing is needed for the dialog in case it needs to be
|
| // destroyed by a task.
|
| // TODO(thestig): This code is wrong. SetNestableTasksAllowed(true) is needed
|
| @@ -129,7 +150,7 @@ void PrintJobWorker::GetSettings(
|
|
|
| // When we delegate to a destination, we don't ask the user for settings.
|
| // TODO(mad): Ask the destination for settings.
|
| - if (ask_user_for_settings) {
|
| + if (ask_user_for_settings == GetSettingsAskParam::ASK_USER) {
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&HoldRefCallback, make_scoped_refptr(owner_),
|
| @@ -137,6 +158,13 @@ void PrintJobWorker::GetSettings(
|
| base::Unretained(this),
|
| document_page_count,
|
| has_selection)));
|
| + } else if (ask_user_for_settings == GetSettingsAskParam::SYSTEM_SPECIFIC) {
|
| + LOG(INFO) << "DGN SYSTEM_SPECIFIC! ";
|
| + BrowserThread::PostTask(
|
| + BrowserThread::UI, FROM_HERE,
|
| + base::Bind(&HoldRefCallback, make_scoped_refptr(owner_),
|
| + base::Bind(&PrintJobWorker::ShowSystemDialog,
|
| + base::Unretained(this))));
|
| } else {
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| @@ -146,6 +174,19 @@ void PrintJobWorker::GetSettings(
|
| }
|
| }
|
|
|
| +void PrintJobWorker::ShowSystemDialog() {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + LOG(INFO) << "DGN ShowSystemDialog";
|
| +
|
| + if (printing_context_ == NULL) LOG(INFO) << "DGN printing_context_ is NULL";
|
| +
|
| + printing_context_->SetPrintSettingsCallback(
|
| + base::Bind(&PrintJobWorkerOwner::ShowSystemDialogDone,
|
| + base::Unretained(owner_)));
|
| +
|
| + printing_context_delegate_->ShowSystemDialog();
|
| +}
|
| +
|
| void PrintJobWorker::SetSettings(
|
| scoped_ptr<base::DictionaryValue> new_settings) {
|
| DCHECK(task_runner_->RunsTasksOnCurrentThread());
|
| @@ -190,11 +231,11 @@ void PrintJobWorker::GetSettingsWithUI(
|
| int document_page_count,
|
| bool has_selection) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| - printing_context_->AskUserForSettings(
|
| - document_page_count,
|
| - has_selection,
|
| - base::Bind(&PrintJobWorker::GetSettingsWithUIDone,
|
| - base::Unretained(this)));
|
| + printing_context_->AskUserForSettings(
|
| + document_page_count,
|
| + has_selection,
|
| + base::Bind(&PrintJobWorker::GetSettingsWithUIDone,
|
| + base::Unretained(this)));
|
| }
|
|
|
| void PrintJobWorker::GetSettingsWithUIDone(PrintingContext::Result result) {
|
|
|