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

Side by Side Diff: chrome/browser/ui/views/tab_contents/render_view_context_menu_views.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
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/tab_contents/render_view_context_menu_views.h" 5 #include "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "content/public/browser/render_widget_host_view.h" 10 #include "content/public/browser/render_widget_host_view.h"
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 #endif // OS_WIN 41 #endif // OS_WIN
42 42
43 void RenderViewContextMenuViews::RunMenuAt( 43 void RenderViewContextMenuViews::RunMenuAt(
44 views::Widget* parent, 44 views::Widget* parent,
45 const gfx::Point& point, 45 const gfx::Point& point,
46 content::ContextMenuSourceType type) { 46 content::ContextMenuSourceType type) {
47 views::MenuItemView::AnchorPosition anchor_position = 47 views::MenuItemView::AnchorPosition anchor_position =
48 type == content::CONTEXT_MENU_SOURCE_TOUCH ? 48 type == content::CONTEXT_MENU_SOURCE_TOUCH ?
49 views::MenuItemView::BOTTOMCENTER : views::MenuItemView::TOPLEFT; 49 views::MenuItemView::BOTTOMCENTER : views::MenuItemView::TOPLEFT;
50
51 // TODO(varunjain): remove this by consolidating ui::MenuSourceType and
52 // content::ContextMenuSourceType.
53 ui::MenuSourceType source_type = ui::MENU_SOURCE_NONE;
54 switch (type) {
55 case content::CONTEXT_MENU_SOURCE_MOUSE:
56 source_type = ui::MENU_SOURCE_MOUSE;
57 break;
58 case content::CONTEXT_MENU_SOURCE_KEYBOARD:
59 source_type = ui::MENU_SOURCE_KEYBOARD;
60 break;
61 case content::CONTEXT_MENU_SOURCE_TOUCH:
62 source_type = ui::MENU_SOURCE_TOUCH;
63 break;
64 default:
65 break;
66 }
50 if (menu_runner_->RunMenuAt(parent, NULL, gfx::Rect(point, gfx::Size()), 67 if (menu_runner_->RunMenuAt(parent, NULL, gfx::Rect(point, gfx::Size()),
51 anchor_position, views::MenuRunner::HAS_MNEMONICS | 68 anchor_position, source_type, views::MenuRunner::HAS_MNEMONICS |
52 views::MenuRunner::CONTEXT_MENU) == 69 views::MenuRunner::CONTEXT_MENU) ==
53 views::MenuRunner::MENU_DELETED) 70 views::MenuRunner::MENU_DELETED)
54 return; 71 return;
55 } 72 }
56 73
57 //////////////////////////////////////////////////////////////////////////////// 74 ////////////////////////////////////////////////////////////////////////////////
58 // RenderViewContextMenuViews, protected: 75 // RenderViewContextMenuViews, protected:
59 76
60 void RenderViewContextMenuViews::PlatformInit() { 77 void RenderViewContextMenuViews::PlatformInit() {
61 menu_runner_.reset(new views::MenuRunner(&menu_model_)); 78 menu_runner_.reset(new views::MenuRunner(&menu_model_));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 item->SetEnabled(enabled); 137 item->SetEnabled(enabled);
121 item->SetTitle(title); 138 item->SetTitle(title);
122 item->SetVisible(!hidden); 139 item->SetVisible(!hidden);
123 140
124 views::MenuItemView* parent = item->GetParentMenuItem(); 141 views::MenuItemView* parent = item->GetParentMenuItem();
125 if (!parent) 142 if (!parent)
126 return; 143 return;
127 144
128 parent->ChildrenChanged(); 145 parent->ChildrenChanged();
129 } 146 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/status_icons/status_icon_win.cc ('k') | chrome/browser/ui/views/tabs/browser_tab_strip_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698