Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: chrome/browser/ui/webui/print_preview_ui.cc

Issue 8585017: PrintPreview: Honor the print media page size and margin values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 void PrintPreviewUI::OnDidGetPreviewPageCount( 186 void PrintPreviewUI::OnDidGetPreviewPageCount(
187 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { 187 const PrintHostMsg_DidGetPreviewPageCount_Params& params) {
188 DCHECK_GT(params.page_count, 0); 188 DCHECK_GT(params.page_count, 0);
189 base::FundamentalValue count(params.page_count); 189 base::FundamentalValue count(params.page_count);
190 base::FundamentalValue request_id(params.preview_request_id); 190 base::FundamentalValue request_id(params.preview_request_id);
191 CallJavascriptFunction("onDidGetPreviewPageCount", count, request_id); 191 CallJavascriptFunction("onDidGetPreviewPageCount", count, request_id);
192 } 192 }
193 193
194 void PrintPreviewUI::OnDidGetDefaultPageLayout( 194 void PrintPreviewUI::OnDidGetDefaultPageLayout(
195 const PageSizeMargins& page_layout) { 195 const PageSizeMargins& page_layout, bool has_custom_page_size_style) {
196 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || 196 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 ||
197 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || 197 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 ||
198 page_layout.content_width < 0 || page_layout.content_height < 0) { 198 page_layout.content_width < 0 || page_layout.content_height < 0) {
199 NOTREACHED(); 199 NOTREACHED();
200 return; 200 return;
201 } 201 }
202 202
203 base::DictionaryValue layout; 203 base::DictionaryValue layout;
204 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top); 204 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top);
205 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left); 205 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left);
206 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom); 206 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom);
207 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right); 207 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right);
208 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width); 208 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width);
209 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height); 209 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height);
210 210
211 CallJavascriptFunction("onDidGetDefaultPageLayout", layout); 211 base::FundamentalValue has_page_size_style(has_custom_page_size_style);
212 CallJavascriptFunction("onDidGetDefaultPageLayout", layout,
213 has_page_size_style);
212 } 214 }
213 215
214 void PrintPreviewUI::OnDidPreviewPage(int page_number, 216 void PrintPreviewUI::OnDidPreviewPage(int page_number,
215 int preview_request_id) { 217 int preview_request_id) {
216 DCHECK_GE(page_number, 0); 218 DCHECK_GE(page_number, 0);
217 base::FundamentalValue number(page_number); 219 base::FundamentalValue number(page_number);
218 StringValue ui_identifier(preview_ui_addr_str_); 220 StringValue ui_identifier(preview_ui_addr_str_);
219 base::FundamentalValue request_id(preview_request_id); 221 base::FundamentalValue request_id(preview_request_id);
220 CallJavascriptFunction("onDidPreviewPage", number, ui_identifier, request_id); 222 CallJavascriptFunction("onDidPreviewPage", number, ui_identifier, request_id);
221 } 223 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); 295 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate();
294 if (!delegate) 296 if (!delegate)
295 return; 297 return;
296 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(""); 298 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed("");
297 delegate->OnDialogCloseFromWebUI(); 299 delegate->OnDialogCloseFromWebUI();
298 } 300 }
299 301
300 void PrintPreviewUI::OnReloadPrintersList() { 302 void PrintPreviewUI::OnReloadPrintersList() {
301 CallJavascriptFunction("reloadPrintersList"); 303 CallJavascriptFunction("reloadPrintersList");
302 } 304 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698