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

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: Rebase Created 4 years, 6 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
« no previous file with comments | « chrome/browser/ui/browser_unittest.cc ('k') | 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 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>
11 #include <set> 11 #include <set>
12 12
13 #include "base/i18n/number_formatting.h" 13 #include "base/i18n/number_formatting.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/app/chrome_command_ids.h" 18 #include "chrome/app/chrome_command_ids.h"
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
20 #include "chrome/browser/bookmarks/bookmark_stats.h" 20 #include "chrome/browser/bookmarks/bookmark_stats.h"
21 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/search/search.h" 23 #include "chrome/browser/search/search.h"
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_commands.h"
25 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "chrome/browser/ui/toolbar/app_menu_model.h" 28 #include "chrome/browser/ui/toolbar/app_menu_model.h"
28 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" 29 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h"
29 #include "chrome/browser/ui/views/toolbar/app_menu_observer.h" 30 #include "chrome/browser/ui/views/toolbar/app_menu_observer.h"
30 #include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h" 31 #include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h"
31 #include "chrome/grit/generated_resources.h" 32 #include "chrome/grit/generated_resources.h"
32 #include "components/bookmarks/browser/bookmark_model.h" 33 #include "components/bookmarks/browser/bookmark_model.h"
33 #include "components/ui/zoom/page_zoom.h" 34 #include "components/ui/zoom/page_zoom.h"
34 #include "components/ui/zoom/zoom_controller.h" 35 #include "components/ui/zoom/zoom_controller.h"
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 return menu() ? 624 return menu() ?
624 menu()->browser_->tab_strip_model()->GetActiveWebContents() : 625 menu()->browser_->tab_strip_model()->GetActiveWebContents() :
625 nullptr; 626 nullptr;
626 } 627 }
627 628
628 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change) { 629 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change) {
629 UpdateZoomControls(); 630 UpdateZoomControls();
630 } 631 }
631 632
632 void UpdateZoomControls() { 633 void UpdateZoomControls() {
633 WebContents* selected_tab = GetActiveWebContents(); 634 WebContents* contents = GetActiveWebContents();
634 int zoom = 100; 635 int zoom = 100;
635 if (selected_tab) { 636 if (contents) {
636 auto zoom_controller = 637 auto zoom_controller =
637 ui_zoom::ZoomController::FromWebContents(selected_tab); 638 ui_zoom::ZoomController::FromWebContents(contents);
638 if (zoom_controller) 639 if (zoom_controller)
639 zoom = zoom_controller->GetZoomPercent(); 640 zoom = zoom_controller->GetZoomPercent();
640 increment_button_->SetEnabled(zoom < 641 increment_button_->SetEnabled(zoom <
641 selected_tab->GetMaximumZoomPercent()); 642 contents->GetMaximumZoomPercent());
642 decrement_button_->SetEnabled(zoom > 643 decrement_button_->SetEnabled(zoom >
643 selected_tab->GetMinimumZoomPercent()); 644 contents->GetMinimumZoomPercent());
644 } 645 }
645 zoom_label_->SetText(base::FormatPercent(zoom)); 646 zoom_label_->SetText(base::FormatPercent(zoom));
646 zoom_label_max_width_valid_ = false; 647 zoom_label_max_width_valid_ = false;
647 } 648 }
648 649
649 // Returns the max width the zoom string can be. 650 // Returns the max width the zoom string can be.
650 int ZoomLabelMaxWidth() const { 651 int ZoomLabelMaxWidth() const {
651 if (!zoom_label_max_width_valid_) { 652 if (!zoom_label_max_width_valid_) {
652 const gfx::FontList& font_list = zoom_label_->font_list(); 653 const gfx::FontList& font_list = zoom_label_->font_list();
653 int border_width = zoom_label_->border() 654 int border_width = zoom_label_->border()
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 0, 1257 0,
1257 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1258 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1258 BOOKMARK_LAUNCH_LOCATION_APP_MENU); 1259 BOOKMARK_LAUNCH_LOCATION_APP_MENU);
1259 } 1260 }
1260 1261
1261 int AppMenu::ModelIndexFromCommandId(int command_id) const { 1262 int AppMenu::ModelIndexFromCommandId(int command_id) const {
1262 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1263 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1263 DCHECK(ix != command_id_to_entry_.end()); 1264 DCHECK(ix != command_id_to_entry_.end());
1264 return ix->second.second; 1265 return ix->second.second;
1265 } 1266 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698