OLD | NEW |
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/browser/printing/print_preview_tab_controller.h" | 5 #include "chrome/browser/printing/print_preview_tab_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 void PrintPreviewTabController::RemoveInitiatorTab( | 428 void PrintPreviewTabController::RemoveInitiatorTab( |
429 TabContentsWrapper* initiator_tab) { | 429 TabContentsWrapper* initiator_tab) { |
430 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(initiator_tab); | 430 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(initiator_tab); |
431 DCHECK(preview_tab); | 431 DCHECK(preview_tab); |
432 // Update the map entry first, so when the print preview tab gets destroyed | 432 // Update the map entry first, so when the print preview tab gets destroyed |
433 // and reaches RemovePreviewTab(), it does not attempt to also remove the | 433 // and reaches RemovePreviewTab(), it does not attempt to also remove the |
434 // initiator tab's observers. | 434 // initiator tab's observers. |
435 preview_tab_map_[preview_tab] = NULL; | 435 preview_tab_map_[preview_tab] = NULL; |
436 RemoveObservers(initiator_tab); | 436 RemoveObservers(initiator_tab); |
437 | 437 |
| 438 initiator_tab->print_view_manager()->PrintPreviewDone(); |
| 439 |
438 // Initiator tab is closed. Close the print preview tab too. | 440 // Initiator tab is closed. Close the print preview tab too. |
439 PrintPreviewUI* print_preview_ui = | 441 PrintPreviewUI* print_preview_ui = |
440 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); | 442 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); |
441 if (print_preview_ui) | 443 if (print_preview_ui) |
442 print_preview_ui->OnInitiatorTabClosed(); | 444 print_preview_ui->OnInitiatorTabClosed(); |
443 } | 445 } |
444 | 446 |
445 void PrintPreviewTabController::RemovePreviewTab( | 447 void PrintPreviewTabController::RemovePreviewTab( |
446 TabContentsWrapper* preview_tab) { | 448 TabContentsWrapper* preview_tab) { |
447 // Remove the initiator tab's observers before erasing the mapping. | 449 // Remove the initiator tab's observers before erasing the mapping. |
448 TabContentsWrapper* initiator_tab = GetInitiatorTab(preview_tab); | 450 TabContentsWrapper* initiator_tab = GetInitiatorTab(preview_tab); |
449 if (initiator_tab) | 451 if (initiator_tab) { |
450 RemoveObservers(initiator_tab); | 452 RemoveObservers(initiator_tab); |
| 453 initiator_tab->print_view_manager()->PrintPreviewDone(); |
| 454 } |
451 | 455 |
452 // Print preview TabContents is destroyed. Notify |PrintPreviewUI| to abort | 456 // Print preview TabContents is destroyed. Notify |PrintPreviewUI| to abort |
453 // the initiator tab preview request. | 457 // the initiator tab preview request. |
454 PrintPreviewUI* print_preview_ui = | 458 PrintPreviewUI* print_preview_ui = |
455 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); | 459 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); |
456 if (print_preview_ui) | 460 if (print_preview_ui) |
457 print_preview_ui->OnTabDestroyed(); | 461 print_preview_ui->OnTabDestroyed(); |
458 | 462 |
459 preview_tab_map_.erase(preview_tab); | 463 preview_tab_map_.erase(preview_tab); |
460 RemoveObservers(preview_tab); | 464 RemoveObservers(preview_tab); |
461 } | 465 } |
462 | 466 |
463 } // namespace printing | 467 } // namespace printing |
OLD | NEW |