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/gfx/jpeg_codec.h" | 8 #include "base/gfx/jpeg_codec.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 WebFrame* web_frame) { | 89 WebFrame* web_frame) { |
90 // Create a new WebView with the same settings as the current display one. | 90 // Create a new WebView with the same settings as the current display one. |
91 // Except that we disable javascript (don't want any active content running | 91 // Except that we disable javascript (don't want any active content running |
92 // on the page). | 92 // on the page). |
93 WebPreferences prefs = render_view_->webkit_preferences(); | 93 WebPreferences prefs = render_view_->webkit_preferences(); |
94 prefs.javascript_enabled = false; | 94 prefs.javascript_enabled = false; |
95 prefs.java_enabled = false; | 95 prefs.java_enabled = false; |
96 | 96 |
97 print_web_view_.reset(WebView::Create(this, NULL)); | 97 print_web_view_.reset(WebView::Create(this, NULL)); |
98 prefs.Apply(print_web_view_.get()); | 98 prefs.Apply(print_web_view_.get()); |
99 print_web_view_->InitializeMainFrame(); | 99 print_web_view_->InitializeMainFrame(NULL); |
100 | 100 |
101 print_pages_params_.reset(new ViewMsg_PrintPages_Params(params)); | 101 print_pages_params_.reset(new ViewMsg_PrintPages_Params(params)); |
102 print_pages_params_->pages.clear(); // Print all pages of selection. | 102 print_pages_params_->pages.clear(); // Print all pages of selection. |
103 | 103 |
104 std::string html = web_frame->selectionAsMarkup().utf8(); | 104 std::string html = web_frame->selectionAsMarkup().utf8(); |
105 std::string url_str = "data:text/html;charset=utf-8,"; | 105 std::string url_str = "data:text/html;charset=utf-8,"; |
106 url_str.append(html); | 106 url_str.append(html); |
107 GURL url(url_str); | 107 GURL url(url_str); |
108 | 108 |
109 // When loading is done this will call DidStopLoading that will do the | 109 // When loading is done this will call DidStopLoading that will do the |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 WebScreenInfo PrintWebViewHelper::screenInfo() { | 174 WebScreenInfo PrintWebViewHelper::screenInfo() { |
175 NOTREACHED(); | 175 NOTREACHED(); |
176 return WebScreenInfo(); | 176 return WebScreenInfo(); |
177 } | 177 } |
178 | 178 |
179 void PrintWebViewHelper::DidStopLoading(WebView* webview) { | 179 void PrintWebViewHelper::DidStopLoading(WebView* webview) { |
180 DCHECK(print_pages_params_.get() != NULL); | 180 DCHECK(print_pages_params_.get() != NULL); |
181 DCHECK_EQ(webview, print_web_view_.get()); | 181 DCHECK_EQ(webview, print_web_view_.get()); |
182 PrintPages(*print_pages_params_.get(), print_web_view_->GetMainFrame()); | 182 PrintPages(*print_pages_params_.get(), print_web_view_->GetMainFrame()); |
183 } | 183 } |
OLD | NEW |