OLD | NEW |
---|---|
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/utf_string_conversions.h" | 8 #include "base/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 24 matching lines...) Expand all Loading... | |
35 | 35 |
36 #if !defined(OS_WIN) | 36 #if !defined(OS_WIN) |
37 // static | 37 // static |
38 RenderViewContextMenuViews* RenderViewContextMenuViews::Create( | 38 RenderViewContextMenuViews* RenderViewContextMenuViews::Create( |
39 content::WebContents* tab_contents, | 39 content::WebContents* tab_contents, |
40 const content::ContextMenuParams& params) { | 40 const content::ContextMenuParams& params) { |
41 return new RenderViewContextMenuViews(tab_contents, params); | 41 return new RenderViewContextMenuViews(tab_contents, params); |
42 } | 42 } |
43 #endif // OS_WIN | 43 #endif // OS_WIN |
44 | 44 |
45 void RenderViewContextMenuViews::RunMenuAt(views::Widget* parent, | 45 void RenderViewContextMenuViews::RunMenuAt( |
46 const gfx::Point& point) { | 46 views::Widget* parent, |
47 const gfx::Point& point, | |
48 const content::ContextMenuSourceType& type) { | |
49 views::MenuItemView::AnchorPosition anchor_position = | |
50 type == content::CONTEXT_MENU_SOURCE_GESTURE ? | |
51 views::MenuItemView::BOTTOMCENTER : views::MenuItemView::TOPLEFT; | |
sky
2012/09/06 16:35:03
Why do we want BOTTOMCENTER for long press?
varunjain
2012/09/06 16:43:45
request from UX was to display the context menu ce
| |
47 if (menu_runner_->RunMenuAt(parent, NULL, gfx::Rect(point, gfx::Size()), | 52 if (menu_runner_->RunMenuAt(parent, NULL, gfx::Rect(point, gfx::Size()), |
48 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS | | 53 anchor_position, views::MenuRunner::HAS_MNEMONICS | |
49 views::MenuRunner::CONTEXT_MENU) == | 54 views::MenuRunner::CONTEXT_MENU) == |
50 views::MenuRunner::MENU_DELETED) | 55 views::MenuRunner::MENU_DELETED) |
51 return; | 56 return; |
52 } | 57 } |
53 | 58 |
54 void RenderViewContextMenuViews::UpdateMenuItemStates() { | 59 void RenderViewContextMenuViews::UpdateMenuItemStates() { |
55 menu_delegate_->BuildMenu(menu_); | 60 menu_delegate_->BuildMenu(menu_); |
56 } | 61 } |
57 | 62 |
58 //////////////////////////////////////////////////////////////////////////////// | 63 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 item->SetEnabled(enabled); | 128 item->SetEnabled(enabled); |
124 item->SetTitle(title); | 129 item->SetTitle(title); |
125 item->SetVisible(!hidden); | 130 item->SetVisible(!hidden); |
126 | 131 |
127 views::MenuItemView* parent = item->GetParentMenuItem(); | 132 views::MenuItemView* parent = item->GetParentMenuItem(); |
128 if (!parent) | 133 if (!parent) |
129 return; | 134 return; |
130 | 135 |
131 parent->ChildrenChanged(); | 136 parent->ChildrenChanged(); |
132 } | 137 } |
OLD | NEW |