| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/printing/print_dialog_cloud.h" | 5 #include "chrome/browser/printing/print_dialog_cloud.h" |
| 6 #include "chrome/browser/printing/print_dialog_cloud_internal.h" | 6 #include "chrome/browser/printing/print_dialog_cloud_internal.h" |
| 7 | 7 |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // that the dialog should be closed, at which point things are torn | 99 // that the dialog should be closed, at which point things are torn |
| 100 // down and released. | 100 // down and released. |
| 101 | 101 |
| 102 // TODO(scottbyer): | 102 // TODO(scottbyer): |
| 103 // http://code.google.com/p/chromium/issues/detail?id=44093 The | 103 // http://code.google.com/p/chromium/issues/detail?id=44093 The |
| 104 // high-level flow (where the PDF data is generated before even | 104 // high-level flow (where the PDF data is generated before even |
| 105 // bringing up the dialog) isn't what we want. | 105 // bringing up the dialog) isn't what we want. |
| 106 | 106 |
| 107 namespace internal_cloud_print_helpers { | 107 namespace internal_cloud_print_helpers { |
| 108 | 108 |
| 109 bool GetRealOrInt(const DictionaryValue& dictionary, | 109 bool GetDoubleOrInt(const DictionaryValue& dictionary, |
| 110 const std::string& path, | 110 const std::string& path, |
| 111 double* out_value) { | 111 double* out_value) { |
| 112 if (!dictionary.GetReal(path, out_value)) { | 112 if (!dictionary.GetDouble(path, out_value)) { |
| 113 int int_value = 0; | 113 int int_value = 0; |
| 114 if (!dictionary.GetInteger(path, &int_value)) | 114 if (!dictionary.GetInteger(path, &int_value)) |
| 115 return false; | 115 return false; |
| 116 *out_value = int_value; | 116 *out_value = int_value; |
| 117 } | 117 } |
| 118 return true; | 118 return true; |
| 119 } | 119 } |
| 120 | 120 |
| 121 // From the JSON parsed value, get the entries for the page setup | 121 // From the JSON parsed value, get the entries for the page setup |
| 122 // parameters. | 122 // parameters. |
| 123 bool GetPageSetupParameters(const std::string& json, | 123 bool GetPageSetupParameters(const std::string& json, |
| 124 ViewMsg_Print_Params& parameters) { | 124 ViewMsg_Print_Params& parameters) { |
| 125 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); | 125 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); |
| 126 DLOG_IF(ERROR, (!parsed_value.get() || | 126 DLOG_IF(ERROR, (!parsed_value.get() || |
| 127 !parsed_value->IsType(Value::TYPE_DICTIONARY))) | 127 !parsed_value->IsType(Value::TYPE_DICTIONARY))) |
| 128 << "PageSetup call didn't have expected contents"; | 128 << "PageSetup call didn't have expected contents"; |
| 129 if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) | 129 if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) |
| 130 return false; | 130 return false; |
| 131 | 131 |
| 132 bool result = true; | 132 bool result = true; |
| 133 DictionaryValue* params = static_cast<DictionaryValue*>(parsed_value.get()); | 133 DictionaryValue* params = static_cast<DictionaryValue*>(parsed_value.get()); |
| 134 result &= GetRealOrInt(*params, "dpi", ¶meters.dpi); | 134 result &= GetDoubleOrInt(*params, "dpi", ¶meters.dpi); |
| 135 result &= GetRealOrInt(*params, "min_shrink", ¶meters.min_shrink); | 135 result &= GetDoubleOrInt(*params, "min_shrink", ¶meters.min_shrink); |
| 136 result &= GetRealOrInt(*params, "max_shrink", ¶meters.max_shrink); | 136 result &= GetDoubleOrInt(*params, "max_shrink", ¶meters.max_shrink); |
| 137 result &= params->GetBoolean("selection_only", ¶meters.selection_only); | 137 result &= params->GetBoolean("selection_only", ¶meters.selection_only); |
| 138 return result; | 138 return result; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void CloudPrintDataSenderHelper::CallJavascriptFunction( | 141 void CloudPrintDataSenderHelper::CallJavascriptFunction( |
| 142 const std::wstring& function_name) { | 142 const std::wstring& function_name) { |
| 143 dom_ui_->CallJavascriptFunction(function_name); | 143 dom_ui_->CallJavascriptFunction(function_name); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void CloudPrintDataSenderHelper::CallJavascriptFunction( | 146 void CloudPrintDataSenderHelper::CallJavascriptFunction( |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 #elif defined(TOOLKIT_GTK) | 578 #elif defined(TOOLKIT_GTK) |
| 579 HtmlDialogGtk* html_dialog = | 579 HtmlDialogGtk* html_dialog = |
| 580 new HtmlDialogGtk(profile, dialog_delegate, NULL); | 580 new HtmlDialogGtk(profile, dialog_delegate, NULL); |
| 581 html_dialog->InitDialog(); | 581 html_dialog->InitDialog(); |
| 582 #endif // defined(TOOLKIT_VIEWS) | 582 #endif // defined(TOOLKIT_VIEWS) |
| 583 } | 583 } |
| 584 } | 584 } |
| 585 | 585 |
| 586 PrintDialogCloud::~PrintDialogCloud() { | 586 PrintDialogCloud::~PrintDialogCloud() { |
| 587 } | 587 } |
| OLD | NEW |