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

Side by Side Diff: chrome/browser/ui/views/toolbar/app_menu.cc

Issue 1877373003: Disable zoom-in and zoom-out buttons in toolbar menu for a crashed page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit test Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/toolbar/app_menu.h" 5 #include "chrome/browser/ui/views/toolbar/app_menu.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 } 659 }
660 660
661 void UpdateZoomControls() { 661 void UpdateZoomControls() {
662 WebContents* selected_tab = GetActiveWebContents(); 662 WebContents* selected_tab = GetActiveWebContents();
663 int zoom = 100; 663 int zoom = 100;
664 if (selected_tab) { 664 if (selected_tab) {
665 auto zoom_controller = 665 auto zoom_controller =
666 ui_zoom::ZoomController::FromWebContents(selected_tab); 666 ui_zoom::ZoomController::FromWebContents(selected_tab);
667 if (zoom_controller) 667 if (zoom_controller)
668 zoom = zoom_controller->GetZoomPercent(); 668 zoom = zoom_controller->GetZoomPercent();
669 increment_button_->SetEnabled(zoom < 669 increment_button_->SetEnabled(
670 selected_tab->GetMaximumZoomPercent()); 670 !selected_tab->IsCrashed() &&
671 decrement_button_->SetEnabled(zoom > 671 zoom < selected_tab->GetMaximumZoomPercent());
672 selected_tab->GetMinimumZoomPercent()); 672 decrement_button_->SetEnabled(
673 !selected_tab->IsCrashed() &&
674 zoom > selected_tab->GetMinimumZoomPercent());
Peter Kasting 2016/04/12 23:39:56 It feels wrong that we duplicate this logic both h
Tom (Use chromium acct) 2016/04/14 19:19:36 Done.
673 } 675 }
674 zoom_label_->SetText( 676 zoom_label_->SetText(
675 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom)); 677 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom));
676 678
677 zoom_label_max_width_valid_ = false; 679 zoom_label_max_width_valid_ = false;
678 } 680 }
679 681
680 // Returns the max width the zoom string can be. 682 // Returns the max width the zoom string can be.
681 int ZoomLabelMaxWidth() const { 683 int ZoomLabelMaxWidth() const {
682 if (!zoom_label_max_width_valid_) { 684 if (!zoom_label_max_width_valid_) {
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 0, 1291 0,
1290 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1292 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1291 BOOKMARK_LAUNCH_LOCATION_APP_MENU); 1293 BOOKMARK_LAUNCH_LOCATION_APP_MENU);
1292 } 1294 }
1293 1295
1294 int AppMenu::ModelIndexFromCommandId(int command_id) const { 1296 int AppMenu::ModelIndexFromCommandId(int command_id) const {
1295 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1297 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1296 DCHECK(ix != command_id_to_entry_.end()); 1298 DCHECK(ix != command_id_to_entry_.end());
1297 return ix->second.second; 1299 return ix->second.second;
1298 } 1300 }
OLDNEW
« chrome/browser/ui/browser_commands.cc ('K') | « chrome/browser/ui/browser_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698