Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/printing/background_printing_manager.h" | |
| 13 #include "chrome/browser/sessions/restore_tab_helper.h" | 14 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 14 #include "chrome/browser/tabs/tab_strip_model.h" | 15 #include "chrome/browser/tabs/tab_strip_model.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
| 17 #include "chrome/browser/ui/browser_navigator.h" | 18 #include "chrome/browser/ui/browser_navigator.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 19 #include "chrome/browser/ui/webui/print_preview_ui.h" | 20 #include "chrome/browser/ui/webui/print_preview_ui.h" |
| 20 #include "chrome/common/chrome_content_client.h" | 21 #include "chrome/common/chrome_content_client.h" |
| 21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 } | 168 } |
| 168 | 169 |
| 169 void PrintPreviewTabController::OnTabContentsDestroyed(TabContents* tab) { | 170 void PrintPreviewTabController::OnTabContentsDestroyed(TabContents* tab) { |
| 170 TabContents* preview_tab = GetPrintPreviewForTab(tab); | 171 TabContents* preview_tab = GetPrintPreviewForTab(tab); |
| 171 if (!preview_tab) | 172 if (!preview_tab) |
| 172 return; | 173 return; |
| 173 | 174 |
| 174 if (tab == preview_tab) { | 175 if (tab == preview_tab) { |
| 175 // Remove the initiator tab's observers before erasing the mapping. | 176 // Remove the initiator tab's observers before erasing the mapping. |
| 176 TabContents* initiator_tab = GetInitiatorTab(tab); | 177 TabContents* initiator_tab = GetInitiatorTab(tab); |
| 177 if (initiator_tab) | 178 if (initiator_tab) { |
| 178 RemoveObservers(initiator_tab); | 179 RemoveObservers(initiator_tab); |
| 180 TabContentsWrapper* initiator_wrapper = | |
| 181 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); | |
| 182 g_browser_process->background_printing_manager()-> | |
| 183 ReleaseInitiatorTabContents(initiator_wrapper); | |
|
kmadhusu
2011/08/18 23:45:50
You need to delete the initiator tab request after
Sheridan Rawlins
2011/08/19 00:24:25
Done.
| |
| 184 } | |
| 179 | 185 |
| 180 // Print preview tab contents are destroyed. Notify |PrintPreviewUI| to | 186 // Print preview tab contents are destroyed. Notify |PrintPreviewUI| to |
| 181 // abort the initiator tab preview request. | 187 // abort the initiator tab preview request. |
| 182 if (IsPrintPreviewTab(tab) && tab->web_ui()) { | 188 if (IsPrintPreviewTab(tab) && tab->web_ui()) { |
| 183 PrintPreviewUI* print_preview_ui = | 189 PrintPreviewUI* print_preview_ui = |
| 184 static_cast<PrintPreviewUI*>(tab->web_ui()); | 190 static_cast<PrintPreviewUI*>(tab->web_ui()); |
| 185 print_preview_ui->OnTabDestroyed(); | 191 print_preview_ui->OnTabDestroyed(); |
| 186 } | 192 } |
| 187 | 193 |
| 188 // Erase the map entry. | 194 // Erase the map entry. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 transition_type == PageTransition::FORWARD_BACK && | 247 transition_type == PageTransition::FORWARD_BACK && |
| 242 nav_type == NavigationType::EXISTING_PAGE) { | 248 nav_type == NavigationType::EXISTING_PAGE) { |
| 243 return; | 249 return; |
| 244 } | 250 } |
| 245 } | 251 } |
| 246 | 252 |
| 247 RemoveObservers(tab); | 253 RemoveObservers(tab); |
| 248 if (source_tab_is_preview_tab) { | 254 if (source_tab_is_preview_tab) { |
| 249 // Remove the initiator tab's observers before erasing the mapping. | 255 // Remove the initiator tab's observers before erasing the mapping. |
| 250 TabContents* initiator_tab = GetInitiatorTab(tab); | 256 TabContents* initiator_tab = GetInitiatorTab(tab); |
| 251 if (initiator_tab) | 257 if (initiator_tab) { |
| 252 RemoveObservers(initiator_tab); | 258 RemoveObservers(initiator_tab); |
| 259 TabContentsWrapper* initiator_wrapper = | |
| 260 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab); | |
| 261 g_browser_process->background_printing_manager()-> | |
| 262 ReleaseInitiatorTabContents(initiator_wrapper); | |
| 263 } | |
| 253 preview_tab_map_.erase(tab); | 264 preview_tab_map_.erase(tab); |
| 254 } else { | 265 } else { |
| 255 preview_tab_map_[preview_tab] = NULL; | 266 preview_tab_map_[preview_tab] = NULL; |
| 256 | 267 |
| 257 // Initiator tab is closed. Disable the controls in preview tab. | 268 // Initiator tab is closed. Disable the controls in preview tab. |
| 258 if (preview_tab->web_ui()) { | 269 if (preview_tab->web_ui()) { |
| 259 PrintPreviewUI* print_preview_ui = | 270 PrintPreviewUI* print_preview_ui = |
| 260 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); | 271 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); |
| 261 print_preview_ui->OnInitiatorTabClosed(); | 272 print_preview_ui->OnInitiatorTabClosed(); |
| 262 } | 273 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 RenderProcessHost* rph = tab->render_view_host()->process(); | 373 RenderProcessHost* rph = tab->render_view_host()->process(); |
| 363 if (registrar_.IsRegistered(this, | 374 if (registrar_.IsRegistered(this, |
| 364 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 375 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 365 Source<RenderProcessHost>(rph))) { | 376 Source<RenderProcessHost>(rph))) { |
| 366 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 377 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 367 Source<RenderProcessHost>(rph)); | 378 Source<RenderProcessHost>(rph)); |
| 368 } | 379 } |
| 369 } | 380 } |
| 370 | 381 |
| 371 } // namespace printing | 382 } // namespace printing |
| OLD | NEW |