| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "chrome/browser/google/google_util.h" | 51 #include "chrome/browser/google/google_util.h" |
| 52 #include "chrome/browser/instant/instant_controller.h" | 52 #include "chrome/browser/instant/instant_controller.h" |
| 53 #include "chrome/browser/instant/instant_unload_handler.h" | 53 #include "chrome/browser/instant/instant_unload_handler.h" |
| 54 #include "chrome/browser/net/browser_url_util.h" | 54 #include "chrome/browser/net/browser_url_util.h" |
| 55 #include "chrome/browser/net/url_fixer_upper.h" | 55 #include "chrome/browser/net/url_fixer_upper.h" |
| 56 #include "chrome/browser/notifications/notification_ui_manager.h" | 56 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 57 #include "chrome/browser/platform_util.h" | 57 #include "chrome/browser/platform_util.h" |
| 58 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 58 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 59 #include "chrome/browser/prefs/pref_service.h" | 59 #include "chrome/browser/prefs/pref_service.h" |
| 60 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 60 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 61 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 61 #include "chrome/browser/profiles/profile.h" | 62 #include "chrome/browser/profiles/profile.h" |
| 62 #include "chrome/browser/sessions/restore_tab_helper.h" | 63 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 63 #include "chrome/browser/sessions/session_service.h" | 64 #include "chrome/browser/sessions/session_service.h" |
| 64 #include "chrome/browser/sessions/session_service_factory.h" | 65 #include "chrome/browser/sessions/session_service_factory.h" |
| 65 #include "chrome/browser/sessions/session_types.h" | 66 #include "chrome/browser/sessions/session_types.h" |
| 66 #include "chrome/browser/sessions/tab_restore_service.h" | 67 #include "chrome/browser/sessions/tab_restore_service.h" |
| 67 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 68 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 68 #include "chrome/browser/sync/profile_sync_service.h" | 69 #include "chrome/browser/sync/profile_sync_service.h" |
| 69 #include "chrome/browser/sync/sync_ui_util.h" | 70 #include "chrome/browser/sync/sync_ui_util.h" |
| 70 #include "chrome/browser/tab_closeable_state_watcher.h" | 71 #include "chrome/browser/tab_closeable_state_watcher.h" |
| (...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 platform_util::OpenExternal(GURL(mailto)); | 1783 platform_util::OpenExternal(GURL(mailto)); |
| 1783 } | 1784 } |
| 1784 | 1785 |
| 1785 void Browser::Print() { | 1786 void Browser::Print() { |
| 1786 if (switches::IsPrintPreviewEnabled()) | 1787 if (switches::IsPrintPreviewEnabled()) |
| 1787 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow(); | 1788 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow(); |
| 1788 else | 1789 else |
| 1789 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow(); | 1790 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow(); |
| 1790 } | 1791 } |
| 1791 | 1792 |
| 1793 void Browser::AdvancedPrint() { |
| 1794 GetSelectedTabContentsWrapper()->print_view_manager()->AdvancedPrintNow(); |
| 1795 } |
| 1796 |
| 1792 void Browser::ToggleEncodingAutoDetect() { | 1797 void Browser::ToggleEncodingAutoDetect() { |
| 1793 UserMetrics::RecordAction(UserMetricsAction("AutoDetectChange")); | 1798 UserMetrics::RecordAction(UserMetricsAction("AutoDetectChange")); |
| 1794 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); | 1799 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); |
| 1795 // If "auto detect" is turned on, then any current override encoding | 1800 // If "auto detect" is turned on, then any current override encoding |
| 1796 // is cleared. This also implicitly performs a reload. | 1801 // is cleared. This also implicitly performs a reload. |
| 1797 // OTOH, if "auto detect" is turned off, we don't change the currently | 1802 // OTOH, if "auto detect" is turned off, we don't change the currently |
| 1798 // active encoding. | 1803 // active encoding. |
| 1799 if (encoding_auto_detect_.GetValue()) { | 1804 if (encoding_auto_detect_.GetValue()) { |
| 1800 TabContents* contents = GetSelectedTabContents(); | 1805 TabContents* contents = GetSelectedTabContents(); |
| 1801 if (contents) | 1806 if (contents) |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2486 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break; | 2491 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break; |
| 2487 #endif | 2492 #endif |
| 2488 | 2493 |
| 2489 // Page-related commands | 2494 // Page-related commands |
| 2490 case IDC_SAVE_PAGE: SavePage(); break; | 2495 case IDC_SAVE_PAGE: SavePage(); break; |
| 2491 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; | 2496 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; |
| 2492 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; | 2497 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; |
| 2493 case IDC_VIEW_SOURCE: ViewSelectedSource(); break; | 2498 case IDC_VIEW_SOURCE: ViewSelectedSource(); break; |
| 2494 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; | 2499 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; |
| 2495 case IDC_PRINT: Print(); break; | 2500 case IDC_PRINT: Print(); break; |
| 2501 case IDC_ADVANCED_PRINT: AdvancedPrint(); break; |
| 2496 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; | 2502 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; |
| 2497 case IDC_ENCODING_UTF8: | 2503 case IDC_ENCODING_UTF8: |
| 2498 case IDC_ENCODING_UTF16LE: | 2504 case IDC_ENCODING_UTF16LE: |
| 2499 case IDC_ENCODING_ISO88591: | 2505 case IDC_ENCODING_ISO88591: |
| 2500 case IDC_ENCODING_WINDOWS1252: | 2506 case IDC_ENCODING_WINDOWS1252: |
| 2501 case IDC_ENCODING_GBK: | 2507 case IDC_ENCODING_GBK: |
| 2502 case IDC_ENCODING_GB18030: | 2508 case IDC_ENCODING_GB18030: |
| 2503 case IDC_ENCODING_BIG5HKSCS: | 2509 case IDC_ENCODING_BIG5HKSCS: |
| 2504 case IDC_ENCODING_BIG5: | 2510 case IDC_ENCODING_BIG5: |
| 2505 case IDC_ENCODING_KOREAN: | 2511 case IDC_ENCODING_KOREAN: |
| (...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4246 command_updater_.UpdateCommandEnabled( | 4252 command_updater_.UpdateCommandEnabled( |
| 4247 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT)); | 4253 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT)); |
| 4248 command_updater_.UpdateCommandEnabled( | 4254 command_updater_.UpdateCommandEnabled( |
| 4249 IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE)); | 4255 IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE)); |
| 4250 UpdateSaveAsState(restrictions); | 4256 UpdateSaveAsState(restrictions); |
| 4251 UpdatePrintingState(restrictions); | 4257 UpdatePrintingState(restrictions); |
| 4252 } | 4258 } |
| 4253 | 4259 |
| 4254 void Browser::UpdatePrintingState(int content_restrictions) { | 4260 void Browser::UpdatePrintingState(int content_restrictions) { |
| 4255 bool enabled = true; | 4261 bool enabled = true; |
| 4262 bool selected_tab_is_preview_tab = false; |
| 4256 if (content_restrictions & CONTENT_RESTRICTION_PRINT) { | 4263 if (content_restrictions & CONTENT_RESTRICTION_PRINT) { |
| 4257 enabled = false; | 4264 enabled = false; |
| 4265 selected_tab_is_preview_tab = |
| 4266 printing::PrintPreviewTabController::IsPrintPreviewTab( |
| 4267 GetSelectedTabContents()); |
| 4258 } else if (g_browser_process->local_state()) { | 4268 } else if (g_browser_process->local_state()) { |
| 4259 enabled = g_browser_process->local_state()-> | 4269 enabled = g_browser_process->local_state()-> |
| 4260 GetBoolean(prefs::kPrintingEnabled); | 4270 GetBoolean(prefs::kPrintingEnabled); |
| 4261 } | 4271 } |
| 4262 command_updater_.UpdateCommandEnabled(IDC_PRINT, enabled); | 4272 command_updater_.UpdateCommandEnabled(IDC_PRINT, enabled); |
| 4273 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, |
| 4274 selected_tab_is_preview_tab ? true : |
| 4275 enabled); |
| 4263 } | 4276 } |
| 4264 | 4277 |
| 4265 void Browser::UpdateReloadStopState(bool is_loading, bool force) { | 4278 void Browser::UpdateReloadStopState(bool is_loading, bool force) { |
| 4266 window_->UpdateReloadStopState(is_loading, force); | 4279 window_->UpdateReloadStopState(is_loading, force); |
| 4267 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); | 4280 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
| 4268 } | 4281 } |
| 4269 | 4282 |
| 4270 void Browser::UpdateCommandsForDevTools() { | 4283 void Browser::UpdateCommandsForDevTools() { |
| 4271 bool dev_tools_enabled = | 4284 bool dev_tools_enabled = |
| 4272 !profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); | 4285 !profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4979 } | 4992 } |
| 4980 | 4993 |
| 4981 void Browser::ShowSyncSetup() { | 4994 void Browser::ShowSyncSetup() { |
| 4982 ProfileSyncService* service = | 4995 ProfileSyncService* service = |
| 4983 profile()->GetOriginalProfile()->GetProfileSyncService(); | 4996 profile()->GetOriginalProfile()->GetProfileSyncService(); |
| 4984 if (service->HasSyncSetupCompleted()) | 4997 if (service->HasSyncSetupCompleted()) |
| 4985 ShowOptionsTab(chrome::kSyncSetupSubPage); | 4998 ShowOptionsTab(chrome::kSyncSetupSubPage); |
| 4986 else | 4999 else |
| 4987 service->ShowLoginDialog(); | 5000 service->ShowLoginDialog(); |
| 4988 } | 5001 } |
| OLD | NEW |