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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #include "chrome/browser/instant/instant_unload_handler.h" | 62 #include "chrome/browser/instant/instant_unload_handler.h" |
63 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" | 63 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" |
64 #include "chrome/browser/intents/web_intents_registry_factory.h" | 64 #include "chrome/browser/intents/web_intents_registry_factory.h" |
65 #include "chrome/browser/net/browser_url_util.h" | 65 #include "chrome/browser/net/browser_url_util.h" |
66 #include "chrome/browser/net/url_fixer_upper.h" | 66 #include "chrome/browser/net/url_fixer_upper.h" |
67 #include "chrome/browser/notifications/notification_ui_manager.h" | 67 #include "chrome/browser/notifications/notification_ui_manager.h" |
68 #include "chrome/browser/platform_util.h" | 68 #include "chrome/browser/platform_util.h" |
69 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 69 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
70 #include "chrome/browser/prefs/pref_service.h" | 70 #include "chrome/browser/prefs/pref_service.h" |
71 #include "chrome/browser/prerender/prerender_tab_helper.h" | 71 #include "chrome/browser/prerender/prerender_tab_helper.h" |
| 72 #include "chrome/browser/printing/background_printing_manager.h" |
72 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 73 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
73 #include "chrome/browser/printing/print_preview_tab_controller.h" | 74 #include "chrome/browser/printing/print_preview_tab_controller.h" |
74 #include "chrome/browser/printing/print_view_manager.h" | 75 #include "chrome/browser/printing/print_view_manager.h" |
75 #include "chrome/browser/profiles/profile.h" | 76 #include "chrome/browser/profiles/profile.h" |
76 #include "chrome/browser/profiles/profile_manager.h" | 77 #include "chrome/browser/profiles/profile_manager.h" |
77 #include "chrome/browser/sessions/restore_tab_helper.h" | 78 #include "chrome/browser/sessions/restore_tab_helper.h" |
78 #include "chrome/browser/sessions/session_service.h" | 79 #include "chrome/browser/sessions/session_service.h" |
79 #include "chrome/browser/sessions/session_service_factory.h" | 80 #include "chrome/browser/sessions/session_service_factory.h" |
80 #include "chrome/browser/sessions/session_types.h" | 81 #include "chrome/browser/sessions/session_types.h" |
81 #include "chrome/browser/sessions/tab_restore_service.h" | 82 #include "chrome/browser/sessions/tab_restore_service.h" |
(...skipping 3462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3544 void Browser::CloseContents(TabContents* source) { | 3545 void Browser::CloseContents(TabContents* source) { |
3545 if (is_attempting_to_close_browser_) { | 3546 if (is_attempting_to_close_browser_) { |
3546 // If we're trying to close the browser, just clear the state related to | 3547 // If we're trying to close the browser, just clear the state related to |
3547 // waiting for unload to fire. Don't actually try to close the tab as it | 3548 // waiting for unload to fire. Don't actually try to close the tab as it |
3548 // will go down the slow shutdown path instead of the fast path of killing | 3549 // will go down the slow shutdown path instead of the fast path of killing |
3549 // all the renderer processes. | 3550 // all the renderer processes. |
3550 ClearUnloadState(source, true); | 3551 ClearUnloadState(source, true); |
3551 return; | 3552 return; |
3552 } | 3553 } |
3553 | 3554 |
| 3555 // Various sites have a pattern which open a new window with output formatted |
| 3556 // for printing, then include a print button, which does window.print(); |
| 3557 // window.close(); An example is printing Virgin America boarding |
| 3558 // pass. Instead of closing, when a print tab is associated with this tab, |
| 3559 // tell the BackgroundPrintingManager to own it, which causes it to be |
| 3560 // hidden and eventually closed when the print window is closed. |
| 3561 TabContentsWrapper* source_wrapper = |
| 3562 TabContentsWrapper::GetCurrentWrapperForContents(source); |
| 3563 if (g_browser_process->background_printing_manager()-> |
| 3564 OwnInitiatorTab(source_wrapper)) { |
| 3565 return; |
| 3566 } |
| 3567 |
3554 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source); | 3568 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source); |
3555 if (index == TabStripModel::kNoTab) { | 3569 if (index == TabStripModel::kNoTab) { |
3556 NOTREACHED() << "CloseContents called for tab not in our strip"; | 3570 NOTREACHED() << "CloseContents called for tab not in our strip"; |
3557 return; | 3571 return; |
3558 } | 3572 } |
3559 tab_handler_->GetTabStripModel()->CloseTabContentsAt( | 3573 tab_handler_->GetTabStripModel()->CloseTabContentsAt( |
3560 index, | 3574 index, |
3561 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | 3575 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); |
3562 } | 3576 } |
3563 | 3577 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3826 // Browser::Navigate via AddNewContents. The latter will retrieve the newly | 3840 // Browser::Navigate via AddNewContents. The latter will retrieve the newly |
3827 // created TabContentsWrapper from TabContents object. | 3841 // created TabContentsWrapper from TabContents object. |
3828 new TabContentsWrapper(new_contents); | 3842 new TabContentsWrapper(new_contents); |
3829 } | 3843 } |
3830 | 3844 |
3831 void Browser::ContentRestrictionsChanged(TabContents* source) { | 3845 void Browser::ContentRestrictionsChanged(TabContents* source) { |
3832 UpdateCommandsForContentRestrictionState(); | 3846 UpdateCommandsForContentRestrictionState(); |
3833 } | 3847 } |
3834 | 3848 |
3835 void Browser::RendererUnresponsive(TabContents* source) { | 3849 void Browser::RendererUnresponsive(TabContents* source) { |
3836 // Ignore hangs if print preview is open. | |
3837 TabContentsWrapper* source_wrapper = | |
3838 TabContentsWrapper::GetCurrentWrapperForContents(source); | |
3839 if (source_wrapper) { | |
3840 printing::PrintPreviewTabController* controller = | |
3841 printing::PrintPreviewTabController::GetInstance(); | |
3842 if (controller) { | |
3843 TabContentsWrapper* preview_tab = | |
3844 controller->GetPrintPreviewForTab(source_wrapper); | |
3845 if (preview_tab && preview_tab != source_wrapper) { | |
3846 return; | |
3847 } | |
3848 } | |
3849 } | |
3850 | |
3851 browser::ShowHungRendererDialog(source); | 3850 browser::ShowHungRendererDialog(source); |
3852 } | 3851 } |
3853 | 3852 |
3854 void Browser::RendererResponsive(TabContents* source) { | 3853 void Browser::RendererResponsive(TabContents* source) { |
3855 browser::HideHungRendererDialog(source); | 3854 browser::HideHungRendererDialog(source); |
3856 } | 3855 } |
3857 | 3856 |
3858 void Browser::WorkerCrashed(TabContents* source) { | 3857 void Browser::WorkerCrashed(TabContents* source) { |
3859 TabContentsWrapper* wrapper = | 3858 TabContentsWrapper* wrapper = |
3860 TabContentsWrapper::GetCurrentWrapperForContents(source); | 3859 TabContentsWrapper::GetCurrentWrapperForContents(source); |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4784 if (has_constrained_window || | 4783 if (has_constrained_window || |
4785 content_restrictions & content::CONTENT_RESTRICTION_PRINT) { | 4784 content_restrictions & content::CONTENT_RESTRICTION_PRINT) { |
4786 print_enabled = false; | 4785 print_enabled = false; |
4787 advanced_print_enabled = false; | 4786 advanced_print_enabled = false; |
4788 } | 4787 } |
4789 | 4788 |
4790 // The exception is print preview, | 4789 // The exception is print preview, |
4791 // where advanced printing is always enabled. | 4790 // where advanced printing is always enabled. |
4792 printing::PrintPreviewTabController* controller = | 4791 printing::PrintPreviewTabController* controller = |
4793 printing::PrintPreviewTabController::GetInstance(); | 4792 printing::PrintPreviewTabController::GetInstance(); |
4794 if (controller && controller->GetPrintPreviewForTab(wrapper)) { | 4793 if (controller && |
| 4794 wrapper && |
| 4795 wrapper == controller->GetPrintPreviewForTab(wrapper)) { |
4795 advanced_print_enabled = true; | 4796 advanced_print_enabled = true; |
4796 } | 4797 } |
4797 } | 4798 } |
4798 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); | 4799 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); |
4799 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, | 4800 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, |
4800 advanced_print_enabled); | 4801 advanced_print_enabled); |
4801 } | 4802 } |
4802 | 4803 |
4803 void Browser::UpdateReloadStopState(bool is_loading, bool force) { | 4804 void Browser::UpdateReloadStopState(bool is_loading, bool force) { |
4804 window_->UpdateReloadStopState(is_loading, force); | 4805 window_->UpdateReloadStopState(is_loading, force); |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5520 } | 5521 } |
5521 | 5522 |
5522 void Browser::UpdateFullscreenExitBubbleContent() { | 5523 void Browser::UpdateFullscreenExitBubbleContent() { |
5523 GURL url; | 5524 GURL url; |
5524 if (fullscreened_tab_) | 5525 if (fullscreened_tab_) |
5525 url = fullscreened_tab_->tab_contents()->GetURL(); | 5526 url = fullscreened_tab_->tab_contents()->GetURL(); |
5526 | 5527 |
5527 window_->UpdateFullscreenExitBubbleContent( | 5528 window_->UpdateFullscreenExitBubbleContent( |
5528 url, GetFullscreenExitBubbleType()); | 5529 url, GetFullscreenExitBubbleType()); |
5529 } | 5530 } |
OLD | NEW |