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 18 matching lines...) Expand all Loading... |
29 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 29 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
30 #include "third_party/WebKit/public/web/WebDocument.h" | 30 #include "third_party/WebKit/public/web/WebDocument.h" |
31 #include "third_party/WebKit/public/web/WebElement.h" | 31 #include "third_party/WebKit/public/web/WebElement.h" |
32 #include "third_party/WebKit/public/web/WebFrameClient.h" | 32 #include "third_party/WebKit/public/web/WebFrameClient.h" |
33 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 33 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
34 #include "third_party/WebKit/public/web/WebPlugin.h" | 34 #include "third_party/WebKit/public/web/WebPlugin.h" |
35 #include "third_party/WebKit/public/web/WebPluginDocument.h" | 35 #include "third_party/WebKit/public/web/WebPluginDocument.h" |
36 #include "third_party/WebKit/public/web/WebPrintParams.h" | 36 #include "third_party/WebKit/public/web/WebPrintParams.h" |
37 #include "third_party/WebKit/public/web/WebPrintPresetOptions.h" | 37 #include "third_party/WebKit/public/web/WebPrintPresetOptions.h" |
38 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" | 38 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" |
| 39 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
39 #include "third_party/WebKit/public/web/WebScriptSource.h" | 40 #include "third_party/WebKit/public/web/WebScriptSource.h" |
40 #include "third_party/WebKit/public/web/WebSettings.h" | 41 #include "third_party/WebKit/public/web/WebSettings.h" |
41 #include "third_party/WebKit/public/web/WebView.h" | 42 #include "third_party/WebKit/public/web/WebView.h" |
42 #include "third_party/WebKit/public/web/WebViewClient.h" | 43 #include "third_party/WebKit/public/web/WebViewClient.h" |
43 #include "ui/base/resource/resource_bundle.h" | 44 #include "ui/base/resource/resource_bundle.h" |
44 | 45 |
45 using content::WebPreferences; | 46 using content::WebPreferences; |
46 | 47 |
47 namespace printing { | 48 namespace printing { |
48 | 49 |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 // TODO(ojan): Remove this override and have this class use a non-null | 564 // TODO(ojan): Remove this override and have this class use a non-null |
564 // layerTreeView. | 565 // layerTreeView. |
565 // blink::WebViewClient override: | 566 // blink::WebViewClient override: |
566 virtual bool allowsBrokenNullLayerTreeView() const; | 567 virtual bool allowsBrokenNullLayerTreeView() const; |
567 | 568 |
568 protected: | 569 protected: |
569 // blink::WebViewClient override: | 570 // blink::WebViewClient override: |
570 virtual void didStopLoading(); | 571 virtual void didStopLoading(); |
571 | 572 |
572 // blink::WebFrameClient override: | 573 // blink::WebFrameClient override: |
573 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent, | 574 // TODO(alexmos): Remove once Blink is updated to use sandbox flags. |
574 const blink::WebString& name); | 575 virtual blink::WebFrame* createChildFrame( |
| 576 blink::WebLocalFrame* parent, |
| 577 const blink::WebString& name); |
| 578 virtual blink::WebFrame* createChildFrame( |
| 579 blink::WebLocalFrame* parent, |
| 580 const blink::WebString& name, |
| 581 blink::WebSandboxFlags sandboxFlags); |
575 virtual void frameDetached(blink::WebFrame* frame); | 582 virtual void frameDetached(blink::WebFrame* frame); |
576 | 583 |
577 private: | 584 private: |
578 void CallOnReady(); | 585 void CallOnReady(); |
579 void ResizeForPrinting(); | 586 void ResizeForPrinting(); |
580 void RestoreSize(); | 587 void RestoreSize(); |
581 void CopySelection(const WebPreferences& preferences); | 588 void CopySelection(const WebPreferences& preferences); |
582 | 589 |
583 FrameReference frame_; | 590 FrameReference frame_; |
584 blink::WebNode node_to_print_; | 591 blink::WebNode node_to_print_; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 void PrepareFrameAndViewForPrint::didStopLoading() { | 714 void PrepareFrameAndViewForPrint::didStopLoading() { |
708 DCHECK(!on_ready_.is_null()); | 715 DCHECK(!on_ready_.is_null()); |
709 // Don't call callback here, because it can delete |this| and WebView that is | 716 // Don't call callback here, because it can delete |this| and WebView that is |
710 // called didStopLoading. | 717 // called didStopLoading. |
711 base::MessageLoop::current()->PostTask( | 718 base::MessageLoop::current()->PostTask( |
712 FROM_HERE, | 719 FROM_HERE, |
713 base::Bind(&PrepareFrameAndViewForPrint::CallOnReady, | 720 base::Bind(&PrepareFrameAndViewForPrint::CallOnReady, |
714 weak_ptr_factory_.GetWeakPtr())); | 721 weak_ptr_factory_.GetWeakPtr())); |
715 } | 722 } |
716 | 723 |
| 724 // TODO(alexmos): Remove once Blink is updated to use sandbox flags. |
| 725 blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame( |
| 726 blink::WebLocalFrame* parent, |
| 727 const blink::WebString& name) { |
| 728 return createChildFrame(parent, name, blink::WebSandboxFlags::None); |
| 729 } |
| 730 |
717 blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame( | 731 blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame( |
718 blink::WebLocalFrame* parent, | 732 blink::WebLocalFrame* parent, |
719 const blink::WebString& name) { | 733 const blink::WebString& name, |
| 734 blink::WebSandboxFlags sandboxFlags) { |
720 blink::WebFrame* frame = blink::WebLocalFrame::create(this); | 735 blink::WebFrame* frame = blink::WebLocalFrame::create(this); |
721 parent->appendChild(frame); | 736 parent->appendChild(frame); |
722 return frame; | 737 return frame; |
723 } | 738 } |
724 | 739 |
725 void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame) { | 740 void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame) { |
726 if (frame->parent()) | 741 if (frame->parent()) |
727 frame->parent()->removeChild(frame); | 742 frame->parent()->removeChild(frame); |
728 frame->close(); | 743 frame->close(); |
729 } | 744 } |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 blink::WebConsoleMessage::LevelWarning, message)); | 2043 blink::WebConsoleMessage::LevelWarning, message)); |
2029 return false; | 2044 return false; |
2030 } | 2045 } |
2031 | 2046 |
2032 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2047 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
2033 // Reset counter on successful print. | 2048 // Reset counter on successful print. |
2034 count_ = 0; | 2049 count_ = 0; |
2035 } | 2050 } |
2036 | 2051 |
2037 } // namespace printing | 2052 } // namespace printing |
OLD | NEW |