Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 8136027: Print Preview: Make print preview tab modal. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase, no renderer changes Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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/profiles/profile_manager.h" 76 #include "chrome/browser/profiles/profile_manager.h"
78 #include "chrome/browser/sessions/restore_tab_helper.h" 77 #include "chrome/browser/sessions/restore_tab_helper.h"
79 #include "chrome/browser/sessions/session_service.h" 78 #include "chrome/browser/sessions/session_service.h"
80 #include "chrome/browser/sessions/session_service_factory.h" 79 #include "chrome/browser/sessions/session_service_factory.h"
81 #include "chrome/browser/sessions/session_types.h" 80 #include "chrome/browser/sessions/session_types.h"
82 #include "chrome/browser/sessions/tab_restore_service.h" 81 #include "chrome/browser/sessions/tab_restore_service.h"
(...skipping 3456 matching lines...) Expand 10 before | Expand all | Expand 10 after
3539 void Browser::CloseContents(TabContents* source) { 3538 void Browser::CloseContents(TabContents* source) {
3540 if (is_attempting_to_close_browser_) { 3539 if (is_attempting_to_close_browser_) {
3541 // If we're trying to close the browser, just clear the state related to 3540 // If we're trying to close the browser, just clear the state related to
3542 // waiting for unload to fire. Don't actually try to close the tab as it 3541 // waiting for unload to fire. Don't actually try to close the tab as it
3543 // will go down the slow shutdown path instead of the fast path of killing 3542 // will go down the slow shutdown path instead of the fast path of killing
3544 // all the renderer processes. 3543 // all the renderer processes.
3545 ClearUnloadState(source, true); 3544 ClearUnloadState(source, true);
3546 return; 3545 return;
3547 } 3546 }
3548 3547
3549 // Various sites have a pattern which open a new window with output formatted
3550 // for printing, then include a print button, which does window.print();
3551 // window.close(); An example is printing Virgin America boarding
3552 // pass. Instead of closing, when a print tab is associated with this tab,
3553 // tell the BackgroundPrintingManager to own it, which causes it to be
3554 // hidden and eventually closed when the print window is closed.
3555 TabContentsWrapper* source_wrapper =
3556 TabContentsWrapper::GetCurrentWrapperForContents(source);
3557 if (g_browser_process->background_printing_manager()->
3558 OwnInitiatorTab(source_wrapper)) {
3559 return;
3560 }
3561
3562 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source); 3548 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source);
3563 if (index == TabStripModel::kNoTab) { 3549 if (index == TabStripModel::kNoTab) {
3564 NOTREACHED() << "CloseContents called for tab not in our strip"; 3550 NOTREACHED() << "CloseContents called for tab not in our strip";
3565 return; 3551 return;
3566 } 3552 }
3567 tab_handler_->GetTabStripModel()->CloseTabContentsAt( 3553 tab_handler_->GetTabStripModel()->CloseTabContentsAt(
3568 index, 3554 index,
3569 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); 3555 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
3570 } 3556 }
3571 3557
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
3836 // Browser::Navigate via AddNewContents. The latter will retrieve the newly 3822 // Browser::Navigate via AddNewContents. The latter will retrieve the newly
3837 // created TabContentsWrapper from TabContents object. 3823 // created TabContentsWrapper from TabContents object.
3838 new TabContentsWrapper(new_contents); 3824 new TabContentsWrapper(new_contents);
3839 } 3825 }
3840 3826
3841 void Browser::ContentRestrictionsChanged(TabContents* source) { 3827 void Browser::ContentRestrictionsChanged(TabContents* source) {
3842 UpdateCommandsForContentRestrictionState(); 3828 UpdateCommandsForContentRestrictionState();
3843 } 3829 }
3844 3830
3845 void Browser::RendererUnresponsive(TabContents* source) { 3831 void Browser::RendererUnresponsive(TabContents* source) {
3832 // Ignore hangs if print preview is open.
3833 TabContentsWrapper* source_wrapper =
3834 TabContentsWrapper::GetCurrentWrapperForContents(source);
3835 if (source_wrapper) {
3836 printing::PrintPreviewTabController* controller =
3837 printing::PrintPreviewTabController::GetInstance();
3838 if (controller) {
3839 TabContentsWrapper* preview_tab =
3840 controller->GetPrintPreviewForTab(source_wrapper);
3841 if (preview_tab && preview_tab != source_wrapper) {
3842 return;
3843 }
3844 }
3845 }
3846
3846 browser::ShowHungRendererDialog(source); 3847 browser::ShowHungRendererDialog(source);
3847 } 3848 }
3848 3849
3849 void Browser::RendererResponsive(TabContents* source) { 3850 void Browser::RendererResponsive(TabContents* source) {
3850 browser::HideHungRendererDialog(source); 3851 browser::HideHungRendererDialog(source);
3851 } 3852 }
3852 3853
3853 void Browser::WorkerCrashed(TabContents* source) { 3854 void Browser::WorkerCrashed(TabContents* source) {
3854 TabContentsWrapper* wrapper = 3855 TabContentsWrapper* wrapper =
3855 TabContentsWrapper::GetCurrentWrapperForContents(source); 3856 TabContentsWrapper::GetCurrentWrapperForContents(source);
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
4759 if (has_constrained_window || 4760 if (has_constrained_window ||
4760 content_restrictions & content::CONTENT_RESTRICTION_PRINT) { 4761 content_restrictions & content::CONTENT_RESTRICTION_PRINT) {
4761 print_enabled = false; 4762 print_enabled = false;
4762 advanced_print_enabled = false; 4763 advanced_print_enabled = false;
4763 } 4764 }
4764 4765
4765 // The exception is print preview, 4766 // The exception is print preview,
4766 // where advanced printing is always enabled. 4767 // where advanced printing is always enabled.
4767 printing::PrintPreviewTabController* controller = 4768 printing::PrintPreviewTabController* controller =
4768 printing::PrintPreviewTabController::GetInstance(); 4769 printing::PrintPreviewTabController::GetInstance();
4769 if (controller && 4770 if (controller && controller->GetPrintPreviewForTab(wrapper)) {
4770 wrapper &&
4771 wrapper == controller->GetPrintPreviewForTab(wrapper)) {
4772 advanced_print_enabled = true; 4771 advanced_print_enabled = true;
4773 } 4772 }
4774 } 4773 }
4775 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); 4774 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled);
4776 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, 4775 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT,
4777 advanced_print_enabled); 4776 advanced_print_enabled);
4778 } 4777 }
4779 4778
4780 void Browser::UpdateReloadStopState(bool is_loading, bool force) { 4779 void Browser::UpdateReloadStopState(bool is_loading, bool force) {
4781 window_->UpdateReloadStopState(is_loading, force); 4780 window_->UpdateReloadStopState(is_loading, force);
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
5502 } 5501 }
5503 5502
5504 void Browser::UpdateFullscreenExitBubbleContent() { 5503 void Browser::UpdateFullscreenExitBubbleContent() {
5505 GURL url; 5504 GURL url;
5506 if (fullscreened_tab_) 5505 if (fullscreened_tab_)
5507 url = fullscreened_tab_->tab_contents()->GetURL(); 5506 url = fullscreened_tab_->tab_contents()->GetURL();
5508 5507
5509 window_->UpdateFullscreenExitBubbleContent( 5508 window_->UpdateFullscreenExitBubbleContent(
5510 url, GetFullscreenExitBubbleType()); 5509 url, GetFullscreenExitBubbleType());
5511 } 5510 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698