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

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: Reverted zoom_controller_unittest.cc 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 WindowOpenDisposition* disposition) { 311 WindowOpenDisposition* disposition) {
312 if (disposition) 312 if (disposition)
313 *disposition = last_blocked_command_disposition_; 313 *disposition = last_blocked_command_disposition_;
314 return last_blocked_command_id_; 314 return last_blocked_command_id_;
315 } 315 }
316 316
317 void BrowserCommandController::TabStateChanged() { 317 void BrowserCommandController::TabStateChanged() {
318 UpdateCommandsForTabState(); 318 UpdateCommandsForTabState();
319 } 319 }
320 320
321 void BrowserCommandController::ZoomStateChanged() {
322 UpdateCommandsForZoomState();
323 }
324
321 void BrowserCommandController::ContentRestrictionsChanged() { 325 void BrowserCommandController::ContentRestrictionsChanged() {
322 UpdateCommandsForContentRestrictionState(); 326 UpdateCommandsForContentRestrictionState();
323 } 327 }
324 328
325 void BrowserCommandController::FullscreenStateChanged() { 329 void BrowserCommandController::FullscreenStateChanged() {
326 UpdateCommandsForFullscreenMode(); 330 UpdateCommandsForFullscreenMode();
327 } 331 }
328 332
329 void BrowserCommandController::PrintingStateChanged() { 333 void BrowserCommandController::PrintingStateChanged() {
330 UpdatePrintingState(); 334 UpdatePrintingState();
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88596, true); 943 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88596, true);
940 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1256, true); 944 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1256, true);
941 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598, true); 945 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598, true);
942 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598I, true); 946 command_updater_.UpdateCommandEnabled(IDC_ENCODING_ISO88598I, true);
943 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1255, true); 947 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1255, true);
944 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1258, true); 948 command_updater_.UpdateCommandEnabled(IDC_ENCODING_WINDOWS1258, true);
945 949
946 // Zoom 950 // Zoom
947 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MENU, true); 951 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MENU, true);
948 command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, true); 952 command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, true);
949 command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, true); 953 command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, false);
950 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, true); 954 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, true);
951 955
952 // Show various bits of UI 956 // Show various bits of UI
953 const bool guest_session = profile()->IsGuestSession(); 957 const bool guest_session = profile()->IsGuestSession();
954 const bool normal_window = browser_->is_type_tabbed(); 958 const bool normal_window = browser_->is_type_tabbed();
955 UpdateOpenFileState(&command_updater_); 959 UpdateOpenFileState(&command_updater_);
956 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, false); 960 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, false);
957 UpdateCommandsForDevTools(); 961 UpdateCommandsForDevTools();
958 command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, CanOpenTaskManager()); 962 command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, CanOpenTaskManager());
959 command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, !guest_session); 963 command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, !guest_session);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 CanCreateBookmarkApp(browser_)); 1123 CanCreateBookmarkApp(browser_));
1120 #endif 1124 #endif
1121 1125
1122 command_updater_.UpdateCommandEnabled( 1126 command_updater_.UpdateCommandEnabled(
1123 IDC_TOGGLE_REQUEST_TABLET_SITE, 1127 IDC_TOGGLE_REQUEST_TABLET_SITE,
1124 CanRequestTabletSite(current_web_contents)); 1128 CanRequestTabletSite(current_web_contents));
1125 1129
1126 UpdateCommandsForContentRestrictionState(); 1130 UpdateCommandsForContentRestrictionState();
1127 UpdateCommandsForBookmarkEditing(); 1131 UpdateCommandsForBookmarkEditing();
1128 UpdateCommandsForFind(); 1132 UpdateCommandsForFind();
1133 // Update the zoom commands when an active tab is selected
Alexei Svitkine (slow) 2014/08/04 16:29:54 Nit: Add a . at the end of the sentence.
1134 UpdateCommandsForZoomState();
1135 }
1136
1137 void BrowserCommandController::UpdateCommandsForZoomState() {
1138 WebContents* contents =
1139 browser_->tab_strip_model()->GetActiveWebContents();
1140 if (!contents)
1141 return;
1142 command_updater_.UpdateCommandEnabled(IDC_ZOOM_PLUS, CanZoomIn(contents));
1143 command_updater_.UpdateCommandEnabled(IDC_ZOOM_NORMAL, ActualSize(contents));
1144 command_updater_.UpdateCommandEnabled(IDC_ZOOM_MINUS, CanZoomOut(contents));
1129 } 1145 }
1130 1146
1131 void BrowserCommandController::UpdateCommandsForContentRestrictionState() { 1147 void BrowserCommandController::UpdateCommandsForContentRestrictionState() {
1132 int restrictions = GetContentRestrictions(browser_); 1148 int restrictions = GetContentRestrictions(browser_);
1133 1149
1134 command_updater_.UpdateCommandEnabled( 1150 command_updater_.UpdateCommandEnabled(
1135 IDC_COPY, !(restrictions & CONTENT_RESTRICTION_COPY)); 1151 IDC_COPY, !(restrictions & CONTENT_RESTRICTION_COPY));
1136 command_updater_.UpdateCommandEnabled( 1152 command_updater_.UpdateCommandEnabled(
1137 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT)); 1153 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT));
1138 command_updater_.UpdateCommandEnabled( 1154 command_updater_.UpdateCommandEnabled(
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 1347
1332 BrowserWindow* BrowserCommandController::window() { 1348 BrowserWindow* BrowserCommandController::window() {
1333 return browser_->window(); 1349 return browser_->window();
1334 } 1350 }
1335 1351
1336 Profile* BrowserCommandController::profile() { 1352 Profile* BrowserCommandController::profile() {
1337 return browser_->profile(); 1353 return browser_->profile();
1338 } 1354 }
1339 1355
1340 } // namespace chrome 1356 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698