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

Side by Side Diff: chrome/browser/printing/print_preview_dialog_controller.cc

Issue 1581083004: Fix NULL crash in PrintViewManager::PrintPreviewDone. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/printing/print_preview_dialog_controller.h" 5 #include "chrome/browser/printing/print_preview_dialog_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 160
161 // static 161 // static
162 void PrintPreviewDialogController::PrintPreview(WebContents* initiator) { 162 void PrintPreviewDialogController::PrintPreview(WebContents* initiator) {
163 if (initiator->ShowingInterstitialPage() || initiator->IsCrashed()) 163 if (initiator->ShowingInterstitialPage() || initiator->IsCrashed())
164 return; 164 return;
165 165
166 PrintPreviewDialogController* dialog_controller = GetInstance(); 166 PrintPreviewDialogController* dialog_controller = GetInstance();
167 if (!dialog_controller) 167 if (!dialog_controller)
168 return; 168 return;
169 if (!dialog_controller->GetOrCreatePreviewDialog(initiator)) 169 if (!dialog_controller->GetOrCreatePreviewDialog(initiator)) {
170 PrintViewManager::FromWebContents(initiator)->PrintPreviewDone(); 170 PrintViewManager* print_view_manager =
171 PrintViewManager::FromWebContents(initiator);
172 if (print_view_manager)
173 print_view_manager->PrintPreviewDone();
174 }
171 } 175 }
172 176
173 WebContents* PrintPreviewDialogController::GetOrCreatePreviewDialog( 177 WebContents* PrintPreviewDialogController::GetOrCreatePreviewDialog(
174 WebContents* initiator) { 178 WebContents* initiator) {
175 DCHECK(initiator); 179 DCHECK(initiator);
176 180
177 // Get the print preview dialog for |initiator|. 181 // Get the print preview dialog for |initiator|.
178 WebContents* preview_dialog = GetPrintPreviewForContents(initiator); 182 WebContents* preview_dialog = GetPrintPreviewForContents(initiator);
179 if (preview_dialog) { 183 if (preview_dialog) {
180 // Show the initiator holding the existing preview dialog. 184 // Show the initiator holding the existing preview dialog.
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 static_cast<PrintPreviewUI*>(web_ui->GetController()); 494 static_cast<PrintPreviewUI*>(web_ui->GetController());
491 if (print_preview_ui) 495 if (print_preview_ui)
492 print_preview_ui->OnPrintPreviewDialogDestroyed(); 496 print_preview_ui->OnPrintPreviewDialogDestroyed();
493 } 497 }
494 498
495 preview_dialog_map_.erase(preview_dialog); 499 preview_dialog_map_.erase(preview_dialog);
496 RemoveObservers(preview_dialog); 500 RemoveObservers(preview_dialog);
497 } 501 }
498 502
499 } // namespace printing 503 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698