OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/renderer_context_menu/views/toolkit_delegate_views.h" | 5 #include "components/renderer_context_menu/views/toolkit_delegate_views.h" |
6 | 6 |
7 #include "ui/gfx/geometry/rect.h" | 7 #include "ui/gfx/geometry/rect.h" |
| 8 #include "ui/gfx/image/image.h" |
8 #include "ui/views/controls/menu/menu_item_view.h" | 9 #include "ui/views/controls/menu/menu_item_view.h" |
9 #include "ui/views/controls/menu/menu_model_adapter.h" | 10 #include "ui/views/controls/menu/menu_model_adapter.h" |
10 #include "ui/views/controls/menu/menu_runner.h" | 11 #include "ui/views/controls/menu/menu_runner.h" |
11 | 12 |
12 ToolkitDelegateViews::ToolkitDelegateViews() : menu_view_(NULL) {} | 13 ToolkitDelegateViews::ToolkitDelegateViews() : menu_view_(NULL) {} |
13 | 14 |
14 ToolkitDelegateViews::~ToolkitDelegateViews() {} | 15 ToolkitDelegateViews::~ToolkitDelegateViews() {} |
15 | 16 |
16 void ToolkitDelegateViews::RunMenuAt(views::Widget* parent, | 17 void ToolkitDelegateViews::RunMenuAt(views::Widget* parent, |
17 const gfx::Point& point, | 18 const gfx::Point& point, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 item->SetTitle(title); | 51 item->SetTitle(title); |
51 item->SetVisible(!hidden); | 52 item->SetVisible(!hidden); |
52 | 53 |
53 views::MenuItemView* parent = item->GetParentMenuItem(); | 54 views::MenuItemView* parent = item->GetParentMenuItem(); |
54 if (!parent) | 55 if (!parent) |
55 return; | 56 return; |
56 | 57 |
57 parent->ChildrenChanged(); | 58 parent->ChildrenChanged(); |
58 } | 59 } |
59 | 60 |
| 61 void ToolkitDelegateViews::SetIcon(int command_id, const gfx::Image& icon) { |
| 62 views::MenuItemView* item = menu_view_->GetMenuItemByID(command_id); |
| 63 if (!item) |
| 64 return; |
| 65 item->SetIcon(*icon.ToImageSkia()); |
| 66 } |
OLD | NEW |