Chromium Code Reviews| 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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 | 786 |
| 787 // WrenchMenu ------------------------------------------------------------------ | 787 // WrenchMenu ------------------------------------------------------------------ |
| 788 | 788 |
| 789 WrenchMenu::WrenchMenu(Browser* browser, int run_flags) | 789 WrenchMenu::WrenchMenu(Browser* browser, int run_flags) |
| 790 : root_(NULL), | 790 : root_(NULL), |
| 791 browser_(browser), | 791 browser_(browser), |
| 792 selected_menu_model_(NULL), | 792 selected_menu_model_(NULL), |
| 793 selected_index_(0), | 793 selected_index_(0), |
| 794 bookmark_menu_(NULL), | 794 bookmark_menu_(NULL), |
| 795 feedback_menu_item_(NULL), | 795 feedback_menu_item_(NULL), |
| 796 screenshot_menu_item_(NULL), | |
|
sky
2015/02/04 17:06:01
nullptr
caelyn
2015/02/04 20:30:12
changing all of these to nullptr while I am here.
| |
| 796 run_flags_(run_flags) { | 797 run_flags_(run_flags) { |
| 797 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, | 798 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
| 798 content::Source<Profile>(browser_->profile())); | 799 content::Source<Profile>(browser_->profile())); |
| 799 } | 800 } |
| 800 | 801 |
| 801 WrenchMenu::~WrenchMenu() { | 802 WrenchMenu::~WrenchMenu() { |
| 802 if (bookmark_menu_delegate_.get()) { | 803 if (bookmark_menu_delegate_.get()) { |
| 803 BookmarkModel* model = BookmarkModelFactory::GetForProfile( | 804 BookmarkModel* model = BookmarkModelFactory::GetForProfile( |
| 804 browser_->profile()); | 805 browser_->profile()); |
| 805 if (model) | 806 if (model) |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1046 return true; | 1047 return true; |
| 1047 } | 1048 } |
| 1048 | 1049 |
| 1049 void WrenchMenu::WillShowMenu(MenuItemView* menu) { | 1050 void WrenchMenu::WillShowMenu(MenuItemView* menu) { |
| 1050 if (menu == bookmark_menu_) | 1051 if (menu == bookmark_menu_) |
| 1051 CreateBookmarkMenu(); | 1052 CreateBookmarkMenu(); |
| 1052 } | 1053 } |
| 1053 | 1054 |
| 1054 void WrenchMenu::WillHideMenu(MenuItemView* menu) { | 1055 void WrenchMenu::WillHideMenu(MenuItemView* menu) { |
| 1055 // Turns off the fade out animation of the wrench menus if | 1056 // Turns off the fade out animation of the wrench menus if |
| 1056 // |feedback_menu_item_| is selected. This excludes the wrench menu itself | 1057 // |feedback_menu_item_| or |screenshot_menu_item_| is selected. This |
| 1057 // from the snapshot in the feedback UI. | 1058 // excludes the wrench menu itself from the screenshot. |
| 1058 if (menu->HasSubmenu() && feedback_menu_item_ && | 1059 if (menu->HasSubmenu() && |
| 1059 feedback_menu_item_->IsSelected()) { | 1060 ((feedback_menu_item_ && feedback_menu_item_->IsSelected()) || |
| 1061 (screenshot_menu_item_ && screenshot_menu_item_->IsSelected()))) { | |
| 1060 // It's okay to just turn off the animation and no to take care the | 1062 // It's okay to just turn off the animation and no to take care the |
| 1061 // animation back because the menu widget will be recreated next time | 1063 // animation back because the menu widget will be recreated next time |
| 1062 // it's opened. See ToolbarView::RunMenu() and Init() of this class. | 1064 // it's opened. See ToolbarView::RunMenu() and Init() of this class. |
| 1063 menu->GetSubmenu()->GetWidget()-> | 1065 menu->GetSubmenu()->GetWidget()-> |
| 1064 SetVisibilityChangedAnimationsEnabled(false); | 1066 SetVisibilityChangedAnimationsEnabled(false); |
| 1065 } | 1067 } |
| 1066 } | 1068 } |
| 1067 | 1069 |
| 1068 bool WrenchMenu::ShouldCloseOnDragComplete() { | 1070 bool WrenchMenu::ShouldCloseOnDragComplete() { |
| 1069 return false; | 1071 return false; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1154 bookmark_menu_ = item; | 1156 bookmark_menu_ = item; |
| 1155 break; | 1157 break; |
| 1156 | 1158 |
| 1157 #if defined(GOOGLE_CHROME_BUILD) | 1159 #if defined(GOOGLE_CHROME_BUILD) |
| 1158 case IDC_FEEDBACK: | 1160 case IDC_FEEDBACK: |
| 1159 DCHECK(!feedback_menu_item_); | 1161 DCHECK(!feedback_menu_item_); |
| 1160 feedback_menu_item_ = item; | 1162 feedback_menu_item_ = item; |
| 1161 break; | 1163 break; |
| 1162 #endif | 1164 #endif |
| 1163 | 1165 |
| 1166 #if defined(OS_CHROMEOS) | |
| 1167 case IDC_TAKE_SCREENSHOT: | |
| 1168 DCHECK(!screenshot_menu_item_); | |
| 1169 screenshot_menu_item_ = item; | |
| 1170 break; | |
| 1171 #endif | |
| 1172 | |
| 1164 case IDC_RECENT_TABS_MENU: | 1173 case IDC_RECENT_TABS_MENU: |
| 1165 DCHECK(!recent_tabs_menu_model_delegate_.get()); | 1174 DCHECK(!recent_tabs_menu_model_delegate_.get()); |
| 1166 recent_tabs_menu_model_delegate_.reset( | 1175 recent_tabs_menu_model_delegate_.reset( |
| 1167 new RecentTabsMenuModelDelegate(this, model->GetSubmenuModelAt(i), | 1176 new RecentTabsMenuModelDelegate(this, model->GetSubmenuModelAt(i), |
| 1168 item)); | 1177 item)); |
| 1169 break; | 1178 break; |
| 1170 | 1179 |
| 1171 default: | 1180 default: |
| 1172 break; | 1181 break; |
| 1173 } | 1182 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1246 0, | 1255 0, |
| 1247 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1256 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1248 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1257 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
| 1249 } | 1258 } |
| 1250 | 1259 |
| 1251 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1260 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
| 1252 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1261 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
| 1253 DCHECK(ix != command_id_to_entry_.end()); | 1262 DCHECK(ix != command_id_to_entry_.end()); |
| 1254 return ix->second.second; | 1263 return ix->second.second; |
| 1255 } | 1264 } |
| OLD | NEW |