| 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/ui/webui/print_preview_ui.h" | 5 #include "chrome/browser/ui/webui/print_preview_ui.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 195 |
| 196 void PrintPreviewUI::OnDidGetPreviewPageCount( | 196 void PrintPreviewUI::OnDidGetPreviewPageCount( |
| 197 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { | 197 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { |
| 198 DCHECK_GT(params.page_count, 0); | 198 DCHECK_GT(params.page_count, 0); |
| 199 base::FundamentalValue count(params.page_count); | 199 base::FundamentalValue count(params.page_count); |
| 200 base::FundamentalValue request_id(params.preview_request_id); | 200 base::FundamentalValue request_id(params.preview_request_id); |
| 201 CallJavascriptFunction("onDidGetPreviewPageCount", count, request_id); | 201 CallJavascriptFunction("onDidGetPreviewPageCount", count, request_id); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void PrintPreviewUI::OnDidGetDefaultPageLayout( | 204 void PrintPreviewUI::OnDidGetDefaultPageLayout( |
| 205 const PageSizeMargins& page_layout) { | 205 const PageSizeMargins& page_layout, bool has_custom_page_size_style) { |
| 206 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || | 206 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || |
| 207 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || | 207 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || |
| 208 page_layout.content_width < 0 || page_layout.content_height < 0) { | 208 page_layout.content_width < 0 || page_layout.content_height < 0) { |
| 209 NOTREACHED(); | 209 NOTREACHED(); |
| 210 return; | 210 return; |
| 211 } | 211 } |
| 212 | 212 |
| 213 base::DictionaryValue layout; | 213 base::DictionaryValue layout; |
| 214 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top); | 214 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top); |
| 215 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left); | 215 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left); |
| 216 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom); | 216 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom); |
| 217 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right); | 217 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right); |
| 218 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width); | 218 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width); |
| 219 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height); | 219 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height); |
| 220 | 220 |
| 221 CallJavascriptFunction("onDidGetDefaultPageLayout", layout); | 221 base::FundamentalValue has_page_size_style(has_custom_page_size_style); |
| 222 CallJavascriptFunction("onDidGetDefaultPageLayout", layout, |
| 223 has_page_size_style); |
| 222 } | 224 } |
| 223 | 225 |
| 224 void PrintPreviewUI::OnDidPreviewPage(int page_number, | 226 void PrintPreviewUI::OnDidPreviewPage(int page_number, |
| 225 int preview_request_id) { | 227 int preview_request_id) { |
| 226 DCHECK_GE(page_number, 0); | 228 DCHECK_GE(page_number, 0); |
| 227 base::FundamentalValue number(page_number); | 229 base::FundamentalValue number(page_number); |
| 228 StringValue ui_identifier(preview_ui_addr_str_); | 230 StringValue ui_identifier(preview_ui_addr_str_); |
| 229 base::FundamentalValue request_id(preview_request_id); | 231 base::FundamentalValue request_id(preview_request_id); |
| 230 CallJavascriptFunction("onDidPreviewPage", number, ui_identifier, request_id); | 232 CallJavascriptFunction("onDidPreviewPage", number, ui_identifier, request_id); |
| 231 } | 233 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); | 305 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); |
| 304 if (!delegate) | 306 if (!delegate) |
| 305 return; | 307 return; |
| 306 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(""); | 308 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(""); |
| 307 delegate->OnDialogCloseFromWebUI(); | 309 delegate->OnDialogCloseFromWebUI(); |
| 308 } | 310 } |
| 309 | 311 |
| 310 void PrintPreviewUI::OnReloadPrintersList() { | 312 void PrintPreviewUI::OnReloadPrintersList() { |
| 311 CallJavascriptFunction("reloadPrintersList"); | 313 CallJavascriptFunction("reloadPrintersList"); |
| 312 } | 314 } |
| OLD | NEW |