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