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

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

Issue 7721001: PrintPreview: Make ctrl-shift-p start the native print flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + merge conflicts fix Created 9 years, 4 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "chrome/browser/instant/instant_controller.h" 54 #include "chrome/browser/instant/instant_controller.h"
55 #include "chrome/browser/instant/instant_unload_handler.h" 55 #include "chrome/browser/instant/instant_unload_handler.h"
56 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" 56 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
57 #include "chrome/browser/net/browser_url_util.h" 57 #include "chrome/browser/net/browser_url_util.h"
58 #include "chrome/browser/net/url_fixer_upper.h" 58 #include "chrome/browser/net/url_fixer_upper.h"
59 #include "chrome/browser/notifications/notification_ui_manager.h" 59 #include "chrome/browser/notifications/notification_ui_manager.h"
60 #include "chrome/browser/platform_util.h" 60 #include "chrome/browser/platform_util.h"
61 #include "chrome/browser/prefs/incognito_mode_prefs.h" 61 #include "chrome/browser/prefs/incognito_mode_prefs.h"
62 #include "chrome/browser/prefs/pref_service.h" 62 #include "chrome/browser/prefs/pref_service.h"
63 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" 63 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"
64 #include "chrome/browser/printing/print_preview_tab_controller.h"
64 #include "chrome/browser/profiles/profile.h" 65 #include "chrome/browser/profiles/profile.h"
65 #include "chrome/browser/sessions/restore_tab_helper.h" 66 #include "chrome/browser/sessions/restore_tab_helper.h"
66 #include "chrome/browser/sessions/session_service.h" 67 #include "chrome/browser/sessions/session_service.h"
67 #include "chrome/browser/sessions/session_service_factory.h" 68 #include "chrome/browser/sessions/session_service_factory.h"
68 #include "chrome/browser/sessions/session_types.h" 69 #include "chrome/browser/sessions/session_types.h"
69 #include "chrome/browser/sessions/tab_restore_service.h" 70 #include "chrome/browser/sessions/tab_restore_service.h"
70 #include "chrome/browser/sessions/tab_restore_service_factory.h" 71 #include "chrome/browser/sessions/tab_restore_service_factory.h"
71 #include "chrome/browser/sync/profile_sync_service.h" 72 #include "chrome/browser/sync/profile_sync_service.h"
72 #include "chrome/browser/sync/sync_ui_util.h" 73 #include "chrome/browser/sync/sync_ui_util.h"
73 #include "chrome/browser/tab_closeable_state_watcher.h" 74 #include "chrome/browser/tab_closeable_state_watcher.h"
(...skipping 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 platform_util::OpenExternal(GURL(mailto)); 1788 platform_util::OpenExternal(GURL(mailto));
1788 } 1789 }
1789 1790
1790 void Browser::Print() { 1791 void Browser::Print() {
1791 if (switches::IsPrintPreviewEnabled()) 1792 if (switches::IsPrintPreviewEnabled())
1792 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow(); 1793 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow();
1793 else 1794 else
1794 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow(); 1795 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow();
1795 } 1796 }
1796 1797
1798 void Browser::AdvancedPrint() {
1799 GetSelectedTabContentsWrapper()->print_view_manager()->AdvancedPrintNow();
1800 }
1801
1797 void Browser::ToggleEncodingAutoDetect() { 1802 void Browser::ToggleEncodingAutoDetect() {
1798 UserMetrics::RecordAction(UserMetricsAction("AutoDetectChange")); 1803 UserMetrics::RecordAction(UserMetricsAction("AutoDetectChange"));
1799 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); 1804 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue());
1800 // If "auto detect" is turned on, then any current override encoding 1805 // If "auto detect" is turned on, then any current override encoding
1801 // is cleared. This also implicitly performs a reload. 1806 // is cleared. This also implicitly performs a reload.
1802 // OTOH, if "auto detect" is turned off, we don't change the currently 1807 // OTOH, if "auto detect" is turned off, we don't change the currently
1803 // active encoding. 1808 // active encoding.
1804 if (encoding_auto_detect_.GetValue()) { 1809 if (encoding_auto_detect_.GetValue()) {
1805 TabContents* contents = GetSelectedTabContents(); 1810 TabContents* contents = GetSelectedTabContents();
1806 if (contents) 1811 if (contents)
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
2581 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break; 2586 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break;
2582 #endif 2587 #endif
2583 2588
2584 // Page-related commands 2589 // Page-related commands
2585 case IDC_SAVE_PAGE: SavePage(); break; 2590 case IDC_SAVE_PAGE: SavePage(); break;
2586 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; 2591 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break;
2587 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; 2592 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break;
2588 case IDC_VIEW_SOURCE: ViewSelectedSource(); break; 2593 case IDC_VIEW_SOURCE: ViewSelectedSource(); break;
2589 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; 2594 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break;
2590 case IDC_PRINT: Print(); break; 2595 case IDC_PRINT: Print(); break;
2596 case IDC_ADVANCED_PRINT: AdvancedPrint(); break;
2591 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; 2597 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break;
2592 case IDC_ENCODING_UTF8: 2598 case IDC_ENCODING_UTF8:
2593 case IDC_ENCODING_UTF16LE: 2599 case IDC_ENCODING_UTF16LE:
2594 case IDC_ENCODING_ISO88591: 2600 case IDC_ENCODING_ISO88591:
2595 case IDC_ENCODING_WINDOWS1252: 2601 case IDC_ENCODING_WINDOWS1252:
2596 case IDC_ENCODING_GBK: 2602 case IDC_ENCODING_GBK:
2597 case IDC_ENCODING_GB18030: 2603 case IDC_ENCODING_GB18030:
2598 case IDC_ENCODING_BIG5HKSCS: 2604 case IDC_ENCODING_BIG5HKSCS:
2599 case IDC_ENCODING_BIG5: 2605 case IDC_ENCODING_BIG5:
2600 case IDC_ENCODING_KOREAN: 2606 case IDC_ENCODING_KOREAN:
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after
4370 command_updater_.UpdateCommandEnabled( 4376 command_updater_.UpdateCommandEnabled(
4371 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT)); 4377 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT));
4372 command_updater_.UpdateCommandEnabled( 4378 command_updater_.UpdateCommandEnabled(
4373 IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE)); 4379 IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE));
4374 UpdateSaveAsState(restrictions); 4380 UpdateSaveAsState(restrictions);
4375 UpdatePrintingState(restrictions); 4381 UpdatePrintingState(restrictions);
4376 } 4382 }
4377 4383
4378 void Browser::UpdatePrintingState(int content_restrictions) { 4384 void Browser::UpdatePrintingState(int content_restrictions) {
4379 bool enabled = true; 4385 bool enabled = true;
4386 bool selected_tab_is_preview_tab = false;
4380 if (content_restrictions & CONTENT_RESTRICTION_PRINT) { 4387 if (content_restrictions & CONTENT_RESTRICTION_PRINT) {
4381 enabled = false; 4388 enabled = false;
4389 selected_tab_is_preview_tab =
4390 printing::PrintPreviewTabController::IsPrintPreviewTab(
4391 GetSelectedTabContents());
4382 } else if (g_browser_process->local_state()) { 4392 } else if (g_browser_process->local_state()) {
4383 enabled = g_browser_process->local_state()-> 4393 enabled = g_browser_process->local_state()->
4384 GetBoolean(prefs::kPrintingEnabled); 4394 GetBoolean(prefs::kPrintingEnabled);
4385 } 4395 }
4386 command_updater_.UpdateCommandEnabled(IDC_PRINT, enabled); 4396 command_updater_.UpdateCommandEnabled(IDC_PRINT, enabled);
4397 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT,
4398 selected_tab_is_preview_tab ? true :
4399 enabled);
4387 } 4400 }
4388 4401
4389 void Browser::UpdateReloadStopState(bool is_loading, bool force) { 4402 void Browser::UpdateReloadStopState(bool is_loading, bool force) {
4390 window_->UpdateReloadStopState(is_loading, force); 4403 window_->UpdateReloadStopState(is_loading, force);
4391 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); 4404 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading);
4392 } 4405 }
4393 4406
4394 void Browser::UpdateCommandsForDevTools() { 4407 void Browser::UpdateCommandsForDevTools() {
4395 bool dev_tools_enabled = 4408 bool dev_tools_enabled =
4396 !profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); 4409 !profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled);
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
5103 } 5116 }
5104 5117
5105 void Browser::ShowSyncSetup() { 5118 void Browser::ShowSyncSetup() {
5106 ProfileSyncService* service = 5119 ProfileSyncService* service =
5107 profile()->GetOriginalProfile()->GetProfileSyncService(); 5120 profile()->GetOriginalProfile()->GetProfileSyncService();
5108 if (service->HasSyncSetupCompleted()) 5121 if (service->HasSyncSetupCompleted())
5109 ShowOptionsTab(chrome::kSyncSetupSubPage); 5122 ShowOptionsTab(chrome::kSyncSetupSubPage);
5110 else 5123 else
5111 service->ShowLoginDialog(); 5124 service->ShowLoginDialog();
5112 } 5125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698