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

Side by Side Diff: chrome/renderer/printing/print_web_view_helper.cc

Issue 357203003: Move webpreferences.* from webkit/ to content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RenderView::FromWebView Created 6 years, 5 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 | Annotate | Revision Log
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/renderer/printing/print_web_view_helper.h" 5 #include "chrome/renderer/printing/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/command_line.h" 10 #include "base/command_line.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/process/process_handle.h" 15 #include "base/process/process_handle.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/print_messages.h" 20 #include "chrome/common/print_messages.h"
21 #include "chrome/common/render_messages.h" 21 #include "chrome/common/render_messages.h"
22 #include "chrome/renderer/prerender/prerender_helper.h" 22 #include "chrome/renderer/prerender/prerender_helper.h"
23 #include "content/public/common/web_preferences.h"
23 #include "content/public/renderer/render_frame.h" 24 #include "content/public/renderer/render_frame.h"
24 #include "content/public/renderer/render_thread.h" 25 #include "content/public/renderer/render_thread.h"
25 #include "content/public/renderer/render_view.h" 26 #include "content/public/renderer/render_view.h"
26 #include "content/public/renderer/web_preferences.h"
27 #include "grit/browser_resources.h" 27 #include "grit/browser_resources.h"
28 #include "net/base/escape.h" 28 #include "net/base/escape.h"
29 #include "printing/metafile.h" 29 #include "printing/metafile.h"
30 #include "printing/metafile_impl.h" 30 #include "printing/metafile_impl.h"
31 #include "printing/units.h" 31 #include "printing/units.h"
32 #include "skia/ext/vector_platform_device_skia.h" 32 #include "skia/ext/vector_platform_device_skia.h"
33 #include "third_party/WebKit/public/platform/WebSize.h" 33 #include "third_party/WebKit/public/platform/WebSize.h"
34 #include "third_party/WebKit/public/platform/WebURLRequest.h" 34 #include "third_party/WebKit/public/platform/WebURLRequest.h"
35 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 35 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
36 #include "third_party/WebKit/public/web/WebDocument.h" 36 #include "third_party/WebKit/public/web/WebDocument.h"
37 #include "third_party/WebKit/public/web/WebElement.h" 37 #include "third_party/WebKit/public/web/WebElement.h"
38 #include "third_party/WebKit/public/web/WebFrameClient.h" 38 #include "third_party/WebKit/public/web/WebFrameClient.h"
39 #include "third_party/WebKit/public/web/WebLocalFrame.h" 39 #include "third_party/WebKit/public/web/WebLocalFrame.h"
40 #include "third_party/WebKit/public/web/WebPlugin.h" 40 #include "third_party/WebKit/public/web/WebPlugin.h"
41 #include "third_party/WebKit/public/web/WebPluginDocument.h" 41 #include "third_party/WebKit/public/web/WebPluginDocument.h"
42 #include "third_party/WebKit/public/web/WebPrintParams.h" 42 #include "third_party/WebKit/public/web/WebPrintParams.h"
43 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" 43 #include "third_party/WebKit/public/web/WebPrintScalingOption.h"
44 #include "third_party/WebKit/public/web/WebScriptSource.h" 44 #include "third_party/WebKit/public/web/WebScriptSource.h"
45 #include "third_party/WebKit/public/web/WebSettings.h" 45 #include "third_party/WebKit/public/web/WebSettings.h"
46 #include "third_party/WebKit/public/web/WebView.h" 46 #include "third_party/WebKit/public/web/WebView.h"
47 #include "third_party/WebKit/public/web/WebViewClient.h" 47 #include "third_party/WebKit/public/web/WebViewClient.h"
48 #include "ui/base/resource/resource_bundle.h" 48 #include "ui/base/resource/resource_bundle.h"
49 #include "webkit/common/webpreferences.h" 49
50 using content::WebPreferences;
50 51
51 namespace printing { 52 namespace printing {
52 53
53 namespace { 54 namespace {
54 55
55 enum PrintPreviewHelperEvents { 56 enum PrintPreviewHelperEvents {
56 PREVIEW_EVENT_REQUESTED, 57 PREVIEW_EVENT_REQUESTED,
57 PREVIEW_EVENT_CACHE_HIT, // Unused 58 PREVIEW_EVENT_CACHE_HIT, // Unused
58 PREVIEW_EVENT_CREATE_DOCUMENT, 59 PREVIEW_EVENT_CREATE_DOCUMENT,
59 PREVIEW_EVENT_NEW_SETTINGS, // Unused 60 PREVIEW_EVENT_NEW_SETTINGS, // Unused
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 RestoreSize(); 690 RestoreSize();
690 // Create a new WebView with the same settings as the current display one. 691 // Create a new WebView with the same settings as the current display one.
691 // Except that we disable javascript (don't want any active content running 692 // Except that we disable javascript (don't want any active content running
692 // on the page). 693 // on the page).
693 WebPreferences prefs = preferences; 694 WebPreferences prefs = preferences;
694 prefs.javascript_enabled = false; 695 prefs.javascript_enabled = false;
695 prefs.java_enabled = false; 696 prefs.java_enabled = false;
696 697
697 blink::WebView* web_view = blink::WebView::create(this); 698 blink::WebView* web_view = blink::WebView::create(this);
698 owns_web_view_ = true; 699 owns_web_view_ = true;
699 content::ApplyWebPreferences(prefs, web_view);
700 web_view->setMainFrame(blink::WebLocalFrame::create(this)); 700 web_view->setMainFrame(blink::WebLocalFrame::create(this));
701 frame_.Reset(web_view->mainFrame()->toWebLocalFrame()); 701 frame_.Reset(web_view->mainFrame()->toWebLocalFrame());
702 node_to_print_.reset(); 702 node_to_print_.reset();
703 703
704 content::RenderView::FromWebView(frame_.GetFrame()->view())
705 ->ApplyWebPreferences(prefs);
706
704 // When loading is done this will call didStopLoading() and that will do the 707 // When loading is done this will call didStopLoading() and that will do the
705 // actual printing. 708 // actual printing.
706 frame()->loadRequest(blink::WebURLRequest(GURL(url_str))); 709 frame()->loadRequest(blink::WebURLRequest(GURL(url_str)));
707 } 710 }
708 711
709 bool PrepareFrameAndViewForPrint::allowsBrokenNullLayerTreeView() const { 712 bool PrepareFrameAndViewForPrint::allowsBrokenNullLayerTreeView() const {
710 return true; 713 return true;
711 } 714 }
712 715
713 void PrepareFrameAndViewForPrint::didStopLoading() { 716 void PrepareFrameAndViewForPrint::didStopLoading() {
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 print_pages_params_->params.print_scaling_option = scaling_option; 1592 print_pages_params_->params.print_scaling_option = scaling_option;
1590 return (print_settings.params.dpi && print_settings.params.document_cookie); 1593 return (print_settings.params.dpi && print_settings.params.document_cookie);
1591 } 1594 }
1592 1595
1593 bool PrintWebViewHelper::RenderPagesForPrint(blink::WebLocalFrame* frame, 1596 bool PrintWebViewHelper::RenderPagesForPrint(blink::WebLocalFrame* frame,
1594 const blink::WebNode& node) { 1597 const blink::WebNode& node) {
1595 if (!frame || prep_frame_view_) 1598 if (!frame || prep_frame_view_)
1596 return false; 1599 return false;
1597 const PrintMsg_PrintPages_Params& params = *print_pages_params_; 1600 const PrintMsg_PrintPages_Params& params = *print_pages_params_;
1598 const PrintMsg_Print_Params& print_params = params.params; 1601 const PrintMsg_Print_Params& print_params = params.params;
1599 prep_frame_view_.reset( 1602 prep_frame_view_.reset(new PrepareFrameAndViewForPrint(
1600 new PrepareFrameAndViewForPrint(print_params, frame, node, 1603 print_params, frame, node, ignore_css_margins_));
1601 ignore_css_margins_));
1602 DCHECK(!print_pages_params_->params.selection_only || 1604 DCHECK(!print_pages_params_->params.selection_only ||
1603 print_pages_params_->pages.empty()); 1605 print_pages_params_->pages.empty());
1604 prep_frame_view_->CopySelectionIfNeeded( 1606 prep_frame_view_->CopySelectionIfNeeded(
1605 render_view()->GetWebkitPreferences(), 1607 render_view()->GetWebkitPreferences(),
1606 base::Bind(&PrintWebViewHelper::OnFramePreparedForPrintPages, 1608 base::Bind(&PrintWebViewHelper::OnFramePreparedForPrintPages,
1607 base::Unretained(this))); 1609 base::Unretained(this)));
1608 return true; 1610 return true;
1609 } 1611 }
1610 1612
1611 #if defined(OS_POSIX) 1613 #if defined(OS_POSIX)
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 } 2024 }
2023 2025
2024 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 2026 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
2025 prep_frame_view_.reset(); 2027 prep_frame_view_.reset();
2026 metafile_.reset(); 2028 metafile_.reset();
2027 pages_to_render_.clear(); 2029 pages_to_render_.clear();
2028 error_ = PREVIEW_ERROR_NONE; 2030 error_ = PREVIEW_ERROR_NONE;
2029 } 2031 }
2030 2032
2031 } // namespace printing 2033 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698