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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 #include "chrome/browser/google/google_util.h" | 50 #include "chrome/browser/google/google_util.h" |
51 #include "chrome/browser/instant/instant_controller.h" | 51 #include "chrome/browser/instant/instant_controller.h" |
52 #include "chrome/browser/instant/instant_unload_handler.h" | 52 #include "chrome/browser/instant/instant_unload_handler.h" |
53 #include "chrome/browser/net/browser_url_util.h" | 53 #include "chrome/browser/net/browser_url_util.h" |
54 #include "chrome/browser/net/url_fixer_upper.h" | 54 #include "chrome/browser/net/url_fixer_upper.h" |
55 #include "chrome/browser/notifications/notification_ui_manager.h" | 55 #include "chrome/browser/notifications/notification_ui_manager.h" |
56 #include "chrome/browser/platform_util.h" | 56 #include "chrome/browser/platform_util.h" |
57 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 57 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
58 #include "chrome/browser/prefs/pref_service.h" | 58 #include "chrome/browser/prefs/pref_service.h" |
59 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 59 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
60 #include "chrome/browser/printing/print_preview_tab_controller.h" | |
60 #include "chrome/browser/profiles/profile.h" | 61 #include "chrome/browser/profiles/profile.h" |
61 #include "chrome/browser/sessions/restore_tab_helper.h" | 62 #include "chrome/browser/sessions/restore_tab_helper.h" |
62 #include "chrome/browser/sessions/session_service.h" | 63 #include "chrome/browser/sessions/session_service.h" |
63 #include "chrome/browser/sessions/session_service_factory.h" | 64 #include "chrome/browser/sessions/session_service_factory.h" |
64 #include "chrome/browser/sessions/session_types.h" | 65 #include "chrome/browser/sessions/session_types.h" |
65 #include "chrome/browser/sessions/tab_restore_service.h" | 66 #include "chrome/browser/sessions/tab_restore_service.h" |
66 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 67 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
67 #include "chrome/browser/sync/profile_sync_service.h" | 68 #include "chrome/browser/sync/profile_sync_service.h" |
68 #include "chrome/browser/sync/sync_ui_util.h" | 69 #include "chrome/browser/sync/sync_ui_util.h" |
69 #include "chrome/browser/tab_closeable_state_watcher.h" | 70 #include "chrome/browser/tab_closeable_state_watcher.h" |
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1750 platform_util::OpenExternal(GURL(mailto)); | 1751 platform_util::OpenExternal(GURL(mailto)); |
1751 } | 1752 } |
1752 | 1753 |
1753 void Browser::Print() { | 1754 void Browser::Print() { |
1754 if (switches::IsPrintPreviewEnabled()) | 1755 if (switches::IsPrintPreviewEnabled()) |
1755 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow(); | 1756 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow(); |
1756 else | 1757 else |
1757 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow(); | 1758 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow(); |
1758 } | 1759 } |
1759 | 1760 |
1761 void Browser::AdvancedPrint() { | |
1762 GetSelectedTabContentsWrapper()->print_view_manager()->AdvancedPrintNow(); | |
1763 } | |
1764 | |
1760 void Browser::ToggleEncodingAutoDetect() { | 1765 void Browser::ToggleEncodingAutoDetect() { |
1761 UserMetrics::RecordAction(UserMetricsAction("AutoDetectChange")); | 1766 UserMetrics::RecordAction(UserMetricsAction("AutoDetectChange")); |
1762 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); | 1767 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); |
1763 // If "auto detect" is turned on, then any current override encoding | 1768 // If "auto detect" is turned on, then any current override encoding |
1764 // is cleared. This also implicitly performs a reload. | 1769 // is cleared. This also implicitly performs a reload. |
1765 // OTOH, if "auto detect" is turned off, we don't change the currently | 1770 // OTOH, if "auto detect" is turned off, we don't change the currently |
1766 // active encoding. | 1771 // active encoding. |
1767 if (encoding_auto_detect_.GetValue()) { | 1772 if (encoding_auto_detect_.GetValue()) { |
1768 TabContents* contents = GetSelectedTabContents(); | 1773 TabContents* contents = GetSelectedTabContents(); |
1769 if (contents) | 1774 if (contents) |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2423 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break; | 2428 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break; |
2424 #endif | 2429 #endif |
2425 | 2430 |
2426 // Page-related commands | 2431 // Page-related commands |
2427 case IDC_SAVE_PAGE: SavePage(); break; | 2432 case IDC_SAVE_PAGE: SavePage(); break; |
2428 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; | 2433 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; |
2429 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; | 2434 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; |
2430 case IDC_VIEW_SOURCE: ViewSelectedSource(); break; | 2435 case IDC_VIEW_SOURCE: ViewSelectedSource(); break; |
2431 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; | 2436 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; |
2432 case IDC_PRINT: Print(); break; | 2437 case IDC_PRINT: Print(); break; |
2438 case IDC_ADVANCED_PRINT: AdvancedPrint(); break; | |
2433 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; | 2439 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; |
2434 case IDC_ENCODING_UTF8: | 2440 case IDC_ENCODING_UTF8: |
2435 case IDC_ENCODING_UTF16LE: | 2441 case IDC_ENCODING_UTF16LE: |
2436 case IDC_ENCODING_ISO88591: | 2442 case IDC_ENCODING_ISO88591: |
2437 case IDC_ENCODING_WINDOWS1252: | 2443 case IDC_ENCODING_WINDOWS1252: |
2438 case IDC_ENCODING_GBK: | 2444 case IDC_ENCODING_GBK: |
2439 case IDC_ENCODING_GB18030: | 2445 case IDC_ENCODING_GB18030: |
2440 case IDC_ENCODING_BIG5HKSCS: | 2446 case IDC_ENCODING_BIG5HKSCS: |
2441 case IDC_ENCODING_BIG5: | 2447 case IDC_ENCODING_BIG5: |
2442 case IDC_ENCODING_KOREAN: | 2448 case IDC_ENCODING_KOREAN: |
(...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4152 command_updater_.UpdateCommandEnabled( | 4158 command_updater_.UpdateCommandEnabled( |
4153 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT)); | 4159 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT)); |
4154 command_updater_.UpdateCommandEnabled( | 4160 command_updater_.UpdateCommandEnabled( |
4155 IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE)); | 4161 IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE)); |
4156 UpdateSaveAsState(restrictions); | 4162 UpdateSaveAsState(restrictions); |
4157 UpdatePrintingState(restrictions); | 4163 UpdatePrintingState(restrictions); |
4158 } | 4164 } |
4159 | 4165 |
4160 void Browser::UpdatePrintingState(int content_restrictions) { | 4166 void Browser::UpdatePrintingState(int content_restrictions) { |
4161 bool enabled = true; | 4167 bool enabled = true; |
4168 bool is_preview_tab = true; | |
Lei Zhang
2011/08/25 09:05:49
This variable is poorly named. It's true in some c
kmadhusu
2011/08/25 17:51:48
Fixed...
| |
4162 if (content_restrictions & CONTENT_RESTRICTION_PRINT) { | 4169 if (content_restrictions & CONTENT_RESTRICTION_PRINT) { |
4163 enabled = false; | 4170 enabled = false; |
4171 is_preview_tab = printing::PrintPreviewTabController::IsPrintPreviewTab( | |
4172 GetSelectedTabContents()); | |
4164 } else if (g_browser_process->local_state()) { | 4173 } else if (g_browser_process->local_state()) { |
4165 enabled = g_browser_process->local_state()-> | 4174 enabled = g_browser_process->local_state()-> |
4166 GetBoolean(prefs::kPrintingEnabled); | 4175 GetBoolean(prefs::kPrintingEnabled); |
4167 } | 4176 } |
4168 command_updater_.UpdateCommandEnabled(IDC_PRINT, enabled); | 4177 command_updater_.UpdateCommandEnabled(IDC_PRINT, enabled); |
4178 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, | |
4179 is_preview_tab ? true : enabled); | |
4169 } | 4180 } |
4170 | 4181 |
4171 void Browser::UpdateReloadStopState(bool is_loading, bool force) { | 4182 void Browser::UpdateReloadStopState(bool is_loading, bool force) { |
4172 window_->UpdateReloadStopState(is_loading, force); | 4183 window_->UpdateReloadStopState(is_loading, force); |
4173 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); | 4184 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
4174 } | 4185 } |
4175 | 4186 |
4176 void Browser::UpdateCommandsForDevTools() { | 4187 void Browser::UpdateCommandsForDevTools() { |
4177 bool dev_tools_enabled = | 4188 bool dev_tools_enabled = |
4178 !profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); | 4189 !profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4885 } | 4896 } |
4886 | 4897 |
4887 void Browser::ShowSyncSetup() { | 4898 void Browser::ShowSyncSetup() { |
4888 ProfileSyncService* service = | 4899 ProfileSyncService* service = |
4889 profile()->GetOriginalProfile()->GetProfileSyncService(); | 4900 profile()->GetOriginalProfile()->GetProfileSyncService(); |
4890 if (service->HasSyncSetupCompleted()) | 4901 if (service->HasSyncSetupCompleted()) |
4891 ShowOptionsTab(chrome::kSyncSetupSubPage); | 4902 ShowOptionsTab(chrome::kSyncSetupSubPage); |
4892 else | 4903 else |
4893 service->ShowLoginDialog(); | 4904 service->ShowLoginDialog(); |
4894 } | 4905 } |
OLD | NEW |