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); |
} |