| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |