Index: android_webview/renderer/print_web_view_helper.cc |
diff --git a/android_webview/renderer/print_web_view_helper.cc b/android_webview/renderer/print_web_view_helper.cc |
index 006a37107d3e18f90e9e2f5a21b0c5950a93baf7..1be735781398d777935f6bbb0dab19166c8933b1 100644 |
--- a/android_webview/renderer/print_web_view_helper.cc |
+++ b/android_webview/renderer/print_web_view_helper.cc |
@@ -19,9 +19,9 @@ |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
+#include "content/public/common/web_preferences.h" |
#include "content/public/renderer/render_thread.h" |
#include "content/public/renderer/render_view.h" |
-#include "content/public/renderer/web_preferences.h" |
#include "net/base/escape.h" |
#include "printing/metafile.h" |
#include "printing/metafile_impl.h" |
@@ -44,13 +44,14 @@ |
#include "third_party/WebKit/public/web/WebViewClient.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/resource/resource_bundle.h" |
-#include "webkit/common/webpreferences.h" |
// This code is copied from chrome/renderer/printing. Code is slightly |
// modified to run it with webview, and the modifications are marked |
// using OS_ANDROID. |
// TODO(sgurun): remove the code as part of componentization of printing. |
+using content::WebPreferences; |
+ |
namespace printing { |
namespace { |
@@ -503,6 +504,7 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient, |
public blink::WebFrameClient { |
public: |
PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& params, |
+ content::RenderView* render_view, |
blink::WebLocalFrame* frame, |
const blink::WebNode& node, |
bool ignore_css_margins); |
@@ -559,6 +561,7 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient, |
base::WeakPtrFactory<PrepareFrameAndViewForPrint> weak_ptr_factory_; |
+ content::RenderView* render_view_; |
FrameReference frame_; |
blink::WebNode node_to_print_; |
bool owns_web_view_; |
@@ -576,10 +579,12 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient, |
PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( |
const PrintMsg_Print_Params& params, |
+ content::RenderView* render_view, |
blink::WebLocalFrame* frame, |
const blink::WebNode& node, |
bool ignore_css_margins) |
: weak_ptr_factory_(this), |
+ render_view_(render_view), |
frame_(frame), |
node_to_print_(node), |
owns_web_view_(false), |
@@ -665,7 +670,7 @@ void PrepareFrameAndViewForPrint::CopySelection( |
blink::WebView* web_view = blink::WebView::create(this); |
owns_web_view_ = true; |
- content::ApplyWebPreferences(prefs, web_view); |
+ render_view_->ApplyWebPreferences(prefs); |
boliu
2014/07/03 00:17:35
Does this work?
frame_->GetRenderView()->ApplyWeb
tfarina
2014/07/03 00:50:14
I don't think this would work. As far as I can see
boliu
2014/07/03 00:59:13
Oops, my bad. How about...
content::RenderView::F
tfarina
2014/07/03 13:19:36
Done.
|
web_view->setMainFrame(blink::WebLocalFrame::create(this)); |
frame_.Reset(web_view->mainFrame()->toWebLocalFrame()); |
@@ -1038,6 +1043,7 @@ void PrintWebViewHelper::PrepareFrameForPreviewDocument() { |
const PrintMsg_Print_Params& print_params = print_pages_params_->params; |
prep_frame_view_.reset( |
new PrepareFrameAndViewForPrint(print_params, |
+ render_view(), |
print_preview_context_.source_frame(), |
print_preview_context_.source_node(), |
ignore_css_margins_)); |
@@ -1437,7 +1443,8 @@ bool PrintWebViewHelper::CalculateNumberOfPages(blink::WebLocalFrame* frame, |
} |
const PrintMsg_Print_Params& params = print_pages_params_->params; |
- PrepareFrameAndViewForPrint prepare(params, frame, node, ignore_css_margins_); |
+ PrepareFrameAndViewForPrint prepare( |
+ params, render_view(), frame, node, ignore_css_margins_); |
prepare.StartPrinting(); |
Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(), |
@@ -1590,9 +1597,8 @@ bool PrintWebViewHelper::RenderPagesForPrint(blink::WebLocalFrame* frame, |
return false; |
const PrintMsg_PrintPages_Params& params = *print_pages_params_; |
const PrintMsg_Print_Params& print_params = params.params; |
- prep_frame_view_.reset( |
- new PrepareFrameAndViewForPrint(print_params, frame, node, |
- ignore_css_margins_)); |
+ prep_frame_view_.reset(new PrepareFrameAndViewForPrint( |
+ print_params, render_view(), frame, node, ignore_css_margins_)); |
DCHECK(!print_pages_params_->params.selection_only || |
print_pages_params_->pages.empty()); |
prep_frame_view_->CopySelectionIfNeeded( |