| 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" | |
| 73 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 72 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 74 #include "chrome/browser/printing/print_preview_tab_controller.h" | 73 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 75 #include "chrome/browser/printing/print_view_manager.h" | 74 #include "chrome/browser/printing/print_view_manager.h" |
| 76 #include "chrome/browser/profiles/profile.h" | 75 #include "chrome/browser/profiles/profile.h" |
| 77 #include "chrome/browser/sessions/restore_tab_helper.h" | 76 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 78 #include "chrome/browser/sessions/session_service.h" | 77 #include "chrome/browser/sessions/session_service.h" |
| 79 #include "chrome/browser/sessions/session_service_factory.h" | 78 #include "chrome/browser/sessions/session_service_factory.h" |
| 80 #include "chrome/browser/sessions/session_types.h" | 79 #include "chrome/browser/sessions/session_types.h" |
| 81 #include "chrome/browser/sessions/tab_restore_service.h" | 80 #include "chrome/browser/sessions/tab_restore_service.h" |
| 82 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 81 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| (...skipping 3367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3450 void Browser::CloseContents(TabContents* source) { | 3449 void Browser::CloseContents(TabContents* source) { |
| 3451 if (is_attempting_to_close_browser_) { | 3450 if (is_attempting_to_close_browser_) { |
| 3452 // If we're trying to close the browser, just clear the state related to | 3451 // If we're trying to close the browser, just clear the state related to |
| 3453 // waiting for unload to fire. Don't actually try to close the tab as it | 3452 // waiting for unload to fire. Don't actually try to close the tab as it |
| 3454 // will go down the slow shutdown path instead of the fast path of killing | 3453 // will go down the slow shutdown path instead of the fast path of killing |
| 3455 // all the renderer processes. | 3454 // all the renderer processes. |
| 3456 ClearUnloadState(source, true); | 3455 ClearUnloadState(source, true); |
| 3457 return; | 3456 return; |
| 3458 } | 3457 } |
| 3459 | 3458 |
| 3460 // Various sites have a pattern which open a new window with output formatted | |
| 3461 // for printing, then include a print button, which does window.print(); | |
| 3462 // window.close(); An example is printing Virgin America boarding | |
| 3463 // pass. Instead of closing, when a print tab is associated with this tab, | |
| 3464 // tell the BackgroundPrintingManager to own it, which causes it to be | |
| 3465 // hidden and eventually closed when the print window is closed. | |
| 3466 TabContentsWrapper* source_wrapper = | |
| 3467 TabContentsWrapper::GetCurrentWrapperForContents(source); | |
| 3468 if (g_browser_process->background_printing_manager()-> | |
| 3469 OwnInitiatorTab(source_wrapper)) { | |
| 3470 return; | |
| 3471 } | |
| 3472 | |
| 3473 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source); | 3459 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source); |
| 3474 if (index == TabStripModel::kNoTab) { | 3460 if (index == TabStripModel::kNoTab) { |
| 3475 NOTREACHED() << "CloseContents called for tab not in our strip"; | 3461 NOTREACHED() << "CloseContents called for tab not in our strip"; |
| 3476 return; | 3462 return; |
| 3477 } | 3463 } |
| 3478 tab_handler_->GetTabStripModel()->CloseTabContentsAt( | 3464 tab_handler_->GetTabStripModel()->CloseTabContentsAt( |
| 3479 index, | 3465 index, |
| 3480 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | 3466 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); |
| 3481 } | 3467 } |
| 3482 | 3468 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3733 NavigationType::Type navigation_type) { | 3719 NavigationType::Type navigation_type) { |
| 3734 // Don't update history if running as app. | 3720 // Don't update history if running as app. |
| 3735 return !IsApplication(); | 3721 return !IsApplication(); |
| 3736 } | 3722 } |
| 3737 | 3723 |
| 3738 void Browser::ContentRestrictionsChanged(TabContents* source) { | 3724 void Browser::ContentRestrictionsChanged(TabContents* source) { |
| 3739 UpdateCommandsForContentRestrictionState(); | 3725 UpdateCommandsForContentRestrictionState(); |
| 3740 } | 3726 } |
| 3741 | 3727 |
| 3742 void Browser::RendererUnresponsive(TabContents* source) { | 3728 void Browser::RendererUnresponsive(TabContents* source) { |
| 3729 // Ignore hangs if print preview is open. |
| 3730 TabContentsWrapper* source_wrapper = |
| 3731 TabContentsWrapper::GetCurrentWrapperForContents(source); |
| 3732 if (source_wrapper) { |
| 3733 printing::PrintPreviewTabController* controller = |
| 3734 printing::PrintPreviewTabController::GetInstance(); |
| 3735 if (controller) { |
| 3736 TabContentsWrapper* preview_tab = |
| 3737 controller->GetPrintPreviewForTab(source_wrapper); |
| 3738 if (preview_tab && preview_tab != source_wrapper) { |
| 3739 return; |
| 3740 } |
| 3741 } |
| 3742 } |
| 3743 |
| 3743 browser::ShowHungRendererDialog(source); | 3744 browser::ShowHungRendererDialog(source); |
| 3744 } | 3745 } |
| 3745 | 3746 |
| 3746 void Browser::RendererResponsive(TabContents* source) { | 3747 void Browser::RendererResponsive(TabContents* source) { |
| 3747 browser::HideHungRendererDialog(source); | 3748 browser::HideHungRendererDialog(source); |
| 3748 } | 3749 } |
| 3749 | 3750 |
| 3750 void Browser::WorkerCrashed(TabContents* source) { | 3751 void Browser::WorkerCrashed(TabContents* source) { |
| 3751 TabContentsWrapper* wrapper = | 3752 TabContentsWrapper* wrapper = |
| 3752 TabContentsWrapper::GetCurrentWrapperForContents(source); | 3753 TabContentsWrapper::GetCurrentWrapperForContents(source); |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4523 if (has_constrained_window || | 4524 if (has_constrained_window || |
| 4524 content_restrictions & CONTENT_RESTRICTION_PRINT) { | 4525 content_restrictions & CONTENT_RESTRICTION_PRINT) { |
| 4525 print_enabled = false; | 4526 print_enabled = false; |
| 4526 advanced_print_enabled = false; | 4527 advanced_print_enabled = false; |
| 4527 } | 4528 } |
| 4528 | 4529 |
| 4529 // The exception is print preview, | 4530 // The exception is print preview, |
| 4530 // where advanced printing is always enabled. | 4531 // where advanced printing is always enabled. |
| 4531 printing::PrintPreviewTabController* controller = | 4532 printing::PrintPreviewTabController* controller = |
| 4532 printing::PrintPreviewTabController::GetInstance(); | 4533 printing::PrintPreviewTabController::GetInstance(); |
| 4533 if (controller && | 4534 if (controller && controller->GetPrintPreviewForTab(wrapper)) { |
| 4534 wrapper && | |
| 4535 wrapper == controller->GetPrintPreviewForTab(wrapper)) { | |
| 4536 advanced_print_enabled = true; | 4535 advanced_print_enabled = true; |
| 4537 } | 4536 } |
| 4538 } | 4537 } |
| 4539 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); | 4538 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); |
| 4540 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, | 4539 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, |
| 4541 advanced_print_enabled); | 4540 advanced_print_enabled); |
| 4542 } | 4541 } |
| 4543 | 4542 |
| 4544 void Browser::UpdateReloadStopState(bool is_loading, bool force) { | 4543 void Browser::UpdateReloadStopState(bool is_loading, bool force) { |
| 4545 window_->UpdateReloadStopState(is_loading, force); | 4544 window_->UpdateReloadStopState(is_loading, force); |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5313 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5312 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
| 5314 } else if (is_type_tabbed()) { | 5313 } else if (is_type_tabbed()) { |
| 5315 GlobalErrorService* service = | 5314 GlobalErrorService* service = |
| 5316 GlobalErrorServiceFactory::GetForProfile(profile()); | 5315 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 5317 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5316 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
| 5318 if (error) { | 5317 if (error) { |
| 5319 error->ShowBubbleView(this); | 5318 error->ShowBubbleView(this); |
| 5320 } | 5319 } |
| 5321 } | 5320 } |
| 5322 } | 5321 } |
| OLD | NEW |