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..ebf083c25bbf82a1ec49abcebe21bba1bffa8a1d 100644 |
--- a/chrome/browser/printing/print_job_worker.cc |
+++ b/chrome/browser/printing/print_job_worker.cc |
@@ -10,6 +10,10 @@ |
#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" |
Vitaly Buka (NO REVIEWS)
2014/12/09 23:46:48
put conditional includes after the main section of
dgn
2014/12/10 18:12:52
Done.
|
+#endif |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/printing/print_job.h" |
@@ -44,6 +48,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 +66,21 @@ PrintingContextDelegate::~PrintingContextDelegate() { |
} |
gfx::NativeView PrintingContextDelegate::GetParentView() { |
Vitaly Buka (NO REVIEWS)
2014/12/09 23:46:48
you can send tiny separate CL for these PrintingCo
dgn
2014/12/10 18:12:52
Here it is: https://codereview.chromium.org/787783
|
- 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 +121,7 @@ void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) { |
} |
void PrintJobWorker::GetSettings( |
- bool ask_user_for_settings, |
+ PrinterQuery::GetSettingsAskParam ask_settings_type, |
int document_page_count, |
bool has_selection, |
MarginType margin_type) { |
@@ -129,7 +138,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 == PrinterQuery::GetSettingsAskParam::ASK_USER) { |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |
Vitaly Buka (NO REVIEWS)
2014/12/09 23:46:48
does android needs both branches: ASK_USER and SYS
dgn
2014/12/10 18:12:52
Yes. SYSTEM_SPECIFIC is related the call coming fr
|
base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), |
@@ -137,6 +146,14 @@ void PrintJobWorker::GetSettings( |
base::Unretained(this), |
document_page_count, |
has_selection))); |
+ } else if (ask_settings_type == |
+ PrinterQuery::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,26 @@ 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 start a |
Vitaly Buka (NO REVIEWS)
2014/12/09 23:46:48
Comment makes if () body multily.
better to use
dgn
2014/12/10 18:12:52
Done.
|
+ // 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()); |