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

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

Issue 310913002: Issue 32919: Update the Zoom NSMenuItems (Zoom-In/Zoom-out/Actual-Size) when the zoom state changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modified zoom_controller_unittests to pass try jobs on bots. Created 6 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
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 WindowOpenDisposition* disposition) { 310 WindowOpenDisposition* disposition) {
311 if (disposition) 311 if (disposition)
312 *disposition = last_blocked_command_disposition_; 312 *disposition = last_blocked_command_disposition_;
313 return last_blocked_command_id_; 313 return last_blocked_command_id_;
314 } 314 }
315 315
316 void BrowserCommandController::TabStateChanged() { 316 void BrowserCommandController::TabStateChanged() {
317 UpdateCommandsForTabState(); 317 UpdateCommandsForTabState();
318 } 318 }
319 319
320 void BrowserCommandController::ZoomStateChanged() {
321 UpdateCommandsForZoomState();
322 }
323
320 void BrowserCommandController::ContentRestrictionsChanged() { 324 void BrowserCommandController::ContentRestrictionsChanged() {
321 UpdateCommandsForContentRestrictionState(); 325 UpdateCommandsForContentRestrictionState();
322 } 326 }
323 327
324 void BrowserCommandController::FullscreenStateChanged() { 328 void BrowserCommandController::FullscreenStateChanged() {
325 UpdateCommandsForFullscreenMode(); 329 UpdateCommandsForFullscreenMode();
326 } 330 }
327 331
328 void BrowserCommandController::PrintingStateChanged() { 332 void BrowserCommandController::PrintingStateChanged() {
329 UpdatePrintingState(); 333 UpdatePrintingState();
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88596, true); 942 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88596, true);
939 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1256, true); 943 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1256, true);
940 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598, true); 944 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598, true);
941 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598I, true); 945 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598I, true);
942 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1255, true); 946 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1255, true);
943 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1258, true); 947 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1258, true);
944 948
945 // Zoom 949 // Zoom
946 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MENU, true); 950 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MENU, true);
947 command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, true); 951 command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, true);
948 command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, true); 952 command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, false);
949 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, true); 953 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, true);
950 954
951 // Show various bits of UI 955 // Show various bits of UI
952 const bool guest_session = profile()->IsGuestSession(); 956 const bool guest_session = profile()->IsGuestSession();
953 const bool normal_window = browser_->is_type_tabbed(); 957 const bool normal_window = browser_->is_type_tabbed();
954 UpdateOpenFileState(&command_updater_); 958 UpdateOpenFileState(&command_updater_);
955 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, false); 959 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, false);
956 UpdateCommandsForDevTools(); 960 UpdateCommandsForDevTools();
957 command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, CanOpenTaskManager()); 961 command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, CanOpenTaskManager());
958 command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, !guest_session); 962 command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, !guest_session);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 CanCreateBookmarkApp(browser_)); 1121 CanCreateBookmarkApp(browser_));
1118 #endif 1122 #endif
1119 1123
1120 command_updater_.UpdateCommandEnabled( 1124 command_updater_.UpdateCommandEnabled(
1121 IDC_TOGGLE_REQUEST_TABLET_SITE, 1125 IDC_TOGGLE_REQUEST_TABLET_SITE,
1122 CanRequestTabletSite(current_web_contents)); 1126 CanRequestTabletSite(current_web_contents));
1123 1127
1124 UpdateCommandsForContentRestrictionState(); 1128 UpdateCommandsForContentRestrictionState();
1125 UpdateCommandsForBookmarkEditing(); 1129 UpdateCommandsForBookmarkEditing();
1126 UpdateCommandsForFind(); 1130 UpdateCommandsForFind();
1131 // Update the zoom commands when an active tab is selected
1132 UpdateCommandsForZoomState();
1133 }
1134
1135 void BrowserCommandController::UpdateCommandsForZoomState() {
1136 WebContents* contents =
1137 browser_->tab_strip_model()->GetActiveWebContents();
1138 if (!contents)
1139 return;
1140 command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, CanZoomIn(contents));
1141 command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, ActualSize(contents));
1142 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, CanZoomOut(contents));
1127 } 1143 }
1128 1144
1129 void BrowserCommandController::UpdateCommandsForContentRestrictionState() { 1145 void BrowserCommandController::UpdateCommandsForContentRestrictionState() {
1130 int restrictions = GetContentRestrictions(browser_); 1146 int restrictions = GetContentRestrictions(browser_);
1131 1147
1132 command_updater_.UpdateCommandEnabled( 1148 command_updater_.UpdateCommandEnabled(
1133 IDC_COPY, !(restrictions & CONTENT_RESTRICTION_COPY)); 1149 IDC_COPY, !(restrictions & CONTENT_RESTRICTION_COPY));
1134 command_updater_.UpdateCommandEnabled( 1150 command_updater_.UpdateCommandEnabled(
1135 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT)); 1151 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT));
1136 command_updater_.UpdateCommandEnabled( 1152 command_updater_.UpdateCommandEnabled(
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 1345
1330 BrowserWindow* BrowserCommandController::window() { 1346 BrowserWindow* BrowserCommandController::window() {
1331 return browser_->window(); 1347 return browser_->window();
1332 } 1348 }
1333 1349
1334 Profile* BrowserCommandController::profile() { 1350 Profile* BrowserCommandController::profile() {
1335 return browser_->profile(); 1351 return browser_->profile();
1336 } 1352 }
1337 1353
1338 } // namespace chrome 1354 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698