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

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

Issue 16979002: Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 6 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
« no previous file with comments | « chrome/browser/ui/views/wrench_menu.h ('k') | ui/app_list/views/app_list_item_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/wrench_menu.h" 5 #include "chrome/browser/ui/views/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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 first_bookmark_command_id_ = next_id + 1; 806 first_bookmark_command_id_ = next_id + 1;
807 menu_runner_.reset(new views::MenuRunner(root_)); 807 menu_runner_.reset(new views::MenuRunner(root_));
808 } 808 }
809 809
810 void WrenchMenu::RunMenu(views::MenuButton* host) { 810 void WrenchMenu::RunMenu(views::MenuButton* host) {
811 gfx::Point screen_loc; 811 gfx::Point screen_loc;
812 views::View::ConvertPointToScreen(host, &screen_loc); 812 views::View::ConvertPointToScreen(host, &screen_loc);
813 gfx::Rect bounds(screen_loc, host->size()); 813 gfx::Rect bounds(screen_loc, host->size());
814 content::RecordAction(UserMetricsAction("ShowAppMenu")); 814 content::RecordAction(UserMetricsAction("ShowAppMenu"));
815 if (menu_runner_->RunMenuAt(host->GetWidget(), host, bounds, 815 if (menu_runner_->RunMenuAt(host->GetWidget(), host, bounds,
816 MenuItemView::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS) == 816 MenuItemView::TOPRIGHT, ui::MENU_SOURCE_NONE,
817 views::MenuRunner::HAS_MNEMONICS) ==
817 views::MenuRunner::MENU_DELETED) 818 views::MenuRunner::MENU_DELETED)
818 return; 819 return;
819 if (bookmark_menu_delegate_.get()) { 820 if (bookmark_menu_delegate_.get()) {
820 BookmarkModel* model = BookmarkModelFactory::GetForProfile( 821 BookmarkModel* model = BookmarkModelFactory::GetForProfile(
821 browser_->profile()); 822 browser_->profile());
822 if (model) 823 if (model)
823 model->RemoveObserver(this); 824 model->RemoveObserver(this);
824 } 825 }
825 if (selected_menu_model_) 826 if (selected_menu_model_)
826 selected_menu_model_->ActivatedAt(selected_index_); 827 selected_menu_model_->ActivatedAt(selected_index_);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 if (!is_bookmark_command(menu->GetCommand())) 892 if (!is_bookmark_command(menu->GetCommand()))
892 return ui::DragDropTypes::DRAG_NONE; 893 return ui::DragDropTypes::DRAG_NONE;
893 894
894 int result = bookmark_menu_delegate_->OnPerformDrop(menu, position, event); 895 int result = bookmark_menu_delegate_->OnPerformDrop(menu, position, event);
895 return result; 896 return result;
896 } 897 }
897 898
898 bool WrenchMenu::ShowContextMenu(MenuItemView* source, 899 bool WrenchMenu::ShowContextMenu(MenuItemView* source,
899 int id, 900 int id,
900 const gfx::Point& p, 901 const gfx::Point& p,
901 bool is_mouse_gesture) { 902 ui::MenuSourceType source_type) {
902 return is_bookmark_command(id) ? 903 return is_bookmark_command(id) ?
903 bookmark_menu_delegate_->ShowContextMenu(source, id, p, 904 bookmark_menu_delegate_->ShowContextMenu(source, id, p,
904 is_mouse_gesture) : 905 source_type) :
905 false; 906 false;
906 } 907 }
907 908
908 bool WrenchMenu::CanDrag(MenuItemView* menu) { 909 bool WrenchMenu::CanDrag(MenuItemView* menu) {
909 return is_bookmark_command(menu->GetCommand()) ? 910 return is_bookmark_command(menu->GetCommand()) ?
910 bookmark_menu_delegate_->CanDrag(menu) : false; 911 bookmark_menu_delegate_->CanDrag(menu) : false;
911 } 912 }
912 913
913 void WrenchMenu::WriteDragData(MenuItemView* sender, 914 void WrenchMenu::WriteDragData(MenuItemView* sender,
914 ui::OSExchangeData* data) { 915 ui::OSExchangeData* data) {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 bookmark_menu_delegate_.reset( 1170 bookmark_menu_delegate_.reset(
1170 new BookmarkMenuDelegate(browser_, 1171 new BookmarkMenuDelegate(browser_,
1171 browser_, 1172 browser_,
1172 parent, 1173 parent,
1173 first_bookmark_command_id_)); 1174 first_bookmark_command_id_));
1174 bookmark_menu_delegate_->Init( 1175 bookmark_menu_delegate_->Init(
1175 this, bookmark_menu_, model->bookmark_bar_node(), 0, 1176 this, bookmark_menu_, model->bookmark_bar_node(), 0,
1176 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1177 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1177 bookmark_utils::LAUNCH_WRENCH_MENU); 1178 bookmark_utils::LAUNCH_WRENCH_MENU);
1178 } 1179 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/wrench_menu.h ('k') | ui/app_list/views/app_list_item_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698