| 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 3464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3548 void Browser::CloseContents(TabContents* source) { | 3547 void Browser::CloseContents(TabContents* source) { |
| 3549 if (is_attempting_to_close_browser_) { | 3548 if (is_attempting_to_close_browser_) { |
| 3550 // If we're trying to close the browser, just clear the state related to | 3549 // If we're trying to close the browser, just clear the state related to |
| 3551 // waiting for unload to fire. Don't actually try to close the tab as it | 3550 // waiting for unload to fire. Don't actually try to close the tab as it |
| 3552 // will go down the slow shutdown path instead of the fast path of killing | 3551 // will go down the slow shutdown path instead of the fast path of killing |
| 3553 // all the renderer processes. | 3552 // all the renderer processes. |
| 3554 ClearUnloadState(source, true); | 3553 ClearUnloadState(source, true); |
| 3555 return; | 3554 return; |
| 3556 } | 3555 } |
| 3557 | 3556 |
| 3558 // Various sites have a pattern which open a new window with output formatted | |
| 3559 // for printing, then include a print button, which does window.print(); | |
| 3560 // window.close(); An example is printing Virgin America boarding | |
| 3561 // pass. Instead of closing, when a print tab is associated with this tab, | |
| 3562 // tell the BackgroundPrintingManager to own it, which causes it to be | |
| 3563 // hidden and eventually closed when the print window is closed. | |
| 3564 TabContentsWrapper* source_wrapper = | |
| 3565 TabContentsWrapper::GetCurrentWrapperForContents(source); | |
| 3566 if (g_browser_process->background_printing_manager()-> | |
| 3567 OwnInitiatorTab(source_wrapper)) { | |
| 3568 return; | |
| 3569 } | |
| 3570 | |
| 3571 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source); | 3557 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source); |
| 3572 if (index == TabStripModel::kNoTab) { | 3558 if (index == TabStripModel::kNoTab) { |
| 3573 NOTREACHED() << "CloseContents called for tab not in our strip"; | 3559 NOTREACHED() << "CloseContents called for tab not in our strip"; |
| 3574 return; | 3560 return; |
| 3575 } | 3561 } |
| 3576 tab_handler_->GetTabStripModel()->CloseTabContentsAt( | 3562 tab_handler_->GetTabStripModel()->CloseTabContentsAt( |
| 3577 index, | 3563 index, |
| 3578 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | 3564 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); |
| 3579 } | 3565 } |
| 3580 | 3566 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3837 NavigationType::Type navigation_type) { | 3823 NavigationType::Type navigation_type) { |
| 3838 // Don't update history if running as app. | 3824 // Don't update history if running as app. |
| 3839 return !IsApplication(); | 3825 return !IsApplication(); |
| 3840 } | 3826 } |
| 3841 | 3827 |
| 3842 void Browser::ContentRestrictionsChanged(TabContents* source) { | 3828 void Browser::ContentRestrictionsChanged(TabContents* source) { |
| 3843 UpdateCommandsForContentRestrictionState(); | 3829 UpdateCommandsForContentRestrictionState(); |
| 3844 } | 3830 } |
| 3845 | 3831 |
| 3846 void Browser::RendererUnresponsive(TabContents* source) { | 3832 void Browser::RendererUnresponsive(TabContents* source) { |
| 3833 // Ignore hangs if print preview is open. |
| 3834 TabContentsWrapper* source_wrapper = |
| 3835 TabContentsWrapper::GetCurrentWrapperForContents(source); |
| 3836 if (source_wrapper) { |
| 3837 printing::PrintPreviewTabController* controller = |
| 3838 printing::PrintPreviewTabController::GetInstance(); |
| 3839 if (controller) { |
| 3840 TabContentsWrapper* preview_tab = |
| 3841 controller->GetPrintPreviewForTab(source_wrapper); |
| 3842 if (preview_tab && preview_tab != source_wrapper) { |
| 3843 return; |
| 3844 } |
| 3845 } |
| 3846 } |
| 3847 |
| 3847 browser::ShowHungRendererDialog(source); | 3848 browser::ShowHungRendererDialog(source); |
| 3848 } | 3849 } |
| 3849 | 3850 |
| 3850 void Browser::RendererResponsive(TabContents* source) { | 3851 void Browser::RendererResponsive(TabContents* source) { |
| 3851 browser::HideHungRendererDialog(source); | 3852 browser::HideHungRendererDialog(source); |
| 3852 } | 3853 } |
| 3853 | 3854 |
| 3854 void Browser::WorkerCrashed(TabContents* source) { | 3855 void Browser::WorkerCrashed(TabContents* source) { |
| 3855 TabContentsWrapper* wrapper = | 3856 TabContentsWrapper* wrapper = |
| 3856 TabContentsWrapper::GetCurrentWrapperForContents(source); | 3857 TabContentsWrapper::GetCurrentWrapperForContents(source); |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4642 if (has_constrained_window || | 4643 if (has_constrained_window || |
| 4643 content_restrictions & CONTENT_RESTRICTION_PRINT) { | 4644 content_restrictions & CONTENT_RESTRICTION_PRINT) { |
| 4644 print_enabled = false; | 4645 print_enabled = false; |
| 4645 advanced_print_enabled = false; | 4646 advanced_print_enabled = false; |
| 4646 } | 4647 } |
| 4647 | 4648 |
| 4648 // The exception is print preview, | 4649 // The exception is print preview, |
| 4649 // where advanced printing is always enabled. | 4650 // where advanced printing is always enabled. |
| 4650 printing::PrintPreviewTabController* controller = | 4651 printing::PrintPreviewTabController* controller = |
| 4651 printing::PrintPreviewTabController::GetInstance(); | 4652 printing::PrintPreviewTabController::GetInstance(); |
| 4652 if (controller && | 4653 if (controller && controller->GetPrintPreviewForTab(wrapper)) { |
| 4653 wrapper && | |
| 4654 wrapper == controller->GetPrintPreviewForTab(wrapper)) { | |
| 4655 advanced_print_enabled = true; | 4654 advanced_print_enabled = true; |
| 4656 } | 4655 } |
| 4657 } | 4656 } |
| 4658 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); | 4657 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); |
| 4659 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, | 4658 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, |
| 4660 advanced_print_enabled); | 4659 advanced_print_enabled); |
| 4661 } | 4660 } |
| 4662 | 4661 |
| 4663 void Browser::UpdateReloadStopState(bool is_loading, bool force) { | 4662 void Browser::UpdateReloadStopState(bool is_loading, bool force) { |
| 4664 window_->UpdateReloadStopState(is_loading, force); | 4663 window_->UpdateReloadStopState(is_loading, force); |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5351 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5350 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
| 5352 } else if (is_type_tabbed()) { | 5351 } else if (is_type_tabbed()) { |
| 5353 GlobalErrorService* service = | 5352 GlobalErrorService* service = |
| 5354 GlobalErrorServiceFactory::GetForProfile(profile()); | 5353 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 5355 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5354 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
| 5356 if (error) { | 5355 if (error) { |
| 5357 error->ShowBubbleView(this); | 5356 error->ShowBubbleView(this); |
| 5358 } | 5357 } |
| 5359 } | 5358 } |
| 5360 } | 5359 } |
| OLD | NEW |