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 "components/printing/renderer/print_web_view_helper.h" | 5 #include "components/printing/renderer/print_web_view_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 web_print_params_.print_content_area.height); | 752 web_print_params_.print_content_area.height); |
753 print_layout_size.set_height( | 753 print_layout_size.set_height( |
754 ScaleAndRound(print_layout_size.height(), kPrintingMinimumShrinkFactor)); | 754 ScaleAndRound(print_layout_size.height(), kPrintingMinimumShrinkFactor)); |
755 | 755 |
756 if (!frame()) | 756 if (!frame()) |
757 return; | 757 return; |
758 | 758 |
759 // Backup size and offset if it's a local frame. | 759 // Backup size and offset if it's a local frame. |
760 blink::WebView* web_view = frame_.view(); | 760 blink::WebView* web_view = frame_.view(); |
761 if (blink::WebFrame* web_frame = web_view->MainFrame()) { | 761 if (blink::WebFrame* web_frame = web_view->MainFrame()) { |
| 762 // TODO(lukasza, weili): Support restoring scroll offset of a remote main |
| 763 // frame - https://crbug.com/734815. |
762 if (web_frame->IsWebLocalFrame()) | 764 if (web_frame->IsWebLocalFrame()) |
763 prev_scroll_offset_ = web_frame->GetScrollOffset(); | 765 prev_scroll_offset_ = web_frame->ToWebLocalFrame()->GetScrollOffset(); |
764 } | 766 } |
765 prev_view_size_ = web_view->Size(); | 767 prev_view_size_ = web_view->Size(); |
766 | 768 |
767 web_view->Resize(print_layout_size); | 769 web_view->Resize(print_layout_size); |
768 } | 770 } |
769 | 771 |
770 void PrepareFrameAndViewForPrint::StartPrinting() { | 772 void PrepareFrameAndViewForPrint::StartPrinting() { |
771 blink::WebView* web_view = frame_.view(); | 773 blink::WebView* web_view = frame_.view(); |
772 web_view->GetSettings()->SetShouldPrintBackgrounds(should_print_backgrounds_); | 774 web_view->GetSettings()->SetShouldPrintBackgrounds(should_print_backgrounds_); |
773 expected_pages_count_ = | 775 expected_pages_count_ = |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 return on_ready_.Run(); // Can delete |this|. | 856 return on_ready_.Run(); // Can delete |this|. |
855 } | 857 } |
856 | 858 |
857 void PrepareFrameAndViewForPrint::RestoreSize() { | 859 void PrepareFrameAndViewForPrint::RestoreSize() { |
858 if (!frame()) | 860 if (!frame()) |
859 return; | 861 return; |
860 | 862 |
861 blink::WebView* web_view = frame_.GetFrame()->View(); | 863 blink::WebView* web_view = frame_.GetFrame()->View(); |
862 web_view->Resize(prev_view_size_); | 864 web_view->Resize(prev_view_size_); |
863 if (blink::WebFrame* web_frame = web_view->MainFrame()) { | 865 if (blink::WebFrame* web_frame = web_view->MainFrame()) { |
| 866 // TODO(lukasza, weili): Support restoring scroll offset of a remote main |
| 867 // frame - https://crbug.com/734815. |
864 if (web_frame->IsWebLocalFrame()) | 868 if (web_frame->IsWebLocalFrame()) |
865 web_frame->SetScrollOffset(prev_scroll_offset_); | 869 web_frame->ToWebLocalFrame()->SetScrollOffset(prev_scroll_offset_); |
866 } | 870 } |
867 } | 871 } |
868 | 872 |
869 void PrepareFrameAndViewForPrint::FinishPrinting() { | 873 void PrepareFrameAndViewForPrint::FinishPrinting() { |
870 blink::WebLocalFrame* frame = frame_.GetFrame(); | 874 blink::WebLocalFrame* frame = frame_.GetFrame(); |
871 if (frame) { | 875 if (frame) { |
872 blink::WebView* web_view = frame->View(); | 876 blink::WebView* web_view = frame->View(); |
873 if (is_printing_started_) { | 877 if (is_printing_started_) { |
874 is_printing_started_ = false; | 878 is_printing_started_ = false; |
875 if (!owns_web_view_) { | 879 if (!owns_web_view_) { |
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 blink::WebConsoleMessage::kLevelWarning, message)); | 2383 blink::WebConsoleMessage::kLevelWarning, message)); |
2380 return false; | 2384 return false; |
2381 } | 2385 } |
2382 | 2386 |
2383 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2387 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
2384 // Reset counter on successful print. | 2388 // Reset counter on successful print. |
2385 count_ = 0; | 2389 count_ = 0; |
2386 } | 2390 } |
2387 | 2391 |
2388 } // namespace printing | 2392 } // namespace printing |
OLD | NEW |