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

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

Issue 2254273003: Remove text encoding UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_command_controller.h" 5 #include "chrome/browser/ui/browser_command_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 namespace { 87 namespace {
88 88
89 enum WindowState { 89 enum WindowState {
90 // Not in fullscreen mode. 90 // Not in fullscreen mode.
91 WINDOW_STATE_NOT_FULLSCREEN, 91 WINDOW_STATE_NOT_FULLSCREEN,
92 92
93 // Fullscreen mode, occupying the whole screen. 93 // Fullscreen mode, occupying the whole screen.
94 WINDOW_STATE_FULLSCREEN, 94 WINDOW_STATE_FULLSCREEN,
95 }; 95 };
96 96
97 // Returns |true| if entry has an internal chrome:// URL, |false| otherwise.
98 bool HasInternalURL(const NavigationEntry* entry) {
99 if (!entry)
100 return false;
101
102 // Check the |virtual_url()| first. This catches regular chrome:// URLs
103 // including URLs that were rewritten (such as chrome://bookmarks).
104 if (entry->GetVirtualURL().SchemeIs(content::kChromeUIScheme))
105 return true;
106
107 // If the |virtual_url()| isn't a chrome:// URL, check if it's actually
108 // view-source: of a chrome:// URL.
109 if (entry->GetVirtualURL().SchemeIs(content::kViewSourceScheme))
110 return entry->GetURL().SchemeIs(content::kChromeUIScheme);
111
112 return false;
113 }
114
115 } // namespace 97 } // namespace
116 98
117 namespace chrome { 99 namespace chrome {
118 100
119 /////////////////////////////////////////////////////////////////////////////// 101 ///////////////////////////////////////////////////////////////////////////////
120 // BrowserCommandController, public: 102 // BrowserCommandController, public:
121 103
122 BrowserCommandController::BrowserCommandController(Browser* browser) 104 BrowserCommandController::BrowserCommandController(Browser* browser)
123 : browser_(browser), 105 : browser_(browser),
124 command_updater_(this), 106 command_updater_(this),
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 case IDC_SAVE_CREDIT_CARD_FOR_PAGE: 449 case IDC_SAVE_CREDIT_CARD_FOR_PAGE:
468 SaveCreditCard(browser_); 450 SaveCreditCard(browser_);
469 break; 451 break;
470 case IDC_TRANSLATE_PAGE: 452 case IDC_TRANSLATE_PAGE:
471 Translate(browser_); 453 Translate(browser_);
472 break; 454 break;
473 case IDC_MANAGE_PASSWORDS_FOR_PAGE: 455 case IDC_MANAGE_PASSWORDS_FOR_PAGE:
474 ManagePasswordsForPage(browser_); 456 ManagePasswordsForPage(browser_);
475 break; 457 break;
476 458
477 // Page encoding commands
478 case IDC_ENCODING_AUTO_DETECT:
479 browser_->ToggleEncodingAutoDetect();
480 break;
481 case IDC_ENCODING_UTF8:
482 case IDC_ENCODING_UTF16LE:
483 case IDC_ENCODING_WINDOWS1252:
484 case IDC_ENCODING_GBK:
485 case IDC_ENCODING_GB18030:
486 case IDC_ENCODING_BIG5:
487 case IDC_ENCODING_KOREAN:
488 case IDC_ENCODING_SHIFTJIS:
489 case IDC_ENCODING_ISO2022JP:
490 case IDC_ENCODING_EUCJP:
491 case IDC_ENCODING_THAI:
492 case IDC_ENCODING_ISO885915:
493 case IDC_ENCODING_MACINTOSH:
494 case IDC_ENCODING_ISO88592:
495 case IDC_ENCODING_WINDOWS1250:
496 case IDC_ENCODING_ISO88595:
497 case IDC_ENCODING_WINDOWS1251:
498 case IDC_ENCODING_KOI8R:
499 case IDC_ENCODING_KOI8U:
500 case IDC_ENCODING_IBM866:
501 case IDC_ENCODING_ISO88597:
502 case IDC_ENCODING_WINDOWS1253:
503 case IDC_ENCODING_ISO88594:
504 case IDC_ENCODING_ISO885913:
505 case IDC_ENCODING_WINDOWS1257:
506 case IDC_ENCODING_ISO88593:
507 case IDC_ENCODING_ISO885910:
508 case IDC_ENCODING_ISO885914:
509 case IDC_ENCODING_ISO885916:
510 case IDC_ENCODING_WINDOWS1254:
511 case IDC_ENCODING_ISO88596:
512 case IDC_ENCODING_WINDOWS1256:
513 case IDC_ENCODING_ISO88598:
514 case IDC_ENCODING_ISO88598I:
515 case IDC_ENCODING_WINDOWS1255:
516 case IDC_ENCODING_WINDOWS1258:
517 browser_->OverrideEncoding(id);
518 break;
519
520 // Clipboard commands 459 // Clipboard commands
521 case IDC_CUT: 460 case IDC_CUT:
522 case IDC_COPY: 461 case IDC_COPY:
523 case IDC_PASTE: 462 case IDC_PASTE:
524 CutCopyPaste(browser_, id); 463 CutCopyPaste(browser_, id);
525 break; 464 break;
526 465
527 // Find-in-page 466 // Find-in-page
528 case IDC_FIND: 467 case IDC_FIND:
529 Find(browser_); 468 Find(browser_);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 command_updater_.UpdateCommandEnabled(IDC_VISIT_DESKTOP_OF_LRU_USER_2, true); 751 command_updater_.UpdateCommandEnabled(IDC_VISIT_DESKTOP_OF_LRU_USER_2, true);
813 command_updater_.UpdateCommandEnabled(IDC_VISIT_DESKTOP_OF_LRU_USER_3, true); 752 command_updater_.UpdateCommandEnabled(IDC_VISIT_DESKTOP_OF_LRU_USER_3, true);
814 #endif 753 #endif
815 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 754 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
816 command_updater_.UpdateCommandEnabled(IDC_USE_SYSTEM_TITLE_BAR, true); 755 command_updater_.UpdateCommandEnabled(IDC_USE_SYSTEM_TITLE_BAR, true);
817 #endif 756 #endif
818 757
819 // Page-related commands 758 // Page-related commands
820 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, true); 759 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, true);
821 command_updater_.UpdateCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE, true); 760 command_updater_.UpdateCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE, true);
822 command_updater_.UpdateCommandEnabled(IDC_ENCODING_AUTO_DETECT, true);
823 command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF8, true);
824 command_updater_.UpdateCommandEnabled(IDC_ENCODING_UTF16LE, true);
825 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1252, true);
826 command_updater_.UpdateCommandEnabled(IDC_ENCODING_GBK, true);
827 command_updater_.UpdateCommandEnabled(IDC_ENCODING_GB18030, true);
828 command_updater_.UpdateCommandEnabled(IDC_ENCODING_BIG5, true);
829 command_updater_.UpdateCommandEnabled(IDC_ENCODING_THAI, true);
830 command_updater_.UpdateCommandEnabled(IDC_ENCODING_KOREAN, true);
831 command_updater_.UpdateCommandEnabled(IDC_ENCODING_SHIFTJIS, true);
832 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO2022JP, true);
833 command_updater_.UpdateCommandEnabled(IDC_ENCODING_EUCJP, true);
834 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885915, true);
835 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MACINTOSH, true);
836 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88592, true);
837 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1250, true);
838 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88595, true);
839 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1251, true);
840 command_updater_.UpdateCommandEnabled(IDC_ENCODING_KOI8R, true);
841 command_updater_.UpdateCommandEnabled(IDC_ENCODING_KOI8U, true);
842 command_updater_.UpdateCommandEnabled(IDC_ENCODING_IBM866, true);
843 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88597, true);
844 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1253, true);
845 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88594, true);
846 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885913, true);
847 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1257, true);
848 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88593, true);
849 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885910, true);
850 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885914, true);
851 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO885916, true);
852 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1254, true);
853 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88596, true);
854 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1256, true);
855 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598, true);
856 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598I, true);
857 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1255, true);
858 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1258, true);
859 761
860 // Zoom 762 // Zoom
861 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MENU, true); 763 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MENU, true);
862 command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, true); 764 command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, true);
863 command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, false); 765 command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, false);
864 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, true); 766 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, true);
865 767
866 // Show various bits of UI 768 // Show various bits of UI
867 const bool guest_session = profile()->IsGuestSession() || 769 const bool guest_session = profile()->IsGuestSession() ||
868 profile()->IsSystemProfile(); 770 profile()->IsSystemProfile();
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 window()->SetStarredState( 909 window()->SetStarredState(
1008 BookmarkTabHelper::FromWebContents(current_web_contents)->is_starred()); 910 BookmarkTabHelper::FromWebContents(current_web_contents)->is_starred());
1009 window()->ZoomChangedForActiveTab(false); 911 window()->ZoomChangedForActiveTab(false);
1010 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, 912 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE,
1011 CanViewSource(browser_)); 913 CanViewSource(browser_));
1012 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, 914 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION,
1013 CanEmailPageLocation(browser_)); 915 CanEmailPageLocation(browser_));
1014 if (browser_->is_devtools()) 916 if (browser_->is_devtools())
1015 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false); 917 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false);
1016 918
1017 // Changing the encoding is not possible on Chrome-internal webpages.
1018 NavigationController& nc = current_web_contents->GetController();
1019 bool is_chrome_internal = HasInternalURL(nc.GetLastCommittedEntry()) ||
1020 current_web_contents->ShowingInterstitialPage();
1021 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU,
1022 !is_chrome_internal && current_web_contents->IsSavable());
1023
1024 // Show various bits of UI 919 // Show various bits of UI
1025 // TODO(pinkerton): Disable app-mode in the model until we implement it 920 // TODO(pinkerton): Disable app-mode in the model until we implement it
1026 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148 921 // on the Mac. Be sure to remove both ifdefs. http://crbug.com/13148
1027 #if !defined(OS_MACOSX) 922 #if !defined(OS_MACOSX)
1028 command_updater_.UpdateCommandEnabled( 923 command_updater_.UpdateCommandEnabled(
1029 IDC_CREATE_SHORTCUTS, 924 IDC_CREATE_SHORTCUTS,
1030 CanCreateApplicationShortcuts(browser_)); 925 CanCreateApplicationShortcuts(browser_));
1031 #endif 926 #endif
1032 command_updater_.UpdateCommandEnabled(IDC_CREATE_HOSTED_APP, 927 command_updater_.UpdateCommandEnabled(IDC_CREATE_HOSTED_APP,
1033 CanCreateBookmarkApp(browser_)); 928 CanCreateBookmarkApp(browser_));
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 1159
1265 BrowserWindow* BrowserCommandController::window() { 1160 BrowserWindow* BrowserCommandController::window() {
1266 return browser_->window(); 1161 return browser_->window();
1267 } 1162 }
1268 1163
1269 Profile* BrowserCommandController::profile() { 1164 Profile* BrowserCommandController::profile() {
1270 return browser_->profile(); 1165 return browser_->profile();
1271 } 1166 }
1272 1167
1273 } // namespace chrome 1168 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_browsertest.cc ('k') | chrome/browser/ui/cocoa/app_menu/app_menu_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698