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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 void PrintPreviewUI::OnDidGetPreviewPageCount( | 178 void PrintPreviewUI::OnDidGetPreviewPageCount( |
179 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { | 179 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { |
180 DCHECK_GT(params.page_count, 0); | 180 DCHECK_GT(params.page_count, 0); |
181 base::FundamentalValue count(params.page_count); | 181 base::FundamentalValue count(params.page_count); |
182 base::FundamentalValue request_id(params.preview_request_id); | 182 base::FundamentalValue request_id(params.preview_request_id); |
183 CallJavascriptFunction("onDidGetPreviewPageCount", count, request_id); | 183 CallJavascriptFunction("onDidGetPreviewPageCount", count, request_id); |
184 } | 184 } |
185 | 185 |
186 void PrintPreviewUI::OnDidGetDefaultPageLayout( | 186 void PrintPreviewUI::OnDidGetDefaultPageLayout( |
187 const PageSizeMargins& page_layout) { | 187 const PageSizeMargins& page_layout, bool has_custom_page_size_style) { |
188 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || | 188 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || |
189 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || | 189 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || |
190 page_layout.content_width < 0 || page_layout.content_height < 0) { | 190 page_layout.content_width < 0 || page_layout.content_height < 0) { |
191 NOTREACHED(); | 191 NOTREACHED(); |
192 return; | 192 return; |
193 } | 193 } |
194 | 194 |
195 base::DictionaryValue layout; | 195 base::DictionaryValue layout; |
196 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top); | 196 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top); |
197 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left); | 197 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left); |
198 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom); | 198 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom); |
199 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right); | 199 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right); |
200 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width); | 200 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width); |
201 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height); | 201 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height); |
202 | 202 |
203 CallJavascriptFunction("onDidGetDefaultPageLayout", layout); | 203 base::FundamentalValue has_page_size_style(has_custom_page_size_style); |
| 204 CallJavascriptFunction("onDidGetDefaultPageLayout", layout, |
| 205 has_page_size_style); |
204 } | 206 } |
205 | 207 |
206 void PrintPreviewUI::OnDidPreviewPage(int page_number, | 208 void PrintPreviewUI::OnDidPreviewPage(int page_number, |
207 int preview_request_id) { | 209 int preview_request_id) { |
208 DCHECK_GE(page_number, 0); | 210 DCHECK_GE(page_number, 0); |
209 base::FundamentalValue number(page_number); | 211 base::FundamentalValue number(page_number); |
210 StringValue ui_identifier(preview_ui_addr_str_); | 212 StringValue ui_identifier(preview_ui_addr_str_); |
211 base::FundamentalValue request_id(preview_request_id); | 213 base::FundamentalValue request_id(preview_request_id); |
212 CallJavascriptFunction("onDidPreviewPage", number, ui_identifier, request_id); | 214 CallJavascriptFunction("onDidPreviewPage", number, ui_identifier, request_id); |
213 } | 215 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); | 287 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); |
286 if (!delegate) | 288 if (!delegate) |
287 return; | 289 return; |
288 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(""); | 290 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(""); |
289 delegate->OnDialogCloseFromWebUI(); | 291 delegate->OnDialogCloseFromWebUI(); |
290 } | 292 } |
291 | 293 |
292 void PrintPreviewUI::OnReloadPrintersList() { | 294 void PrintPreviewUI::OnReloadPrintersList() { |
293 CallJavascriptFunction("reloadPrintersList"); | 295 CallJavascriptFunction("reloadPrintersList"); |
294 } | 296 } |
OLD | NEW |