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 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1749 platform_util::OpenExternal(GURL(mailto)); | 1749 platform_util::OpenExternal(GURL(mailto)); |
1750 } | 1750 } |
1751 | 1751 |
1752 void Browser::Print() { | 1752 void Browser::Print() { |
1753 if (switches::IsPrintPreviewEnabled()) | 1753 if (switches::IsPrintPreviewEnabled()) |
1754 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow(); | 1754 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow(); |
1755 else | 1755 else |
1756 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow(); | 1756 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow(); |
1757 } | 1757 } |
1758 | 1758 |
1759 void Browser::AdvancedPrint() { | |
1760 GetSelectedTabContentsWrapper()->print_view_manager()->AdvancedPrintNow(); | |
1761 } | |
1762 | |
1759 void Browser::ToggleEncodingAutoDetect() { | 1763 void Browser::ToggleEncodingAutoDetect() { |
1760 UserMetrics::RecordAction(UserMetricsAction("AutoDetectChange")); | 1764 UserMetrics::RecordAction(UserMetricsAction("AutoDetectChange")); |
1761 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); | 1765 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); |
1762 // If "auto detect" is turned on, then any current override encoding | 1766 // If "auto detect" is turned on, then any current override encoding |
1763 // is cleared. This also implicitly performs a reload. | 1767 // is cleared. This also implicitly performs a reload. |
1764 // OTOH, if "auto detect" is turned off, we don't change the currently | 1768 // OTOH, if "auto detect" is turned off, we don't change the currently |
1765 // active encoding. | 1769 // active encoding. |
1766 if (encoding_auto_detect_.GetValue()) { | 1770 if (encoding_auto_detect_.GetValue()) { |
1767 TabContents* contents = GetSelectedTabContents(); | 1771 TabContents* contents = GetSelectedTabContents(); |
1768 if (contents) | 1772 if (contents) |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2422 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break; | 2426 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break; |
2423 #endif | 2427 #endif |
2424 | 2428 |
2425 // Page-related commands | 2429 // Page-related commands |
2426 case IDC_SAVE_PAGE: SavePage(); break; | 2430 case IDC_SAVE_PAGE: SavePage(); break; |
2427 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; | 2431 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; |
2428 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; | 2432 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; |
2429 case IDC_VIEW_SOURCE: ViewSelectedSource(); break; | 2433 case IDC_VIEW_SOURCE: ViewSelectedSource(); break; |
2430 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; | 2434 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; |
2431 case IDC_PRINT: Print(); break; | 2435 case IDC_PRINT: Print(); break; |
2436 case IDC_ADVANCED_PRINT: AdvancedPrint(); break; | |
2432 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; | 2437 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; |
2433 case IDC_ENCODING_UTF8: | 2438 case IDC_ENCODING_UTF8: |
2434 case IDC_ENCODING_UTF16LE: | 2439 case IDC_ENCODING_UTF16LE: |
2435 case IDC_ENCODING_ISO88591: | 2440 case IDC_ENCODING_ISO88591: |
2436 case IDC_ENCODING_WINDOWS1252: | 2441 case IDC_ENCODING_WINDOWS1252: |
2437 case IDC_ENCODING_GBK: | 2442 case IDC_ENCODING_GBK: |
2438 case IDC_ENCODING_GB18030: | 2443 case IDC_ENCODING_GB18030: |
2439 case IDC_ENCODING_BIG5HKSCS: | 2444 case IDC_ENCODING_BIG5HKSCS: |
2440 case IDC_ENCODING_BIG5: | 2445 case IDC_ENCODING_BIG5: |
2441 case IDC_ENCODING_KOREAN: | 2446 case IDC_ENCODING_KOREAN: |
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4153 command_updater_.UpdateCommandEnabled( | 4158 command_updater_.UpdateCommandEnabled( |
4154 IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE)); | 4159 IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE)); |
4155 UpdateSaveAsState(restrictions); | 4160 UpdateSaveAsState(restrictions); |
4156 UpdatePrintingState(restrictions); | 4161 UpdatePrintingState(restrictions); |
4157 } | 4162 } |
4158 | 4163 |
4159 void Browser::UpdatePrintingState(int content_restrictions) { | 4164 void Browser::UpdatePrintingState(int content_restrictions) { |
4160 bool enabled = true; | 4165 bool enabled = true; |
4161 if (content_restrictions & CONTENT_RESTRICTION_PRINT) { | 4166 if (content_restrictions & CONTENT_RESTRICTION_PRINT) { |
4162 enabled = false; | 4167 enabled = false; |
4168 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, true); | |
Lei Zhang
2011/08/24 01:27:28
You don't always want to do this. For example, if
kmadhusu
2011/08/25 02:15:20
Fixed.
| |
4163 } else if (g_browser_process->local_state()) { | 4169 } else if (g_browser_process->local_state()) { |
4164 enabled = g_browser_process->local_state()-> | 4170 enabled = g_browser_process->local_state()-> |
4165 GetBoolean(prefs::kPrintingEnabled); | 4171 GetBoolean(prefs::kPrintingEnabled); |
4172 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, enabled); | |
4166 } | 4173 } |
4167 command_updater_.UpdateCommandEnabled(IDC_PRINT, enabled); | 4174 command_updater_.UpdateCommandEnabled(IDC_PRINT, enabled); |
4168 } | 4175 } |
4169 | 4176 |
4170 void Browser::UpdateReloadStopState(bool is_loading, bool force) { | 4177 void Browser::UpdateReloadStopState(bool is_loading, bool force) { |
4171 window_->UpdateReloadStopState(is_loading, force); | 4178 window_->UpdateReloadStopState(is_loading, force); |
4172 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); | 4179 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
4173 } | 4180 } |
4174 | 4181 |
4175 void Browser::UpdateCommandsForDevTools() { | 4182 void Browser::UpdateCommandsForDevTools() { |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4884 } | 4891 } |
4885 | 4892 |
4886 void Browser::ShowSyncSetup() { | 4893 void Browser::ShowSyncSetup() { |
4887 ProfileSyncService* service = | 4894 ProfileSyncService* service = |
4888 profile()->GetOriginalProfile()->GetProfileSyncService(); | 4895 profile()->GetOriginalProfile()->GetProfileSyncService(); |
4889 if (service->HasSyncSetupCompleted()) | 4896 if (service->HasSyncSetupCompleted()) |
4890 ShowOptionsTab(chrome::kSyncSetupSubPage); | 4897 ShowOptionsTab(chrome::kSyncSetupSubPage); |
4891 else | 4898 else |
4892 service->ShowLoginDialog(); | 4899 service->ShowLoginDialog(); |
4893 } | 4900 } |
OLD | NEW |