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

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 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 3462 matching lines...) Expand 10 before | Expand all | Expand 10 after
3545 void Browser::CloseContents(TabContents* source) { 3544 void Browser::CloseContents(TabContents* source) {
3546 if (is_attempting_to_close_browser_) { 3545 if (is_attempting_to_close_browser_) {
3547 // If we're trying to close the browser, just clear the state related to 3546 // If we're trying to close the browser, just clear the state related to
3548 // waiting for unload to fire. Don't actually try to close the tab as it 3547 // waiting for unload to fire. Don't actually try to close the tab as it
3549 // will go down the slow shutdown path instead of the fast path of killing 3548 // will go down the slow shutdown path instead of the fast path of killing
3550 // all the renderer processes. 3549 // all the renderer processes.
3551 ClearUnloadState(source, true); 3550 ClearUnloadState(source, true);
3552 return; 3551 return;
3553 } 3552 }
3554 3553
3555 // Various sites have a pattern which open a new window with output formatted
3556 // for printing, then include a print button, which does window.print();
3557 // window.close(); An example is printing Virgin America boarding
3558 // pass. Instead of closing, when a print tab is associated with this tab,
3559 // tell the BackgroundPrintingManager to own it, which causes it to be
3560 // hidden and eventually closed when the print window is closed.
3561 TabContentsWrapper* source_wrapper =
3562 TabContentsWrapper::GetCurrentWrapperForContents(source);
3563 if (g_browser_process->background_printing_manager()->
3564 OwnInitiatorTab(source_wrapper)) {
3565 return;
3566 }
3567
3568 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source); 3554 int index = tab_handler_->GetTabStripModel()->GetWrapperIndex(source);
3569 if (index == TabStripModel::kNoTab) { 3555 if (index == TabStripModel::kNoTab) {
3570 NOTREACHED() << "CloseContents called for tab not in our strip"; 3556 NOTREACHED() << "CloseContents called for tab not in our strip";
3571 return; 3557 return;
3572 } 3558 }
3573 tab_handler_->GetTabStripModel()->CloseTabContentsAt( 3559 tab_handler_->GetTabStripModel()->CloseTabContentsAt(
3574 index, 3560 index,
3575 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); 3561 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
3576 } 3562 }
3577 3563
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
3840 // Browser::Navigate via AddNewContents. The latter will retrieve the newly 3826 // Browser::Navigate via AddNewContents. The latter will retrieve the newly
3841 // created TabContentsWrapper from TabContents object. 3827 // created TabContentsWrapper from TabContents object.
3842 new TabContentsWrapper(new_contents); 3828 new TabContentsWrapper(new_contents);
3843 } 3829 }
3844 3830
3845 void Browser::ContentRestrictionsChanged(TabContents* source) { 3831 void Browser::ContentRestrictionsChanged(TabContents* source) {
3846 UpdateCommandsForContentRestrictionState(); 3832 UpdateCommandsForContentRestrictionState();
3847 } 3833 }
3848 3834
3849 void Browser::RendererUnresponsive(TabContents* source) { 3835 void Browser::RendererUnresponsive(TabContents* source) {
3836 // Ignore hangs if print preview is open.
3837 TabContentsWrapper* source_wrapper =
3838 TabContentsWrapper::GetCurrentWrapperForContents(source);
3839 if (source_wrapper) {
3840 printing::PrintPreviewTabController* controller =
3841 printing::PrintPreviewTabController::GetInstance();
3842 if (controller) {
3843 TabContentsWrapper* preview_tab =
3844 controller->GetPrintPreviewForTab(source_wrapper);
3845 if (preview_tab && preview_tab != source_wrapper) {
3846 return;
3847 }
3848 }
3849 }
3850
3850 browser::ShowHungRendererDialog(source); 3851 browser::ShowHungRendererDialog(source);
3851 } 3852 }
3852 3853
3853 void Browser::RendererResponsive(TabContents* source) { 3854 void Browser::RendererResponsive(TabContents* source) {
3854 browser::HideHungRendererDialog(source); 3855 browser::HideHungRendererDialog(source);
3855 } 3856 }
3856 3857
3857 void Browser::WorkerCrashed(TabContents* source) { 3858 void Browser::WorkerCrashed(TabContents* source) {
3858 TabContentsWrapper* wrapper = 3859 TabContentsWrapper* wrapper =
3859 TabContentsWrapper::GetCurrentWrapperForContents(source); 3860 TabContentsWrapper::GetCurrentWrapperForContents(source);
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
4783 if (has_constrained_window || 4784 if (has_constrained_window ||
4784 content_restrictions & content::CONTENT_RESTRICTION_PRINT) { 4785 content_restrictions & content::CONTENT_RESTRICTION_PRINT) {
4785 print_enabled = false; 4786 print_enabled = false;
4786 advanced_print_enabled = false; 4787 advanced_print_enabled = false;
4787 } 4788 }
4788 4789
4789 // The exception is print preview, 4790 // The exception is print preview,
4790 // where advanced printing is always enabled. 4791 // where advanced printing is always enabled.
4791 printing::PrintPreviewTabController* controller = 4792 printing::PrintPreviewTabController* controller =
4792 printing::PrintPreviewTabController::GetInstance(); 4793 printing::PrintPreviewTabController::GetInstance();
4793 if (controller && 4794 if (controller && controller->GetPrintPreviewForTab(wrapper)) {
4794 wrapper &&
4795 wrapper == controller->GetPrintPreviewForTab(wrapper)) {
4796 advanced_print_enabled = true; 4795 advanced_print_enabled = true;
4797 } 4796 }
4798 } 4797 }
4799 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); 4798 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled);
4800 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, 4799 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT,
4801 advanced_print_enabled); 4800 advanced_print_enabled);
4802 } 4801 }
4803 4802
4804 void Browser::UpdateReloadStopState(bool is_loading, bool force) { 4803 void Browser::UpdateReloadStopState(bool is_loading, bool force) {
4805 window_->UpdateReloadStopState(is_loading, force); 4804 window_->UpdateReloadStopState(is_loading, force);
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
5521 } 5520 }
5522 5521
5523 void Browser::UpdateFullscreenExitBubbleContent() { 5522 void Browser::UpdateFullscreenExitBubbleContent() {
5524 GURL url; 5523 GURL url;
5525 if (fullscreened_tab_) 5524 if (fullscreened_tab_)
5526 url = fullscreened_tab_->tab_contents()->GetURL(); 5525 url = fullscreened_tab_->tab_contents()->GetURL();
5527 5526
5528 window_->UpdateFullscreenExitBubbleContent( 5527 window_->UpdateFullscreenExitBubbleContent(
5529 url, GetFullscreenExitBubbleType()); 5528 url, GetFullscreenExitBubbleType());
5530 } 5529 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.js ('k') | chrome/browser/ui/browser_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698