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 ee8cddea181a9a759182b4d828a3d4a45ae424da..eb0e94208159ce941623d1a7e0c21faf907c4e7b 100644 |
| --- a/chrome/browser/printing/print_job_worker.cc |
| +++ b/chrome/browser/printing/print_job_worker.cc |
| @@ -10,6 +10,11 @@ |
| #include "base/compiler_specific.h" |
| #include "base/message_loop/message_loop.h" |
| #include "base/values.h" |
| + |
| +#if defined(OS_ANDROID) |
| +#include "chrome/browser/android/tab_android.h" |
| +#endif |
| + |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/chrome_notification_types.h" |
| #include "chrome/browser/printing/print_job.h" |
| @@ -44,6 +49,9 @@ class PrintingContextDelegate : public PrintingContext::Delegate { |
| gfx::NativeView GetParentView() override; |
| std::string GetAppLocale() override; |
| + // Not exposed to PrintingContext::Delegate because of dependency issues. |
| + content::WebContents* GetWebContents(); |
| + |
| private: |
| int render_process_id_; |
| int render_view_id_; |
| @@ -59,19 +67,21 @@ PrintingContextDelegate::~PrintingContextDelegate() { |
| } |
| gfx::NativeView PrintingContextDelegate::GetParentView() { |
| - DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| - content::RenderViewHost* view = |
| - content::RenderViewHost::FromID(render_process_id_, render_view_id_); |
| - if (!view) |
| - return NULL; |
| - content::WebContents* wc = content::WebContents::FromRenderViewHost(view); |
| - return wc ? wc->GetNativeView() : NULL; |
| + content::WebContents* wc = GetWebContents(); |
| + return wc ? wc->GetNativeView() : nullptr; |
| } |
| std::string PrintingContextDelegate::GetAppLocale() { |
| return g_browser_process->GetApplicationLocale(); |
| } |
| +content::WebContents* PrintingContextDelegate::GetWebContents() { |
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + content::RenderViewHost* view = |
| + content::RenderViewHost::FromID(render_process_id_, render_view_id_); |
| + return view ? content::WebContents::FromRenderViewHost(view) : nullptr; |
| +} |
| + |
| void NotificationCallback(PrintJobWorkerOwner* print_job, |
| JobEventDetails::Type detail_type, |
| PrintedDocument* document, |
| @@ -112,7 +122,7 @@ void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) { |
| } |
| void PrintJobWorker::GetSettings( |
| - bool ask_user_for_settings, |
| + GetSettingsAskParam ask_settings_type, |
| int document_page_count, |
| bool has_selection, |
| MarginType margin_type) { |
| @@ -129,7 +139,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_settings_type == GetSettingsAskParam::ASK_USER) { |
| BrowserThread::PostTask( |
| BrowserThread::UI, FROM_HERE, |
| base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), |
| @@ -137,6 +147,13 @@ void PrintJobWorker::GetSettings( |
| base::Unretained(this), |
| document_page_count, |
| has_selection))); |
| + } else if (ask_settings_type == 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 +163,25 @@ void PrintJobWorker::GetSettings( |
| } |
| } |
| +void PrintJobWorker::ShowSystemDialog() { |
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + LOG(INFO) << "DGN ShowSystemDialog"; |
| + |
| +#if defined(OS_ANDROID) |
| + PrintingContextDelegate* pcd = |
| + static_cast<PrintingContextDelegate*>(printing_context_delegate_.get()); |
| + content::WebContents* wc = pcd->GetWebContents(); |
| + TabAndroid* tab = TabAndroid::FromWebContents(wc); |
| + if (tab) tab->SetPendingPrint(); // If fails or is not called, attempting to |
|
mlamouri (slow - plz ping)
2014/11/27 20:26:02
I believe the coding style says:
if (tab)
tab->S
dgn
2014/11/28 11:51:15
Done.
|
| + // start a pending print does nothing and |
| + // will notify that printing is finished. |
| +#endif |
| + |
| + printing_context_->RequestSystemDialog( |
| + base::Bind(&PrintJobWorker::GetSettingsDone, |
| + base::Unretained(this))); |
| +} |
| + |
| void PrintJobWorker::SetSettings( |
| scoped_ptr<base::DictionaryValue> new_settings) { |
| DCHECK(task_runner_->RunsTasksOnCurrentThread()); |