| 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/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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #if !defined(OS_WIN) | 34 #if !defined(OS_WIN) |
| 35 // static | 35 // static |
| 36 RenderViewContextMenuViews* RenderViewContextMenuViews::Create( | 36 RenderViewContextMenuViews* RenderViewContextMenuViews::Create( |
| 37 content::WebContents* web_contents, | 37 content::WebContents* web_contents, |
| 38 const content::ContextMenuParams& params) { | 38 const content::ContextMenuParams& params) { |
| 39 return new RenderViewContextMenuViews(web_contents, params); | 39 return new RenderViewContextMenuViews(web_contents, params); |
| 40 } | 40 } |
| 41 #endif // OS_WIN | 41 #endif // OS_WIN |
| 42 | 42 |
| 43 void RenderViewContextMenuViews::RunMenuAt( | 43 void RenderViewContextMenuViews::RunMenuAt(views::Widget* parent, |
| 44 views::Widget* parent, | 44 const gfx::Point& point, |
| 45 const gfx::Point& point, | 45 ui::MenuSourceType type) { |
| 46 content::ContextMenuSourceType type) { | |
| 47 views::MenuItemView::AnchorPosition anchor_position = | 46 views::MenuItemView::AnchorPosition anchor_position = |
| 48 (type == content::CONTEXT_MENU_SOURCE_TOUCH || | 47 (type == ui::MENU_SOURCE_TOUCH || |
| 49 type == content::CONTEXT_MENU_SOURCE_TOUCH_EDIT_MENU) ? | 48 type == ui::MENU_SOURCE_TOUCH_EDIT_MENU) ? |
| 50 views::MenuItemView::BOTTOMCENTER : views::MenuItemView::TOPLEFT; | 49 views::MenuItemView::BOTTOMCENTER : views::MenuItemView::TOPLEFT; |
| 51 | 50 |
| 52 // TODO(varunjain): remove this by consolidating ui::MenuSourceType and | |
| 53 // content::ContextMenuSourceType. | |
| 54 ui::MenuSourceType source_type = ui::MENU_SOURCE_NONE; | |
| 55 switch (type) { | |
| 56 case content::CONTEXT_MENU_SOURCE_MOUSE: | |
| 57 source_type = ui::MENU_SOURCE_MOUSE; | |
| 58 break; | |
| 59 case content::CONTEXT_MENU_SOURCE_KEYBOARD: | |
| 60 source_type = ui::MENU_SOURCE_KEYBOARD; | |
| 61 break; | |
| 62 case content::CONTEXT_MENU_SOURCE_TOUCH: | |
| 63 source_type = ui::MENU_SOURCE_TOUCH; | |
| 64 break; | |
| 65 default: | |
| 66 break; | |
| 67 } | |
| 68 if (menu_runner_->RunMenuAt(parent, NULL, gfx::Rect(point, gfx::Size()), | 51 if (menu_runner_->RunMenuAt(parent, NULL, gfx::Rect(point, gfx::Size()), |
| 69 anchor_position, source_type, views::MenuRunner::HAS_MNEMONICS | | 52 anchor_position, type, views::MenuRunner::HAS_MNEMONICS | |
| 70 views::MenuRunner::CONTEXT_MENU) == | 53 views::MenuRunner::CONTEXT_MENU) == |
| 71 views::MenuRunner::MENU_DELETED) | 54 views::MenuRunner::MENU_DELETED) |
| 72 return; | 55 return; |
| 73 } | 56 } |
| 74 | 57 |
| 75 //////////////////////////////////////////////////////////////////////////////// | 58 //////////////////////////////////////////////////////////////////////////////// |
| 76 // RenderViewContextMenuViews, protected: | 59 // RenderViewContextMenuViews, protected: |
| 77 | 60 |
| 78 void RenderViewContextMenuViews::PlatformInit() { | 61 void RenderViewContextMenuViews::PlatformInit() { |
| 79 menu_runner_.reset(new views::MenuRunner(&menu_model_)); | 62 menu_runner_.reset(new views::MenuRunner(&menu_model_)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 item->SetEnabled(enabled); | 121 item->SetEnabled(enabled); |
| 139 item->SetTitle(title); | 122 item->SetTitle(title); |
| 140 item->SetVisible(!hidden); | 123 item->SetVisible(!hidden); |
| 141 | 124 |
| 142 views::MenuItemView* parent = item->GetParentMenuItem(); | 125 views::MenuItemView* parent = item->GetParentMenuItem(); |
| 143 if (!parent) | 126 if (!parent) |
| 144 return; | 127 return; |
| 145 | 128 |
| 146 parent->ChildrenChanged(); | 129 parent->ChildrenChanged(); |
| 147 } | 130 } |
| OLD | NEW |