| OLD | NEW | 
|---|
| 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/wrench_menu.h" | 5 #include "chrome/browser/ui/views/toolbar/wrench_menu.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <cmath> | 8 #include <cmath> | 
| 9 #include <set> | 9 #include <set> | 
| 10 | 10 | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 54 #include "ui/views/controls/label.h" | 54 #include "ui/views/controls/label.h" | 
| 55 #include "ui/views/controls/menu/menu_config.h" | 55 #include "ui/views/controls/menu/menu_config.h" | 
| 56 #include "ui/views/controls/menu/menu_item_view.h" | 56 #include "ui/views/controls/menu/menu_item_view.h" | 
| 57 #include "ui/views/controls/menu/menu_model_adapter.h" | 57 #include "ui/views/controls/menu/menu_model_adapter.h" | 
| 58 #include "ui/views/controls/menu/menu_runner.h" | 58 #include "ui/views/controls/menu/menu_runner.h" | 
| 59 #include "ui/views/controls/menu/menu_scroll_view_container.h" | 59 #include "ui/views/controls/menu/menu_scroll_view_container.h" | 
| 60 #include "ui/views/controls/menu/submenu_view.h" | 60 #include "ui/views/controls/menu/submenu_view.h" | 
| 61 #include "ui/views/widget/widget.h" | 61 #include "ui/views/widget/widget.h" | 
| 62 | 62 | 
| 63 using base::UserMetricsAction; | 63 using base::UserMetricsAction; | 
| 64 using content::HostZoomMap; |  | 
| 65 using content::WebContents; | 64 using content::WebContents; | 
| 66 using ui::MenuModel; | 65 using ui::MenuModel; | 
| 67 using views::CustomButton; | 66 using views::CustomButton; | 
| 68 using views::ImageButton; | 67 using views::ImageButton; | 
| 69 using views::Label; | 68 using views::Label; | 
| 70 using views::LabelButton; | 69 using views::LabelButton; | 
| 71 using views::MenuConfig; | 70 using views::MenuConfig; | 
| 72 using views::MenuItemView; | 71 using views::MenuItemView; | 
| 73 using views::View; | 72 using views::View; | 
| 74 | 73 | 
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 487            int decrement_index, | 486            int decrement_index, | 
| 488            int increment_index, | 487            int increment_index, | 
| 489            int fullscreen_index) | 488            int fullscreen_index) | 
| 490       : WrenchMenuView(menu, menu_model), | 489       : WrenchMenuView(menu, menu_model), | 
| 491         fullscreen_index_(fullscreen_index), | 490         fullscreen_index_(fullscreen_index), | 
| 492         increment_button_(NULL), | 491         increment_button_(NULL), | 
| 493         zoom_label_(NULL), | 492         zoom_label_(NULL), | 
| 494         decrement_button_(NULL), | 493         decrement_button_(NULL), | 
| 495         fullscreen_button_(NULL), | 494         fullscreen_button_(NULL), | 
| 496         zoom_label_width_(0) { | 495         zoom_label_width_(0) { | 
| 497     content_zoom_subscription_ = HostZoomMap::GetDefaultForBrowserContext( | 496     content_zoom_subscription_ = | 
| 498         menu->browser_->profile())->AddZoomLevelChangedCallback( | 497         content::HostZoomMap::GetDefaultForBrowserContext( | 
| 499             base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged, | 498             menu->browser_->profile()) | 
| 500                        base::Unretained(this))); | 499             ->AddZoomLevelChangedCallback( | 
|  | 500                 base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged, | 
|  | 501                            base::Unretained(this))); | 
| 501 | 502 | 
| 502     browser_zoom_subscription_ = ZoomEventManager::GetForBrowserContext( | 503     browser_zoom_subscription_ = ZoomEventManager::GetForBrowserContext( | 
| 503         menu->browser_->profile())->AddZoomLevelChangedCallback( | 504         menu->browser_->profile())->AddZoomLevelChangedCallback( | 
| 504             base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged, | 505             base::Bind(&WrenchMenu::ZoomView::OnZoomLevelChanged, | 
| 505                        base::Unretained(this))); | 506                        base::Unretained(this))); | 
| 506 | 507 | 
| 507     decrement_button_ = CreateButtonWithAccName( | 508     decrement_button_ = CreateButtonWithAccName( | 
| 508         IDS_ZOOM_MINUS2, InMenuButtonBackground::LEFT_BUTTON, | 509         IDS_ZOOM_MINUS2, InMenuButtonBackground::LEFT_BUTTON, | 
| 509         decrement_index, IDS_ACCNAME_ZOOM_MINUS2); | 510         decrement_index, IDS_ACCNAME_ZOOM_MINUS2); | 
| 510 | 511 | 
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 627     } else { | 628     } else { | 
| 628       // Zoom buttons don't close the menu. | 629       // Zoom buttons don't close the menu. | 
| 629       menu_model()->ActivatedAt(sender->tag()); | 630       menu_model()->ActivatedAt(sender->tag()); | 
| 630     } | 631     } | 
| 631   } | 632   } | 
| 632 | 633 | 
| 633   // Overridden from WrenchMenuObserver. | 634   // Overridden from WrenchMenuObserver. | 
| 634   void WrenchMenuDestroyed() override { WrenchMenuView::WrenchMenuDestroyed(); } | 635   void WrenchMenuDestroyed() override { WrenchMenuView::WrenchMenuDestroyed(); } | 
| 635 | 636 | 
| 636  private: | 637  private: | 
| 637   void OnZoomLevelChanged(const HostZoomMap::ZoomLevelChange& change) { | 638   void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change) { | 
| 638     UpdateZoomControls(); | 639     UpdateZoomControls(); | 
| 639   } | 640   } | 
| 640 | 641 | 
| 641   void UpdateZoomControls() { | 642   void UpdateZoomControls() { | 
| 642     WebContents* selected_tab = | 643     WebContents* selected_tab = | 
| 643         menu()->browser_->tab_strip_model()->GetActiveWebContents(); | 644         menu()->browser_->tab_strip_model()->GetActiveWebContents(); | 
| 644     int zoom = 100; | 645     int zoom = 100; | 
| 645     if (selected_tab) | 646     if (selected_tab) | 
| 646       zoom = ZoomController::FromWebContents(selected_tab)->GetZoomPercent(); | 647       zoom = ZoomController::FromWebContents(selected_tab)->GetZoomPercent(); | 
| 647     increment_button_->SetEnabled(zoom < selected_tab->GetMaximumZoomPercent()); | 648     increment_button_->SetEnabled(zoom < selected_tab->GetMaximumZoomPercent()); | 
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1239                                 0, | 1240                                 0, | 
| 1240                                 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1241                                 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 
| 1241                                 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1242                                 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 
| 1242 } | 1243 } | 
| 1243 | 1244 | 
| 1244 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1245 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 
| 1245   CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1246   CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 
| 1246   DCHECK(ix != command_id_to_entry_.end()); | 1247   DCHECK(ix != command_id_to_entry_.end()); | 
| 1247   return ix->second.second; | 1248   return ix->second.second; | 
| 1248 } | 1249 } | 
| OLD | NEW | 
|---|