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

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

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years, 1 month 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 <vector> 8 #include <vector>
9 9
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 void PrintPreviewUI::OnShowSystemDialog() { 536 void PrintPreviewUI::OnShowSystemDialog() {
537 web_ui()->CallJavascriptFunctionUnsafe("onSystemDialogLinkClicked"); 537 web_ui()->CallJavascriptFunctionUnsafe("onSystemDialogLinkClicked");
538 } 538 }
539 #endif // ENABLE_BASIC_PRINTING 539 #endif // ENABLE_BASIC_PRINTING
540 540
541 void PrintPreviewUI::OnDidGetPreviewPageCount( 541 void PrintPreviewUI::OnDidGetPreviewPageCount(
542 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { 542 const PrintHostMsg_DidGetPreviewPageCount_Params& params) {
543 DCHECK_GT(params.page_count, 0); 543 DCHECK_GT(params.page_count, 0);
544 if (g_testing_delegate) 544 if (g_testing_delegate)
545 g_testing_delegate->DidGetPreviewPageCount(params.page_count); 545 g_testing_delegate->DidGetPreviewPageCount(params.page_count);
546 base::FundamentalValue count(params.page_count); 546 base::Value count(params.page_count);
547 base::FundamentalValue request_id(params.preview_request_id); 547 base::Value request_id(params.preview_request_id);
548 base::FundamentalValue fit_to_page_scaling(params.fit_to_page_scaling); 548 base::Value fit_to_page_scaling(params.fit_to_page_scaling);
549 web_ui()->CallJavascriptFunctionUnsafe("onDidGetPreviewPageCount", count, 549 web_ui()->CallJavascriptFunctionUnsafe("onDidGetPreviewPageCount", count,
550 request_id, fit_to_page_scaling); 550 request_id, fit_to_page_scaling);
551 } 551 }
552 552
553 void PrintPreviewUI::OnDidGetDefaultPageLayout( 553 void PrintPreviewUI::OnDidGetDefaultPageLayout(
554 const PageSizeMargins& page_layout, const gfx::Rect& printable_area, 554 const PageSizeMargins& page_layout, const gfx::Rect& printable_area,
555 bool has_custom_page_size_style) { 555 bool has_custom_page_size_style) {
556 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || 556 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 ||
557 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || 557 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 ||
558 page_layout.content_width < 0 || page_layout.content_height < 0 || 558 page_layout.content_width < 0 || page_layout.content_height < 0 ||
559 printable_area.width() <= 0 || printable_area.height() <= 0) { 559 printable_area.width() <= 0 || printable_area.height() <= 0) {
560 NOTREACHED(); 560 NOTREACHED();
561 return; 561 return;
562 } 562 }
563 563
564 base::DictionaryValue layout; 564 base::DictionaryValue layout;
565 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top); 565 layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top);
566 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left); 566 layout.SetDouble(printing::kSettingMarginLeft, page_layout.margin_left);
567 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom); 567 layout.SetDouble(printing::kSettingMarginBottom, page_layout.margin_bottom);
568 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right); 568 layout.SetDouble(printing::kSettingMarginRight, page_layout.margin_right);
569 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width); 569 layout.SetDouble(printing::kSettingContentWidth, page_layout.content_width);
570 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height); 570 layout.SetDouble(printing::kSettingContentHeight, page_layout.content_height);
571 layout.SetInteger(printing::kSettingPrintableAreaX, printable_area.x()); 571 layout.SetInteger(printing::kSettingPrintableAreaX, printable_area.x());
572 layout.SetInteger(printing::kSettingPrintableAreaY, printable_area.y()); 572 layout.SetInteger(printing::kSettingPrintableAreaY, printable_area.y());
573 layout.SetInteger(printing::kSettingPrintableAreaWidth, 573 layout.SetInteger(printing::kSettingPrintableAreaWidth,
574 printable_area.width()); 574 printable_area.width());
575 layout.SetInteger(printing::kSettingPrintableAreaHeight, 575 layout.SetInteger(printing::kSettingPrintableAreaHeight,
576 printable_area.height()); 576 printable_area.height());
577 577
578 base::FundamentalValue has_page_size_style(has_custom_page_size_style); 578 base::Value has_page_size_style(has_custom_page_size_style);
579 web_ui()->CallJavascriptFunctionUnsafe("onDidGetDefaultPageLayout", layout, 579 web_ui()->CallJavascriptFunctionUnsafe("onDidGetDefaultPageLayout", layout,
580 has_page_size_style); 580 has_page_size_style);
581 } 581 }
582 582
583 void PrintPreviewUI::OnDidPreviewPage(int page_number, 583 void PrintPreviewUI::OnDidPreviewPage(int page_number,
584 int preview_request_id) { 584 int preview_request_id) {
585 DCHECK_GE(page_number, 0); 585 DCHECK_GE(page_number, 0);
586 base::FundamentalValue number(page_number); 586 base::Value number(page_number);
587 base::FundamentalValue ui_identifier(id_); 587 base::Value ui_identifier(id_);
588 base::FundamentalValue request_id(preview_request_id); 588 base::Value request_id(preview_request_id);
589 if (g_testing_delegate) 589 if (g_testing_delegate)
590 g_testing_delegate->DidRenderPreviewPage(web_ui()->GetWebContents()); 590 g_testing_delegate->DidRenderPreviewPage(web_ui()->GetWebContents());
591 web_ui()->CallJavascriptFunctionUnsafe("onDidPreviewPage", number, 591 web_ui()->CallJavascriptFunctionUnsafe("onDidPreviewPage", number,
592 ui_identifier, request_id); 592 ui_identifier, request_id);
593 if (g_testing_delegate && g_testing_delegate->IsAutoCancelEnabled()) 593 if (g_testing_delegate && g_testing_delegate->IsAutoCancelEnabled())
594 web_ui()->CallJavascriptFunctionUnsafe("autoCancelForTesting"); 594 web_ui()->CallJavascriptFunctionUnsafe("autoCancelForTesting");
595 } 595 }
596 596
597 void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count, 597 void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count,
598 int preview_request_id) { 598 int preview_request_id) {
599 VLOG(1) << "Print preview request finished with " 599 VLOG(1) << "Print preview request finished with "
600 << expected_pages_count << " pages"; 600 << expected_pages_count << " pages";
601 601
602 if (!initial_preview_start_time_.is_null()) { 602 if (!initial_preview_start_time_.is_null()) {
603 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime", 603 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime",
604 base::TimeTicks::Now() - initial_preview_start_time_); 604 base::TimeTicks::Now() - initial_preview_start_time_);
605 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial", 605 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial",
606 expected_pages_count); 606 expected_pages_count);
607 UMA_HISTOGRAM_COUNTS( 607 UMA_HISTOGRAM_COUNTS(
608 "PrintPreview.RegeneratePreviewRequest.BeforeFirstData", 608 "PrintPreview.RegeneratePreviewRequest.BeforeFirstData",
609 handler_->regenerate_preview_request_count()); 609 handler_->regenerate_preview_request_count());
610 initial_preview_start_time_ = base::TimeTicks(); 610 initial_preview_start_time_ = base::TimeTicks();
611 } 611 }
612 base::FundamentalValue ui_identifier(id_); 612 base::Value ui_identifier(id_);
613 base::FundamentalValue ui_preview_request_id(preview_request_id); 613 base::Value ui_preview_request_id(preview_request_id);
614 web_ui()->CallJavascriptFunctionUnsafe("updatePrintPreview", ui_identifier, 614 web_ui()->CallJavascriptFunctionUnsafe("updatePrintPreview", ui_identifier,
615 ui_preview_request_id); 615 ui_preview_request_id);
616 } 616 }
617 617
618 void PrintPreviewUI::OnFileSelectionCancelled() { 618 void PrintPreviewUI::OnFileSelectionCancelled() {
619 web_ui()->CallJavascriptFunctionUnsafe("fileSelectionCancelled"); 619 web_ui()->CallJavascriptFunctionUnsafe("fileSelectionCancelled");
620 } 620 }
621 621
622 void PrintPreviewUI::OnCancelPendingPreviewRequest() { 622 void PrintPreviewUI::OnCancelPendingPreviewRequest() {
623 g_print_preview_request_id_map.Get().Set(id_, -1); 623 g_print_preview_request_id_map.Get().Set(id_, -1);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 683 }
684 684
685 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { 685 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) {
686 handler_->FileSelected(path, 0, NULL); 686 handler_->FileSelected(path, 0, NULL);
687 } 687 }
688 688
689 void PrintPreviewUI::SetPdfSavedClosureForTesting( 689 void PrintPreviewUI::SetPdfSavedClosureForTesting(
690 const base::Closure& closure) { 690 const base::Closure& closure) {
691 handler_->SetPdfSavedClosureForTesting(closure); 691 handler_->SetPdfSavedClosureForTesting(closure);
692 } 692 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698