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

Unified Diff: chrome/browser/ui/webui/print_preview_handler.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: '' 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
Index: chrome/browser/ui/webui/print_preview_handler.cc
diff --git a/chrome/browser/ui/webui/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview_handler.cc
index 65a39edfb37b4e25457a006df08fbb9f6e735eb6..946c93b9a30182af5549f08b590f973ef644261c 100644
--- a/chrome/browser/ui/webui/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview_handler.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/print_preview_handler.h"
+#include "base/json/json_reader.h"
#include "base/values.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "printing/backend/print_backend.h"
@@ -35,6 +36,18 @@ void PrintPreviewHandler::HandleGetPrinters(const ListValue*) {
web_ui_->CallJavascriptFunction(L"setPrinters", printers);
}
-void PrintPreviewHandler::HandlePrint(const ListValue*) {
- web_ui_->GetRenderViewHost()->PrintForPrintPreview();
+void PrintPreviewHandler::HandlePrint(const ListValue* args) {
+ std::string json_str;
+ CHECK(args->GetString(0, &json_str)) << "Could not read JSON argument";
Lei Zhang 2011/03/02 23:28:54 I would not do a CHECK here. This would imply if t
kmadhusu 2011/03/04 19:39:02 Fixed.
+ if (json_str.empty()) {
+ NOTREACHED() << "Empty print job settings";
+ return;
+ }
+ scoped_ptr<DictionaryValue> settings(static_cast<DictionaryValue*>(
+ base::JSONReader::Read(json_str, false)));
+ CHECK(settings.get() && settings->IsType(Value::TYPE_DICTIONARY))
+ << "Print job settings must be a dictionary.";
+
+ CHECK(!settings->empty()) << "Print job settings dictionary is empty";
+ web_ui_->GetRenderViewHost()->PrintForPrintPreview(*settings);
}

Powered by Google App Engine
This is Rietveld 408576698