| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 #include "chrome/browser/instant/instant_unload_handler.h" | 63 #include "chrome/browser/instant/instant_unload_handler.h" |
| 64 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" | 64 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" |
| 65 #include "chrome/browser/intents/web_intents_registry_factory.h" | 65 #include "chrome/browser/intents/web_intents_registry_factory.h" |
| 66 #include "chrome/browser/net/browser_url_util.h" | 66 #include "chrome/browser/net/browser_url_util.h" |
| 67 #include "chrome/browser/net/url_fixer_upper.h" | 67 #include "chrome/browser/net/url_fixer_upper.h" |
| 68 #include "chrome/browser/notifications/notification_ui_manager.h" | 68 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 69 #include "chrome/browser/platform_util.h" | 69 #include "chrome/browser/platform_util.h" |
| 70 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 70 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 71 #include "chrome/browser/prefs/pref_service.h" | 71 #include "chrome/browser/prefs/pref_service.h" |
| 72 #include "chrome/browser/prerender/prerender_tab_helper.h" | 72 #include "chrome/browser/prerender/prerender_tab_helper.h" |
| 73 #include "chrome/browser/printing/background_printing_manager.h" | |
| 74 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 73 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 75 #include "chrome/browser/printing/print_preview_tab_controller.h" | 74 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 76 #include "chrome/browser/printing/print_view_manager.h" | 75 #include "chrome/browser/printing/print_view_manager.h" |
| 77 #include "chrome/browser/profiles/profile.h" | 76 #include "chrome/browser/profiles/profile.h" |
| 78 #include "chrome/browser/profiles/profile_manager.h" | 77 #include "chrome/browser/profiles/profile_manager.h" |
| 79 #include "chrome/browser/sessions/restore_tab_helper.h" | 78 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 80 #include "chrome/browser/sessions/session_service.h" | 79 #include "chrome/browser/sessions/session_service.h" |
| 81 #include "chrome/browser/sessions/session_service_factory.h" | 80 #include "chrome/browser/sessions/session_service_factory.h" |
| 82 #include "chrome/browser/sessions/session_types.h" | 81 #include "chrome/browser/sessions/session_types.h" |
| 83 #include "chrome/browser/sessions/tab_restore_service.h" | 82 #include "chrome/browser/sessions/tab_restore_service.h" |
| (...skipping 3448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3532 void Browser::CloseContents(TabContents* source) { | 3531 void Browser::CloseContents(TabContents* source) { |
| 3533 if (is_attempting_to_close_browser_) { | 3532 if (is_attempting_to_close_browser_) { |
| 3534 // If we're trying to close the browser, just clear the state related to | 3533 // If we're trying to close the browser, just clear the state related to |
| 3535 // waiting for unload to fire. Don't actually try to close the tab as it | 3534 // waiting for unload to fire. Don't actually try to close the tab as it |
| 3536 // will go down the slow shutdown path instead of the fast path of killing | 3535 // will go down the slow shutdown path instead of the fast path of killing |
| 3537 // all the renderer processes. | 3536 // all the renderer processes. |
| 3538 ClearUnloadState(source, true); | 3537 ClearUnloadState(source, true); |
| 3539 return; | 3538 return; |
| 3540 } | 3539 } |
| 3541 | 3540 |
| 3542 // Various sites have a pattern which open a new window with output formatted | |
| 3543 // for printing, then include a print button, which does window.print(); | |
| 3544 // window.close(); An example is printing Virgin America boarding | |
| 3545 // pass. Instead of closing, when a print tab is associated with this tab, | |
| 3546 // tell the BackgroundPrintingManager to own it, which causes it to be | |
| 3547 // hidden and eventually closed when the print window is closed. | |
| 3548 TabContentsWrapper* source_wrapper = | |
| 3549 TabContentsWrapper::GetCurrentWrapperForContents(source); | |
| 3550 if (g_browser_process->background_printing_manager()-> | |
| 3551 OwnInitiatorTab(source_wrapper)) { | |
| 3552 return; | |
| 3553 } | |
| 3554 | |
| 3555 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source); | 3541 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source); |
| 3556 if (index == TabStripModel::kNoTab) { | 3542 if (index == TabStripModel::kNoTab) { |
| 3557 NOTREACHED() << "CloseContents called for tab not in our strip"; | 3543 NOTREACHED() << "CloseContents called for tab not in our strip"; |
| 3558 return; | 3544 return; |
| 3559 } | 3545 } |
| 3560 tab_handler_->GetTabStripModel()->CloseTabContentsAt( | 3546 tab_handler_->GetTabStripModel()->CloseTabContentsAt( |
| 3561 index, | 3547 index, |
| 3562 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | 3548 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); |
| 3563 } | 3549 } |
| 3564 | 3550 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3821 NavigationType::Type navigation_type) { | 3807 NavigationType::Type navigation_type) { |
| 3822 // Don't update history if running as app. | 3808 // Don't update history if running as app. |
| 3823 return !IsApplication(); | 3809 return !IsApplication(); |
| 3824 } | 3810 } |
| 3825 | 3811 |
| 3826 void Browser::ContentRestrictionsChanged(TabContents* source) { | 3812 void Browser::ContentRestrictionsChanged(TabContents* source) { |
| 3827 UpdateCommandsForContentRestrictionState(); | 3813 UpdateCommandsForContentRestrictionState(); |
| 3828 } | 3814 } |
| 3829 | 3815 |
| 3830 void Browser::RendererUnresponsive(TabContents* source) { | 3816 void Browser::RendererUnresponsive(TabContents* source) { |
| 3817 // Ignore hangs if print preview is open. |
| 3818 TabContentsWrapper* source_wrapper = |
| 3819 TabContentsWrapper::GetCurrentWrapperForContents(source); |
| 3820 if (source_wrapper) { |
| 3821 printing::PrintPreviewTabController* controller = |
| 3822 printing::PrintPreviewTabController::GetInstance(); |
| 3823 if (controller) { |
| 3824 TabContentsWrapper* preview_tab = |
| 3825 controller->GetPrintPreviewForTab(source_wrapper); |
| 3826 if (preview_tab && preview_tab != source_wrapper) { |
| 3827 return; |
| 3828 } |
| 3829 } |
| 3830 } |
| 3831 |
| 3831 browser::ShowHungRendererDialog(source); | 3832 browser::ShowHungRendererDialog(source); |
| 3832 } | 3833 } |
| 3833 | 3834 |
| 3834 void Browser::RendererResponsive(TabContents* source) { | 3835 void Browser::RendererResponsive(TabContents* source) { |
| 3835 browser::HideHungRendererDialog(source); | 3836 browser::HideHungRendererDialog(source); |
| 3836 } | 3837 } |
| 3837 | 3838 |
| 3838 void Browser::WorkerCrashed(TabContents* source) { | 3839 void Browser::WorkerCrashed(TabContents* source) { |
| 3839 TabContentsWrapper* wrapper = | 3840 TabContentsWrapper* wrapper = |
| 3840 TabContentsWrapper::GetCurrentWrapperForContents(source); | 3841 TabContentsWrapper::GetCurrentWrapperForContents(source); |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4630 if (has_constrained_window || | 4631 if (has_constrained_window || |
| 4631 content_restrictions & CONTENT_RESTRICTION_PRINT) { | 4632 content_restrictions & CONTENT_RESTRICTION_PRINT) { |
| 4632 print_enabled = false; | 4633 print_enabled = false; |
| 4633 advanced_print_enabled = false; | 4634 advanced_print_enabled = false; |
| 4634 } | 4635 } |
| 4635 | 4636 |
| 4636 // The exception is print preview, | 4637 // The exception is print preview, |
| 4637 // where advanced printing is always enabled. | 4638 // where advanced printing is always enabled. |
| 4638 printing::PrintPreviewTabController* controller = | 4639 printing::PrintPreviewTabController* controller = |
| 4639 printing::PrintPreviewTabController::GetInstance(); | 4640 printing::PrintPreviewTabController::GetInstance(); |
| 4640 if (controller && | 4641 if (controller && controller->GetPrintPreviewForTab(wrapper)) { |
| 4641 wrapper && | |
| 4642 wrapper == controller->GetPrintPreviewForTab(wrapper)) { | |
| 4643 advanced_print_enabled = true; | 4642 advanced_print_enabled = true; |
| 4644 } | 4643 } |
| 4645 } | 4644 } |
| 4646 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); | 4645 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); |
| 4647 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, | 4646 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, |
| 4648 advanced_print_enabled); | 4647 advanced_print_enabled); |
| 4649 } | 4648 } |
| 4650 | 4649 |
| 4651 void Browser::UpdateReloadStopState(bool is_loading, bool force) { | 4650 void Browser::UpdateReloadStopState(bool is_loading, bool force) { |
| 4652 window_->UpdateReloadStopState(is_loading, force); | 4651 window_->UpdateReloadStopState(is_loading, force); |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5339 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5338 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
| 5340 } else if (is_type_tabbed()) { | 5339 } else if (is_type_tabbed()) { |
| 5341 GlobalErrorService* service = | 5340 GlobalErrorService* service = |
| 5342 GlobalErrorServiceFactory::GetForProfile(profile()); | 5341 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 5343 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5342 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
| 5344 if (error) { | 5343 if (error) { |
| 5345 error->ShowBubbleView(this); | 5344 error->ShowBubbleView(this); |
| 5346 } | 5345 } |
| 5347 } | 5346 } |
| 5348 } | 5347 } |
| OLD | NEW |