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

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: address preview tab navigation, cancelling print to pdf issues Created 9 years, 2 months 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/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 3360 matching lines...) Expand 10 before | Expand all | Expand 10 after
3443 void Browser::CloseContents(TabContents* source) { 3442 void Browser::CloseContents(TabContents* source) {
3444 if (is_attempting_to_close_browser_) { 3443 if (is_attempting_to_close_browser_) {
3445 // If we're trying to close the browser, just clear the state related to 3444 // If we're trying to close the browser, just clear the state related to
3446 // waiting for unload to fire. Don't actually try to close the tab as it 3445 // waiting for unload to fire. Don't actually try to close the tab as it
3447 // will go down the slow shutdown path instead of the fast path of killing 3446 // will go down the slow shutdown path instead of the fast path of killing
3448 // all the renderer processes. 3447 // all the renderer processes.
3449 ClearUnloadState(source, true); 3448 ClearUnloadState(source, true);
3450 return; 3449 return;
3451 } 3450 }
3452 3451
3453 // Various sites have a pattern which open a new window with output formatted
3454 // for printing, then include a print button, which does window.print();
3455 // window.close(); An example is printing Virgin America boarding
3456 // pass. Instead of closing, when a print tab is associated with this tab,
3457 // tell the BackgroundPrintingManager to own it, which causes it to be
3458 // hidden and eventually closed when the print window is closed.
3459 TabContentsWrapper* source_wrapper =
3460 TabContentsWrapper::GetCurrentWrapperForContents(source);
3461 if (g_browser_process->background_printing_manager()->
3462 OwnInitiatorTab(source_wrapper)) {
3463 return;
3464 }
3465
3466 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source); 3452 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source);
3467 if (index == TabStripModel::kNoTab) { 3453 if (index == TabStripModel::kNoTab) {
3468 NOTREACHED() << "CloseContents called for tab not in our strip"; 3454 NOTREACHED() << "CloseContents called for tab not in our strip";
3469 return; 3455 return;
3470 } 3456 }
3471 tab_handler_->GetTabStripModel()->CloseTabContentsAt( 3457 tab_handler_->GetTabStripModel()->CloseTabContentsAt(
3472 index, 3458 index,
3473 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); 3459 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
3474 } 3460 }
3475 3461
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
3726 NavigationType::Type navigation_type) { 3712 NavigationType::Type navigation_type) {
3727 // Don't update history if running as app. 3713 // Don't update history if running as app.
3728 return !IsApplication(); 3714 return !IsApplication();
3729 } 3715 }
3730 3716
3731 void Browser::ContentRestrictionsChanged(TabContents* source) { 3717 void Browser::ContentRestrictionsChanged(TabContents* source) {
3732 UpdateCommandsForContentRestrictionState(); 3718 UpdateCommandsForContentRestrictionState();
3733 } 3719 }
3734 3720
3735 void Browser::RendererUnresponsive(TabContents* source) { 3721 void Browser::RendererUnresponsive(TabContents* source) {
3722 // Ignore hangs if print preview is open.
3723 TabContentsWrapper* source_wrapper =
3724 TabContentsWrapper::GetCurrentWrapperForContents(source);
3725 if (source_wrapper) {
3726 printing::PrintPreviewTabController* controller =
3727 printing::PrintPreviewTabController::GetInstance();
3728 if (controller) {
3729 TabContentsWrapper* preview_tab =
3730 controller->GetPrintPreviewForTab(source_wrapper);
3731 if (preview_tab && preview_tab != source_wrapper) {
3732 return;
3733 }
3734 }
3735 }
3736
3736 browser::ShowHungRendererDialog(source); 3737 browser::ShowHungRendererDialog(source);
3737 } 3738 }
3738 3739
3739 void Browser::RendererResponsive(TabContents* source) { 3740 void Browser::RendererResponsive(TabContents* source) {
3740 browser::HideHungRendererDialog(source); 3741 browser::HideHungRendererDialog(source);
3741 } 3742 }
3742 3743
3743 void Browser::WorkerCrashed(TabContents* source) { 3744 void Browser::WorkerCrashed(TabContents* source) {
3744 TabContentsWrapper* wrapper = 3745 TabContentsWrapper* wrapper =
3745 TabContentsWrapper::GetCurrentWrapperForContents(source); 3746 TabContentsWrapper::GetCurrentWrapperForContents(source);
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
4516 if (has_constrained_window || 4517 if (has_constrained_window ||
4517 content_restrictions & CONTENT_RESTRICTION_PRINT) { 4518 content_restrictions & CONTENT_RESTRICTION_PRINT) {
4518 print_enabled = false; 4519 print_enabled = false;
4519 advanced_print_enabled = false; 4520 advanced_print_enabled = false;
4520 } 4521 }
4521 4522
4522 // The exception is print preview, 4523 // The exception is print preview,
4523 // where advanced printing is always enabled. 4524 // where advanced printing is always enabled.
4524 printing::PrintPreviewTabController* controller = 4525 printing::PrintPreviewTabController* controller =
4525 printing::PrintPreviewTabController::GetInstance(); 4526 printing::PrintPreviewTabController::GetInstance();
4526 if (controller && 4527 if (controller && controller->GetPrintPreviewForTab(wrapper)) {
kmadhusu 2011/10/14 00:21:09 nit: {} not required
Lei Zhang 2011/10/14 20:31:27 I like it for readability for nested if blocks.
4527 wrapper &&
4528 wrapper == controller->GetPrintPreviewForTab(wrapper)) {
4529 advanced_print_enabled = true; 4528 advanced_print_enabled = true;
4530 } 4529 }
4531 } 4530 }
4532 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); 4531 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled);
4533 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, 4532 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT,
4534 advanced_print_enabled); 4533 advanced_print_enabled);
4535 } 4534 }
4536 4535
4537 void Browser::UpdateReloadStopState(bool is_loading, bool force) { 4536 void Browser::UpdateReloadStopState(bool is_loading, bool force) {
4538 window_->UpdateReloadStopState(is_loading, force); 4537 window_->UpdateReloadStopState(is_loading, force);
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
5306 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); 5305 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type);
5307 } else if (is_type_tabbed()) { 5306 } else if (is_type_tabbed()) {
5308 GlobalErrorService* service = 5307 GlobalErrorService* service =
5309 GlobalErrorServiceFactory::GetForProfile(profile()); 5308 GlobalErrorServiceFactory::GetForProfile(profile());
5310 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); 5309 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView();
5311 if (error) { 5310 if (error) {
5312 error->ShowBubbleView(this); 5311 error->ShowBubbleView(this);
5313 } 5312 }
5314 } 5313 }
5315 } 5314 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698