| 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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || | 995 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || |
| 995 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) | 996 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) |
| 996 return true; | 997 return true; |
| 997 | 998 |
| 998 const Entry& entry = command_id_to_entry_.find(command_id)->second; | 999 const Entry& entry = command_id_to_entry_.find(command_id)->second; |
| 999 return entry.first->IsEnabledAt(entry.second); | 1000 return entry.first->IsEnabledAt(entry.second); |
| 1000 } | 1001 } |
| 1001 | 1002 |
| 1002 void WrenchMenu::ExecuteCommand(int command_id, int mouse_event_flags) { | 1003 void WrenchMenu::ExecuteCommand(int command_id, int mouse_event_flags) { |
| 1003 if (IsBookmarkCommand(command_id)) { | 1004 if (IsBookmarkCommand(command_id)) { |
| 1005 UMA_HISTOGRAM_TIMES("WrenchMenu.TimeToAction.BookmarkOpen", |
| 1006 menu_opened_timer_.Elapsed()); |
| 1007 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.MenuAction", |
| 1008 MENU_ACTION_BOOKMARK_OPEN, LIMIT_MENU_ACTION); |
| 1004 bookmark_menu_delegate_->ExecuteCommand(command_id, mouse_event_flags); | 1009 bookmark_menu_delegate_->ExecuteCommand(command_id, mouse_event_flags); |
| 1005 return; | 1010 return; |
| 1006 } | 1011 } |
| 1007 | 1012 |
| 1008 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || | 1013 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || |
| 1009 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) { | 1014 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) { |
| 1010 // These items are represented by child views. If ExecuteCommand is invoked | 1015 // These items are represented by child views. If ExecuteCommand is invoked |
| 1011 // it means the user clicked on the area around the buttons and we should | 1016 // it means the user clicked on the area around the buttons and we should |
| 1012 // not do anyting. | 1017 // not do anyting. |
| 1013 return; | 1018 return; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 0, | 1244 0, |
| 1240 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1245 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1241 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1246 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
| 1242 } | 1247 } |
| 1243 | 1248 |
| 1244 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1249 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
| 1245 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1250 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
| 1246 DCHECK(ix != command_id_to_entry_.end()); | 1251 DCHECK(ix != command_id_to_entry_.end()); |
| 1247 return ix->second.second; | 1252 return ix->second.second; |
| 1248 } | 1253 } |
| OLD | NEW |