| 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 "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/sessions/restore_tab_helper.h" | 8 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 9 #include "chrome/browser/tabs/tab_strip_model.h" | 9 #include "chrome/browser/tabs/tab_strip_model.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 return; | 131 return; |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 if (source_tab_is_preview_tab) { | 135 if (source_tab_is_preview_tab) { |
| 136 // Remove the initiator tab's observers before erasing the mapping. | 136 // Remove the initiator tab's observers before erasing the mapping. |
| 137 TabContents* initiator_tab = GetInitiatorTab(source_tab); | 137 TabContents* initiator_tab = GetInitiatorTab(source_tab); |
| 138 if (initiator_tab) | 138 if (initiator_tab) |
| 139 RemoveObservers(initiator_tab); | 139 RemoveObservers(initiator_tab); |
| 140 | 140 |
| 141 // |source_tab_is_preview_tab| is misleading in the case where the user |
| 142 // chooses to re-open the initiator tab after closing it, as |source_tab| |
| 143 // has navigated to the URL of the initiator tab at this point. Make sure to |
| 144 // verify that |source_tab| really is a print preview tab. |
| 145 if (IsPrintPreviewTab(source_tab)) { |
| 146 PrintPreviewUI* print_preview_ui = |
| 147 static_cast<PrintPreviewUI*>(source_tab->web_ui()); |
| 148 print_preview_ui->OnNavigation(); |
| 149 } |
| 150 |
| 141 // Erase the map entry. | 151 // Erase the map entry. |
| 142 preview_tab_map_.erase(source_tab); | 152 preview_tab_map_.erase(source_tab); |
| 143 } else { | 153 } else { |
| 144 // Initiator tab is closed. Disable the controls in preview tab. | 154 // Initiator tab is closed. Disable the controls in preview tab. |
| 145 PrintPreviewUI* print_preview_ui = | 155 PrintPreviewUI* print_preview_ui = |
| 146 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); | 156 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); |
| 147 print_preview_ui->OnInitiatorTabClosed(source_tab->GetURL().spec()); | 157 print_preview_ui->OnInitiatorTabClosed(source_tab->GetURL().spec()); |
| 148 | 158 |
| 149 // |source_tab| is an initiator tab, update the map entry. | 159 // |source_tab| is an initiator tab, update the map entry. |
| 150 preview_tab_map_[preview_tab] = NULL; | 160 preview_tab_map_[preview_tab] = NULL; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 239 } |
| 230 | 240 |
| 231 void PrintPreviewTabController::RemoveObservers(TabContents* tab) { | 241 void PrintPreviewTabController::RemoveObservers(TabContents* tab) { |
| 232 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED, | 242 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED, |
| 233 Source<TabContents>(tab)); | 243 Source<TabContents>(tab)); |
| 234 registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED, | 244 registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED, |
| 235 Source<NavigationController>(&tab->controller())); | 245 Source<NavigationController>(&tab->controller())); |
| 236 } | 246 } |
| 237 | 247 |
| 238 } // namespace printing | 248 } // namespace printing |
| OLD | NEW |