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

Side by Side Diff: chrome/browser/ui/views/toolbar/wrench_menu.cc

Issue 331993009: MacViews: Run native Cocoa context menus to support Services. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add VIEWS_EXPORT for unit test access Created 6 years, 5 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 | Annotate | Revision Log
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/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 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 // so we get the taller menu style. 978 // so we get the taller menu style.
979 PopulateMenu(root_, model); 979 PopulateMenu(root_, model);
980 980
981 #if defined(DEBUG) 981 #if defined(DEBUG)
982 // Verify that the reserved command ID's for bookmarks menu are not used. 982 // Verify that the reserved command ID's for bookmarks menu are not used.
983 for (int i = WrenchMenuModel:kMinBookmarkCommandId; 983 for (int i = WrenchMenuModel:kMinBookmarkCommandId;
984 i <= WrenchMenuModel::kMaxBookmarkCommandId; ++i) 984 i <= WrenchMenuModel::kMaxBookmarkCommandId; ++i)
985 DCHECK(command_id_to_entry_.find(i) == command_id_to_entry_.end()); 985 DCHECK(command_id_to_entry_.find(i) == command_id_to_entry_.end());
986 #endif // defined(DEBUG) 986 #endif // defined(DEBUG)
987 987
988 menu_runner_.reset(new views::MenuRunner(root_)); 988 menu_runner_.reset(
989 new views::MenuRunner(root_, views::MenuRunner::HAS_MNEMONICS));
989 } 990 }
990 991
991 void WrenchMenu::RunMenu(views::MenuButton* host) { 992 void WrenchMenu::RunMenu(views::MenuButton* host) {
992 gfx::Point screen_loc; 993 gfx::Point screen_loc;
993 views::View::ConvertPointToScreen(host, &screen_loc); 994 views::View::ConvertPointToScreen(host, &screen_loc);
994 gfx::Rect bounds(screen_loc, host->size()); 995 gfx::Rect bounds(screen_loc, host->size());
995 content::RecordAction(UserMetricsAction("ShowAppMenu")); 996 content::RecordAction(UserMetricsAction("ShowAppMenu"));
996 if (menu_runner_->RunMenuAt(host->GetWidget(), 997 if (menu_runner_->RunMenuAt(host->GetWidget(),
997 host, 998 host,
998 bounds, 999 bounds,
999 views::MENU_ANCHOR_TOPRIGHT, 1000 views::MENU_ANCHOR_TOPRIGHT,
1000 ui::MENU_SOURCE_NONE, 1001 ui::MENU_SOURCE_NONE) ==
1001 views::MenuRunner::HAS_MNEMONICS) ==
1002 views::MenuRunner::MENU_DELETED) 1002 views::MenuRunner::MENU_DELETED)
1003 return; 1003 return;
1004 if (bookmark_menu_delegate_.get()) { 1004 if (bookmark_menu_delegate_.get()) {
1005 BookmarkModel* model = BookmarkModelFactory::GetForProfile( 1005 BookmarkModel* model = BookmarkModelFactory::GetForProfile(
1006 browser_->profile()); 1006 browser_->profile());
1007 if (model) 1007 if (model)
1008 model->RemoveObserver(this); 1008 model->RemoveObserver(this);
1009 } 1009 }
1010 if (selected_menu_model_) 1010 if (selected_menu_model_)
1011 selected_menu_model_->ActivatedAt(selected_index_); 1011 selected_menu_model_->ActivatedAt(selected_index_);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 0, 1404 0,
1405 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1405 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1406 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); 1406 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU);
1407 } 1407 }
1408 1408
1409 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { 1409 int WrenchMenu::ModelIndexFromCommandId(int command_id) const {
1410 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1410 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1411 DCHECK(ix != command_id_to_entry_.end()); 1411 DCHECK(ix != command_id_to_entry_.end());
1412 return ix->second.second; 1412 return ix->second.second;
1413 } 1413 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698