| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "grit/components_resources.h" | 25 #include "grit/components_resources.h" |
| 26 #include "net/base/escape.h" | 26 #include "net/base/escape.h" |
| 27 #include "printing/pdf_metafile_skia.h" | 27 #include "printing/pdf_metafile_skia.h" |
| 28 #include "printing/units.h" | 28 #include "printing/units.h" |
| 29 #include "third_party/WebKit/public/platform/WebSize.h" | 29 #include "third_party/WebKit/public/platform/WebSize.h" |
| 30 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 30 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 31 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 31 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 32 #include "third_party/WebKit/public/web/WebDocument.h" | 32 #include "third_party/WebKit/public/web/WebDocument.h" |
| 33 #include "third_party/WebKit/public/web/WebElement.h" | 33 #include "third_party/WebKit/public/web/WebElement.h" |
| 34 #include "third_party/WebKit/public/web/WebFrameClient.h" | 34 #include "third_party/WebKit/public/web/WebFrameClient.h" |
| 35 #include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" |
| 35 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 36 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 36 #include "third_party/WebKit/public/web/WebPlugin.h" | 37 #include "third_party/WebKit/public/web/WebPlugin.h" |
| 37 #include "third_party/WebKit/public/web/WebPluginDocument.h" | 38 #include "third_party/WebKit/public/web/WebPluginDocument.h" |
| 38 #include "third_party/WebKit/public/web/WebPrintParams.h" | 39 #include "third_party/WebKit/public/web/WebPrintParams.h" |
| 39 #include "third_party/WebKit/public/web/WebPrintPresetOptions.h" | 40 #include "third_party/WebKit/public/web/WebPrintPresetOptions.h" |
| 40 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 41 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 41 #include "third_party/WebKit/public/web/WebScriptSource.h" | 42 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 42 #include "third_party/WebKit/public/web/WebSettings.h" | 43 #include "third_party/WebKit/public/web/WebSettings.h" |
| 43 #include "third_party/WebKit/public/web/WebView.h" | 44 #include "third_party/WebKit/public/web/WebView.h" |
| 44 #include "third_party/WebKit/public/web/WebViewClient.h" | 45 #include "third_party/WebKit/public/web/WebViewClient.h" |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 void didStopLoading() override; | 589 void didStopLoading() override; |
| 589 // TODO(ojan): Remove this override and have this class use a non-null | 590 // TODO(ojan): Remove this override and have this class use a non-null |
| 590 // layerTreeView. | 591 // layerTreeView. |
| 591 bool allowsBrokenNullLayerTreeView() const override; | 592 bool allowsBrokenNullLayerTreeView() const override; |
| 592 | 593 |
| 593 // blink::WebFrameClient: | 594 // blink::WebFrameClient: |
| 594 blink::WebFrame* createChildFrame( | 595 blink::WebFrame* createChildFrame( |
| 595 blink::WebLocalFrame* parent, | 596 blink::WebLocalFrame* parent, |
| 596 blink::WebTreeScopeType scope, | 597 blink::WebTreeScopeType scope, |
| 597 const blink::WebString& name, | 598 const blink::WebString& name, |
| 598 blink::WebSandboxFlags sandboxFlags) override; | 599 blink::WebSandboxFlags sandboxFlags, |
| 600 const blink::WebFrameOwnerProperties& frameOwnerProperties) override; |
| 599 void frameDetached(blink::WebFrame* frame, DetachType type) override; | 601 void frameDetached(blink::WebFrame* frame, DetachType type) override; |
| 600 | 602 |
| 601 void CallOnReady(); | 603 void CallOnReady(); |
| 602 void ResizeForPrinting(); | 604 void ResizeForPrinting(); |
| 603 void RestoreSize(); | 605 void RestoreSize(); |
| 604 void CopySelection(const WebPreferences& preferences); | 606 void CopySelection(const WebPreferences& preferences); |
| 605 | 607 |
| 606 FrameReference frame_; | 608 FrameReference frame_; |
| 607 blink::WebNode node_to_print_; | 609 blink::WebNode node_to_print_; |
| 608 bool owns_web_view_; | 610 bool owns_web_view_; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 // called didStopLoading. | 733 // called didStopLoading. |
| 732 base::ThreadTaskRunnerHandle::Get()->PostTask( | 734 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 733 FROM_HERE, base::Bind(&PrepareFrameAndViewForPrint::CallOnReady, | 735 FROM_HERE, base::Bind(&PrepareFrameAndViewForPrint::CallOnReady, |
| 734 weak_ptr_factory_.GetWeakPtr())); | 736 weak_ptr_factory_.GetWeakPtr())); |
| 735 } | 737 } |
| 736 | 738 |
| 737 blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame( | 739 blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame( |
| 738 blink::WebLocalFrame* parent, | 740 blink::WebLocalFrame* parent, |
| 739 blink::WebTreeScopeType scope, | 741 blink::WebTreeScopeType scope, |
| 740 const blink::WebString& name, | 742 const blink::WebString& name, |
| 741 blink::WebSandboxFlags sandboxFlags) { | 743 blink::WebSandboxFlags sandboxFlags, |
| 744 const blink::WebFrameOwnerProperties& frameOwnerProperties) { |
| 742 blink::WebFrame* frame = blink::WebLocalFrame::create(scope, this); | 745 blink::WebFrame* frame = blink::WebLocalFrame::create(scope, this); |
| 743 parent->appendChild(frame); | 746 parent->appendChild(frame); |
| 744 return frame; | 747 return frame; |
| 745 } | 748 } |
| 746 | 749 |
| 747 void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame, | 750 void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame, |
| 748 DetachType type) { | 751 DetachType type) { |
| 749 DCHECK(type == DetachType::Remove); | 752 DCHECK(type == DetachType::Remove); |
| 750 if (frame->parent()) | 753 if (frame->parent()) |
| 751 frame->parent()->removeChild(frame); | 754 frame->parent()->removeChild(frame); |
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2090 blink::WebConsoleMessage::LevelWarning, message)); | 2093 blink::WebConsoleMessage::LevelWarning, message)); |
| 2091 return false; | 2094 return false; |
| 2092 } | 2095 } |
| 2093 | 2096 |
| 2094 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2097 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
| 2095 // Reset counter on successful print. | 2098 // Reset counter on successful print. |
| 2096 count_ = 0; | 2099 count_ = 0; |
| 2097 } | 2100 } |
| 2098 | 2101 |
| 2099 } // namespace printing | 2102 } // namespace printing |
| OLD | NEW |