OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/print_preview_ui.h" | 5 #include "chrome/browser/ui/webui/print_preview/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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { | 199 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { |
200 DCHECK_GT(params.page_count, 0); | 200 DCHECK_GT(params.page_count, 0); |
201 base::FundamentalValue count(params.page_count); | 201 base::FundamentalValue count(params.page_count); |
202 base::FundamentalValue request_id(params.preview_request_id); | 202 base::FundamentalValue request_id(params.preview_request_id); |
203 web_ui()->CallJavascriptFunction("onDidGetPreviewPageCount", | 203 web_ui()->CallJavascriptFunction("onDidGetPreviewPageCount", |
204 count, | 204 count, |
205 request_id); | 205 request_id); |
206 } | 206 } |
207 | 207 |
208 void PrintPreviewUI::OnDidGetDefaultPageLayout( | 208 void PrintPreviewUI::OnDidGetDefaultPageLayout( |
209 const PageSizeMargins& page_layout, bool has_custom_page_size_style) { | 209 const PageSizeMargins& page_layout, bool has_custom_page_size_style, |
| 210 bool header_footer_applies) { |
210 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || | 211 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || |
211 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || | 212 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || |
212 page_layout.content_width < 0 || page_layout.content_height < 0) { | 213 page_layout.content_width < 0 || page_layout.content_height < 0) { |
213 NOTREACHED(); | 214 NOTREACHED(); |
214 return; | 215 return; |
215 } | 216 } |
216 | 217 |
217 base::DictionaryValue layout; | 218 base::DictionaryValue layout; |
218 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top); | 219 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top); |
219 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left); | 220 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left); |
220 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom); | 221 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom); |
221 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right); | 222 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right); |
222 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width); | 223 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width); |
223 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height); | 224 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height); |
224 | 225 |
225 base::FundamentalValue has_page_size_style(has_custom_page_size_style); | 226 base::FundamentalValue has_page_size_style(has_custom_page_size_style); |
| 227 base::FundamentalValue has_header_footer_option(header_footer_applies); |
226 web_ui()->CallJavascriptFunction("onDidGetDefaultPageLayout", layout, | 228 web_ui()->CallJavascriptFunction("onDidGetDefaultPageLayout", layout, |
227 has_page_size_style); | 229 has_page_size_style, |
| 230 has_header_footer_option); |
228 } | 231 } |
229 | 232 |
230 void PrintPreviewUI::OnDidPreviewPage(int page_number, | 233 void PrintPreviewUI::OnDidPreviewPage(int page_number, |
231 int preview_request_id) { | 234 int preview_request_id) { |
232 DCHECK_GE(page_number, 0); | 235 DCHECK_GE(page_number, 0); |
233 base::FundamentalValue number(page_number); | 236 base::FundamentalValue number(page_number); |
234 StringValue ui_identifier(preview_ui_addr_str_); | 237 StringValue ui_identifier(preview_ui_addr_str_); |
235 base::FundamentalValue request_id(preview_request_id); | 238 base::FundamentalValue request_id(preview_request_id); |
236 web_ui()->CallJavascriptFunction( | 239 web_ui()->CallJavascriptFunction( |
237 "onDidPreviewPage", number, ui_identifier, request_id); | 240 "onDidPreviewPage", number, ui_identifier, request_id); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); | 314 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); |
312 if (!delegate) | 315 if (!delegate) |
313 return; | 316 return; |
314 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(""); | 317 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(""); |
315 delegate->OnDialogCloseFromWebUI(); | 318 delegate->OnDialogCloseFromWebUI(); |
316 } | 319 } |
317 | 320 |
318 void PrintPreviewUI::OnReloadPrintersList() { | 321 void PrintPreviewUI::OnReloadPrintersList() { |
319 web_ui()->CallJavascriptFunction("reloadPrintersList"); | 322 web_ui()->CallJavascriptFunction("reloadPrintersList"); |
320 } | 323 } |
OLD | NEW |