| 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 |
| 11 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_stats.h" | 16 #include "chrome/browser/bookmarks/bookmark_stats.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/search/search.h" | 19 #include "chrome/browser/search/search.h" |
| 19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || | 996 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || |
| 996 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) | 997 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) |
| 997 return true; | 998 return true; |
| 998 | 999 |
| 999 const Entry& entry = command_id_to_entry_.find(command_id)->second; | 1000 const Entry& entry = command_id_to_entry_.find(command_id)->second; |
| 1000 return entry.first->IsEnabledAt(entry.second); | 1001 return entry.first->IsEnabledAt(entry.second); |
| 1001 } | 1002 } |
| 1002 | 1003 |
| 1003 void WrenchMenu::ExecuteCommand(int command_id, int mouse_event_flags) { | 1004 void WrenchMenu::ExecuteCommand(int command_id, int mouse_event_flags) { |
| 1004 if (IsBookmarkCommand(command_id)) { | 1005 if (IsBookmarkCommand(command_id)) { |
| 1006 UMA_HISTOGRAM_TIMES("WrenchMenu.TimeToAction.BookmarkOpen", |
| 1007 menu_opened_timer_.Elapsed()); |
| 1008 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.MenuAction", |
| 1009 MENU_ACTION_BOOKMARK_OPEN, LIMIT_MENU_ACTION); |
| 1005 bookmark_menu_delegate_->ExecuteCommand(command_id, mouse_event_flags); | 1010 bookmark_menu_delegate_->ExecuteCommand(command_id, mouse_event_flags); |
| 1006 return; | 1011 return; |
| 1007 } | 1012 } |
| 1008 | 1013 |
| 1009 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || | 1014 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || |
| 1010 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) { | 1015 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) { |
| 1011 // These items are represented by child views. If ExecuteCommand is invoked | 1016 // These items are represented by child views. If ExecuteCommand is invoked |
| 1012 // it means the user clicked on the area around the buttons and we should | 1017 // it means the user clicked on the area around the buttons and we should |
| 1013 // not do anyting. | 1018 // not do anyting. |
| 1014 return; | 1019 return; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 0, | 1245 0, |
| 1241 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1246 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1242 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1247 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
| 1243 } | 1248 } |
| 1244 | 1249 |
| 1245 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1250 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
| 1246 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1251 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
| 1247 DCHECK(ix != command_id_to_entry_.end()); | 1252 DCHECK(ix != command_id_to_entry_.end()); |
| 1248 return ix->second.second; | 1253 return ix->second.second; |
| 1249 } | 1254 } |
| OLD | NEW |