OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
10 #include "chrome/renderer/render_view.h" | 10 #include "chrome/renderer/render_view.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 239 |
240 bool PrintWebViewHelper::CopyAndPrint(const ViewMsg_PrintPages_Params& params, | 240 bool PrintWebViewHelper::CopyAndPrint(const ViewMsg_PrintPages_Params& params, |
241 WebFrame* web_frame) { | 241 WebFrame* web_frame) { |
242 // Create a new WebView with the same settings as the current display one. | 242 // Create a new WebView with the same settings as the current display one. |
243 // Except that we disable javascript (don't want any active content running | 243 // Except that we disable javascript (don't want any active content running |
244 // on the page). | 244 // on the page). |
245 WebPreferences prefs = render_view_->webkit_preferences(); | 245 WebPreferences prefs = render_view_->webkit_preferences(); |
246 prefs.javascript_enabled = false; | 246 prefs.javascript_enabled = false; |
247 prefs.java_enabled = false; | 247 prefs.java_enabled = false; |
248 | 248 |
249 print_web_view_ = WebView::create(this); | 249 print_web_view_ = WebView::create(this, 0); |
250 prefs.Apply(print_web_view_); | 250 prefs.Apply(print_web_view_); |
251 print_web_view_->initializeMainFrame(this); | 251 print_web_view_->initializeMainFrame(this); |
252 | 252 |
253 print_pages_params_.reset(new ViewMsg_PrintPages_Params(params)); | 253 print_pages_params_.reset(new ViewMsg_PrintPages_Params(params)); |
254 print_pages_params_->pages.clear(); // Print all pages of selection. | 254 print_pages_params_->pages.clear(); // Print all pages of selection. |
255 | 255 |
256 std::string html = web_frame->selectionAsMarkup().utf8(); | 256 std::string html = web_frame->selectionAsMarkup().utf8(); |
257 std::string url_str = "data:text/html;charset=utf-8,"; | 257 std::string url_str = "data:text/html;charset=utf-8,"; |
258 url_str.append(html); | 258 url_str.append(html); |
259 GURL url(url_str); | 259 GURL url(url_str); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 338 } |
339 | 339 |
340 int32 PrintWebViewHelper::routing_id() { | 340 int32 PrintWebViewHelper::routing_id() { |
341 return render_view_->routing_id(); | 341 return render_view_->routing_id(); |
342 } | 342 } |
343 | 343 |
344 void PrintWebViewHelper::didStopLoading() { | 344 void PrintWebViewHelper::didStopLoading() { |
345 DCHECK(print_pages_params_.get() != NULL); | 345 DCHECK(print_pages_params_.get() != NULL); |
346 PrintPages(*print_pages_params_.get(), print_web_view_->mainFrame()); | 346 PrintPages(*print_pages_params_.get(), print_web_view_->mainFrame()); |
347 } | 347 } |
OLD | NEW |