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

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

Issue 2666093002: Remove base::FundamentalValue (Closed)
Patch Set: Rebase Created 3 years, 9 months 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
OLDNEW
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 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 void PrintPreviewUI::OnShowSystemDialog() { 550 void PrintPreviewUI::OnShowSystemDialog() {
551 web_ui()->CallJavascriptFunctionUnsafe("onSystemDialogLinkClicked"); 551 web_ui()->CallJavascriptFunctionUnsafe("onSystemDialogLinkClicked");
552 } 552 }
553 #endif // ENABLE_BASIC_PRINTING 553 #endif // ENABLE_BASIC_PRINTING
554 554
555 void PrintPreviewUI::OnDidGetPreviewPageCount( 555 void PrintPreviewUI::OnDidGetPreviewPageCount(
556 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { 556 const PrintHostMsg_DidGetPreviewPageCount_Params& params) {
557 DCHECK_GT(params.page_count, 0); 557 DCHECK_GT(params.page_count, 0);
558 if (g_testing_delegate) 558 if (g_testing_delegate)
559 g_testing_delegate->DidGetPreviewPageCount(params.page_count); 559 g_testing_delegate->DidGetPreviewPageCount(params.page_count);
560 base::FundamentalValue count(params.page_count); 560 base::Value count(params.page_count);
561 base::FundamentalValue request_id(params.preview_request_id); 561 base::Value request_id(params.preview_request_id);
562 base::FundamentalValue fit_to_page_scaling(params.fit_to_page_scaling); 562 base::Value fit_to_page_scaling(params.fit_to_page_scaling);
563 web_ui()->CallJavascriptFunctionUnsafe("onDidGetPreviewPageCount", count, 563 web_ui()->CallJavascriptFunctionUnsafe("onDidGetPreviewPageCount", count,
564 request_id, fit_to_page_scaling); 564 request_id, fit_to_page_scaling);
565 } 565 }
566 566
567 void PrintPreviewUI::OnDidGetDefaultPageLayout( 567 void PrintPreviewUI::OnDidGetDefaultPageLayout(
568 const PageSizeMargins& page_layout, const gfx::Rect& printable_area, 568 const PageSizeMargins& page_layout, const gfx::Rect& printable_area,
569 bool has_custom_page_size_style) { 569 bool has_custom_page_size_style) {
570 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || 570 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 ||
571 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || 571 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 ||
572 page_layout.content_width < 0 || page_layout.content_height < 0 || 572 page_layout.content_width < 0 || page_layout.content_height < 0 ||
573 printable_area.width() <= 0 || printable_area.height() <= 0) { 573 printable_area.width() <= 0 || printable_area.height() <= 0) {
574 NOTREACHED(); 574 NOTREACHED();
575 return; 575 return;
576 } 576 }
577 577
578 base::DictionaryValue layout; 578 base::DictionaryValue layout;
579 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top); 579 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top);
580 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left); 580 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left);
581 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom); 581 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom);
582 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right); 582 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right);
583 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width); 583 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width);
584 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height); 584 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height);
585 layout.SetInteger(printing::kSettingPrintableAreaX, printable_area.x()); 585 layout.SetInteger(printing::kSettingPrintableAreaX, printable_area.x());
586 layout.SetInteger(printing::kSettingPrintableAreaY, printable_area.y()); 586 layout.SetInteger(printing::kSettingPrintableAreaY, printable_area.y());
587 layout.SetInteger(printing::kSettingPrintableAreaWidth, 587 layout.SetInteger(printing::kSettingPrintableAreaWidth,
588 printable_area.width()); 588 printable_area.width());
589 layout.SetInteger(printing::kSettingPrintableAreaHeight, 589 layout.SetInteger(printing::kSettingPrintableAreaHeight,
590 printable_area.height()); 590 printable_area.height());
591 591
592 base::FundamentalValue has_page_size_style(has_custom_page_size_style); 592 base::Value has_page_size_style(has_custom_page_size_style);
593 web_ui()->CallJavascriptFunctionUnsafe("onDidGetDefaultPageLayout", layout, 593 web_ui()->CallJavascriptFunctionUnsafe("onDidGetDefaultPageLayout", layout,
594 has_page_size_style); 594 has_page_size_style);
595 } 595 }
596 596
597 void PrintPreviewUI::OnDidPreviewPage(int page_number, 597 void PrintPreviewUI::OnDidPreviewPage(int page_number,
598 int preview_request_id) { 598 int preview_request_id) {
599 DCHECK_GE(page_number, 0); 599 DCHECK_GE(page_number, 0);
600 base::FundamentalValue number(page_number); 600 base::Value number(page_number);
601 base::FundamentalValue ui_identifier(id_); 601 base::Value ui_identifier(id_);
602 base::FundamentalValue request_id(preview_request_id); 602 base::Value request_id(preview_request_id);
603 if (g_testing_delegate) 603 if (g_testing_delegate)
604 g_testing_delegate->DidRenderPreviewPage(web_ui()->GetWebContents()); 604 g_testing_delegate->DidRenderPreviewPage(web_ui()->GetWebContents());
605 web_ui()->CallJavascriptFunctionUnsafe("onDidPreviewPage", number, 605 web_ui()->CallJavascriptFunctionUnsafe("onDidPreviewPage", number,
606 ui_identifier, request_id); 606 ui_identifier, request_id);
607 } 607 }
608 608
609 void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count, 609 void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count,
610 int preview_request_id) { 610 int preview_request_id) {
611 VLOG(1) << "Print preview request finished with " 611 VLOG(1) << "Print preview request finished with "
612 << expected_pages_count << " pages"; 612 << expected_pages_count << " pages";
613 613
614 if (!initial_preview_start_time_.is_null()) { 614 if (!initial_preview_start_time_.is_null()) {
615 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime", 615 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime",
616 base::TimeTicks::Now() - initial_preview_start_time_); 616 base::TimeTicks::Now() - initial_preview_start_time_);
617 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial", 617 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial",
618 expected_pages_count); 618 expected_pages_count);
619 UMA_HISTOGRAM_COUNTS( 619 UMA_HISTOGRAM_COUNTS(
620 "PrintPreview.RegeneratePreviewRequest.BeforeFirstData", 620 "PrintPreview.RegeneratePreviewRequest.BeforeFirstData",
621 handler_->regenerate_preview_request_count()); 621 handler_->regenerate_preview_request_count());
622 initial_preview_start_time_ = base::TimeTicks(); 622 initial_preview_start_time_ = base::TimeTicks();
623 } 623 }
624 base::FundamentalValue ui_identifier(id_); 624 base::Value ui_identifier(id_);
625 base::FundamentalValue ui_preview_request_id(preview_request_id); 625 base::Value ui_preview_request_id(preview_request_id);
626 web_ui()->CallJavascriptFunctionUnsafe("updatePrintPreview", ui_identifier, 626 web_ui()->CallJavascriptFunctionUnsafe("updatePrintPreview", ui_identifier,
627 ui_preview_request_id); 627 ui_preview_request_id);
628 } 628 }
629 629
630 void PrintPreviewUI::OnFileSelectionCancelled() { 630 void PrintPreviewUI::OnFileSelectionCancelled() {
631 web_ui()->CallJavascriptFunctionUnsafe("fileSelectionCancelled"); 631 web_ui()->CallJavascriptFunctionUnsafe("fileSelectionCancelled");
632 } 632 }
633 633
634 void PrintPreviewUI::OnCancelPendingPreviewRequest() { 634 void PrintPreviewUI::OnCancelPendingPreviewRequest() {
635 g_print_preview_request_id_map.Get().Set(id_, -1); 635 g_print_preview_request_id_map.Get().Set(id_, -1);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 } 695 }
696 696
697 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { 697 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) {
698 handler_->FileSelected(path, 0, NULL); 698 handler_->FileSelected(path, 0, NULL);
699 } 699 }
700 700
701 void PrintPreviewUI::SetPdfSavedClosureForTesting( 701 void PrintPreviewUI::SetPdfSavedClosureForTesting(
702 const base::Closure& closure) { 702 const base::Closure& closure) {
703 handler_->SetPdfSavedClosureForTesting(closure); 703 handler_->SetPdfSavedClosureForTesting(closure);
704 } 704 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698