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

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

Issue 7056070: PrintPreview: Preview generation should not block print button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return; 193 return;
194 WebFrame* main_frame = render_view()->webview()->mainFrame(); 194 WebFrame* main_frame = render_view()->webview()->mainFrame();
195 if (!main_frame) 195 if (!main_frame)
196 return; 196 return;
197 197
198 WebDocument document = main_frame->document(); 198 WebDocument document = main_frame->document();
199 // <object> with id="pdf-viewer" is created in 199 // <object> with id="pdf-viewer" is created in
200 // chrome/browser/resources/print_preview.js 200 // chrome/browser/resources/print_preview.js
201 WebElement pdf_element = document.getElementById("pdf-viewer"); 201 WebElement pdf_element = document.getElementById("pdf-viewer");
202 if (pdf_element.isNull()) { 202 if (pdf_element.isNull()) {
203 NOTREACHED(); 203 DidFinishPrinting(FAIL_PRINT);
Lei Zhang 2011/06/09 09:54:55 Can you explain how we reach this state? It seems
kmadhusu 2011/06/09 18:11:44 While testing I came across a test case which sati
204 return; 204 return;
205 } 205 }
206 206
207 WebFrame* pdf_frame = pdf_element.document().frame(); 207 WebFrame* pdf_frame = pdf_element.document().frame();
208 if (!InitPrintSettings(pdf_frame, &pdf_element)) { 208 if (!InitPrintSettings(pdf_frame, &pdf_element)) {
209 NOTREACHED() << "Failed to initialize print page settings"; 209 NOTREACHED() << "Failed to initialize print page settings";
210 return; 210 return;
211 } 211 }
212 212
213 if (!UpdatePrintSettings(job_settings)) { 213 if (!UpdatePrintSettings(job_settings)) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) { 354 void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) {
355 if (result == FAIL_PRINT) { 355 if (result == FAIL_PRINT) {
356 WebView* web_view = print_web_view_; 356 WebView* web_view = print_web_view_;
357 if (!web_view) 357 if (!web_view)
358 web_view = render_view()->webview(); 358 web_view = render_view()->webview();
359 359
360 render_view()->runModalAlertDialog( 360 render_view()->runModalAlertDialog(
361 web_view->mainFrame(), 361 web_view->mainFrame(),
362 l10n_util::GetStringUTF16(IDS_PRINT_SPOOL_FAILED_ERROR_TEXT)); 362 l10n_util::GetStringUTF16(IDS_PRINT_SPOOL_FAILED_ERROR_TEXT));
363 363
364 if (notify_browser_of_print_failure_) { 364 if (notify_browser_of_print_failure_ && print_pages_params_.get()) {
365 int cookie = print_pages_params_->params.document_cookie; 365 int cookie = print_pages_params_->params.document_cookie;
366 Send(new PrintHostMsg_PrintingFailed(routing_id(), cookie)); 366 Send(new PrintHostMsg_PrintingFailed(routing_id(), cookie));
367 } 367 }
368 } else if (result == FAIL_PREVIEW) { 368 } else if (result == FAIL_PREVIEW) {
369 int cookie = print_pages_params_->params.document_cookie; 369 int cookie = print_pages_params_->params.document_cookie;
370 Send(new PrintHostMsg_PrintPreviewFailed(routing_id(), cookie)); 370 Send(new PrintHostMsg_PrintPreviewFailed(routing_id(), cookie));
371 } 371 }
372 372
373 if (print_web_view_) { 373 if (print_web_view_) {
374 print_web_view_->close(); 374 print_web_view_->close();
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 744
745 void PrintWebViewHelper::ResetScriptedPrintCount() { 745 void PrintWebViewHelper::ResetScriptedPrintCount() {
746 // Reset cancel counter on successful print. 746 // Reset cancel counter on successful print.
747 user_cancelled_scripted_print_count_ = 0; 747 user_cancelled_scripted_print_count_ = 0;
748 } 748 }
749 749
750 void PrintWebViewHelper::IncrementScriptedPrintCount() { 750 void PrintWebViewHelper::IncrementScriptedPrintCount() {
751 ++user_cancelled_scripted_print_count_; 751 ++user_cancelled_scripted_print_count_;
752 last_cancelled_script_print_ = base::Time::Now(); 752 last_cancelled_script_print_ = base::Time::Now();
753 } 753 }
OLDNEW
« chrome/browser/ui/webui/print_preview_ui.h ('K') | « chrome/browser/ui/webui/print_preview_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698