Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6336)

Unified Diff: chrome/browser/printing/print_job_worker.cc

Issue 6533006: Print Preview: Hook up the print button to initiate printing without displaying a print dialog. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Addressed review comments. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/printing/print_job_worker.h ('k') | chrome/browser/printing/printer_query.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 db0c3411dbccc4012a765046d98ba1bfc7235aed..3c7f8625de8fb228bc3f11dde77245ba5904bf32 100644
--- a/chrome/browser/printing/print_job_worker.cc
+++ b/chrome/browser/printing/print_job_worker.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/printing/print_job_worker.h"
#include "base/message_loop.h"
+#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/printing/print_job.h"
#include "chrome/common/notification_service.h"
@@ -98,6 +99,41 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings,
}
}
+void PrintJobWorker::SetSettings(const DictionaryValue* const new_settings) {
+ DCHECK_EQ(message_loop(), MessageLoop::current());
+
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &PrintJobWorker::UpdatePrintSettings,
+ new_settings));
+}
+
+void PrintJobWorker::UpdatePrintSettings(
+ const DictionaryValue* const new_settings) {
+ // Create new PageRanges based on |new_settings|.
+ PageRanges new_ranges;
+ ListValue* page_range_array;
+ if (new_settings->GetList("pageRange", &page_range_array)) {
+ for (size_t index = 0; index < page_range_array->GetSize(); ++index) {
+ DictionaryValue* dict;
+ if (page_range_array->GetDictionary(index, &dict)) {
+ PageRange range;
+ if (dict->GetInteger("from", &range.from) &&
+ dict->GetInteger("to", &range.to)) {
+ // Page numbers are 0-based.
+ range.from--;
+ range.to--;
+ new_ranges.push_back(range);
+ }
+ }
+ }
+ }
+ // We don't update any other print job settings now, so delete |new_settings|.
+ delete new_settings;
+ PrintingContext::Result result =
+ printing_context_->UpdatePrintSettings(new_ranges);
+ GetSettingsDone(result);
+}
+
void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) {
// Most PrintingContext functions may start a message loop and process
// message recursively, so disable recursive task processing.
« no previous file with comments | « chrome/browser/printing/print_job_worker.h ('k') | chrome/browser/printing/printer_query.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698