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

Side by Side Diff: chrome/browser/views/wrench_menu.cc

Issue 3055006: UpdateZoomControls honors the global enabled state of the zoom commands.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/wrench_menu.h" 5 #include "chrome/browser/views/wrench_menu.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 const NotificationDetails& details) { 449 const NotificationDetails& details) {
450 DCHECK_EQ(NotificationType::ZOOM_LEVEL_CHANGED, type.value); 450 DCHECK_EQ(NotificationType::ZOOM_LEVEL_CHANGED, type.value);
451 UpdateZoomControls(); 451 UpdateZoomControls();
452 } 452 }
453 453
454 private: 454 private:
455 void UpdateZoomControls() { 455 void UpdateZoomControls() {
456 bool enable_increment, enable_decrement; 456 bool enable_increment, enable_decrement;
457 int zoom_percent = 457 int zoom_percent =
458 static_cast<int>(GetZoom(&enable_increment, &enable_decrement)); 458 static_cast<int>(GetZoom(&enable_increment, &enable_decrement));
459 enable_increment = enable_increment &&
460 menu_model_->IsEnabledAt(increment_button_->tag());
461 enable_decrement = enable_decrement &&
462 menu_model_->IsEnabledAt(decrement_button_->tag());
463 increment_button_->SetEnabled(enable_increment);
464 decrement_button_->SetEnabled(enable_decrement);
459 zoom_label_->SetText(l10n_util::GetStringF( 465 zoom_label_->SetText(l10n_util::GetStringF(
460 IDS_ZOOM_PERCENT, IntToWString(zoom_percent))); 466 IDS_ZOOM_PERCENT, IntToWString(zoom_percent)));
461 increment_button_->SetEnabled(enable_increment); 467 // If both increment and decrement are disabled, then we disable the zoom
462 decrement_button_->SetEnabled(enable_decrement); 468 // label too.
469 zoom_label_->SetEnabled(enable_increment || enable_decrement);
463 } 470 }
464 471
465 double GetZoom(bool* enable_increment, bool* enable_decrement) { 472 double GetZoom(bool* enable_increment, bool* enable_decrement) {
466 // TODO: move this somewhere it can be shared. 473 // TODO: move this somewhere it can be shared.
467 TabContents* selected_tab = menu_->browser_->GetSelectedTabContents(); 474 TabContents* selected_tab = menu_->browser_->GetSelectedTabContents();
468 *enable_decrement = *enable_increment = false; 475 *enable_decrement = *enable_increment = false;
469 if (!selected_tab) 476 if (!selected_tab)
470 return 1; 477 return 1;
471 478
472 HostZoomMap* zoom_map = selected_tab->profile()->GetHostZoomMap(); 479 HostZoomMap* zoom_map = selected_tab->profile()->GetHostZoomMap();
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 } 699 }
693 700
694 return menu_item; 701 return menu_item;
695 } 702 }
696 703
697 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { 704 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) {
698 selected_menu_model_ = model; 705 selected_menu_model_ = model;
699 selected_index_ = index; 706 selected_index_ = index;
700 root_->Cancel(); 707 root_->Cancel();
701 } 708 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698