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

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

Issue 1992017: Fix Print Selection. (Closed)
Patch Set: Merged ToT. Created 10 years, 7 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
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 // The routing id is sent across as it is needed to look up the 147 // The routing id is sent across as it is needed to look up the
148 // corresponding RenderViewHost instance to signal and reset the 148 // corresponding RenderViewHost instance to signal and reset the
149 // pump messages event. 149 // pump messages event.
150 params.routing_id = routing_id(); 150 params.routing_id = routing_id();
151 // host_window_ may be NULL at this point if the current window is a popup 151 // host_window_ may be NULL at this point if the current window is a popup
152 // and the print() command has been issued from the parent. The receiver 152 // and the print() command has been issued from the parent. The receiver
153 // of this message has to deal with this. 153 // of this message has to deal with this.
154 params.host_window_id = render_view_->host_window(); 154 params.host_window_id = render_view_->host_window();
155 params.cookie = default_settings.document_cookie; 155 params.cookie = default_settings.document_cookie;
156 // TODO(maruel): Reenable once http://crbug.com/22937 is fixed. 156 params.has_selection = frame->hasSelection();
157 // Print selection is broken because DidStopLoading is never called.
158 // params.has_selection = frame->hasSelection();
159 params.has_selection = false;
160 params.expected_pages_count = expected_pages_count; 157 params.expected_pages_count = expected_pages_count;
161 params.use_overlays = use_browser_overlays; 158 params.use_overlays = use_browser_overlays;
162 159
163 msg = new ViewHostMsg_ScriptedPrint(routing_id(), params, 160 msg = new ViewHostMsg_ScriptedPrint(routing_id(), params,
164 &print_settings); 161 &print_settings);
165 msg->EnableMessagePumping(); 162 msg->EnableMessagePumping();
166 if (Send(msg)) { 163 if (Send(msg)) {
167 msg = NULL; 164 msg = NULL;
168 165
169 // If the settings are invalid, early quit. 166 // If the settings are invalid, early quit.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 WebFrame* web_frame) { 230 WebFrame* web_frame) {
234 // Create a new WebView with the same settings as the current display one. 231 // Create a new WebView with the same settings as the current display one.
235 // Except that we disable javascript (don't want any active content running 232 // Except that we disable javascript (don't want any active content running
236 // on the page). 233 // on the page).
237 WebPreferences prefs = render_view_->webkit_preferences(); 234 WebPreferences prefs = render_view_->webkit_preferences();
238 prefs.javascript_enabled = false; 235 prefs.javascript_enabled = false;
239 prefs.java_enabled = false; 236 prefs.java_enabled = false;
240 237
241 print_web_view_ = WebView::create(this); 238 print_web_view_ = WebView::create(this);
242 prefs.Apply(print_web_view_); 239 prefs.Apply(print_web_view_);
243 print_web_view_->initializeMainFrame(NULL); 240 print_web_view_->initializeMainFrame(this);
244 241
245 print_pages_params_.reset(new ViewMsg_PrintPages_Params(params)); 242 print_pages_params_.reset(new ViewMsg_PrintPages_Params(params));
246 print_pages_params_->pages.clear(); // Print all pages of selection. 243 print_pages_params_->pages.clear(); // Print all pages of selection.
247 244
248 std::string html = web_frame->selectionAsMarkup().utf8(); 245 std::string html = web_frame->selectionAsMarkup().utf8();
249 std::string url_str = "data:text/html;charset=utf-8,"; 246 std::string url_str = "data:text/html;charset=utf-8,";
250 url_str.append(html); 247 url_str.append(html);
251 GURL url(url_str); 248 GURL url(url_str);
252 249
253 // When loading is done this will call DidStopLoading that will do the 250 // When loading is done this will call DidStopLoading that will do the
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 327 }
331 328
332 int32 PrintWebViewHelper::routing_id() { 329 int32 PrintWebViewHelper::routing_id() {
333 return render_view_->routing_id(); 330 return render_view_->routing_id();
334 } 331 }
335 332
336 void PrintWebViewHelper::didStopLoading() { 333 void PrintWebViewHelper::didStopLoading() {
337 DCHECK(print_pages_params_.get() != NULL); 334 DCHECK(print_pages_params_.get() != NULL);
338 PrintPages(*print_pages_params_.get(), print_web_view_->mainFrame()); 335 PrintPages(*print_pages_params_.get(), print_web_view_->mainFrame());
339 } 336 }
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698