Chromium Code Reviews| Index: views/controls/menu/native_menu_win.cc |
| diff --git a/views/controls/menu/native_menu_win.cc b/views/controls/menu/native_menu_win.cc |
| index b9c78a1617a2fec961b97e9d7f2bcbc60f2b6d0f..6d1733f4239eab5ef14275b715c9b1abd20d6b41 100644 |
| --- a/views/controls/menu/native_menu_win.cc |
| +++ b/views/controls/menu/native_menu_win.cc |
| @@ -5,6 +5,7 @@ |
| #include "views/controls/menu/native_menu_win.h" |
| #include "base/logging.h" |
| +#include "base/message_loop.h" |
| #include "base/stl_util-inl.h" |
| #include "base/string_util.h" |
| #include "base/win/wrapped_window_proc.h" |
| @@ -311,6 +312,7 @@ NativeMenuWin::NativeMenuWin(ui::MenuModel* model, HWND system_menu_for) |
| system_menu_for_(system_menu_for), |
| first_item_index_(0), |
| menu_action_(MENU_ACTION_NONE) { |
| + model_->SetMenuModelDelegate(this); |
|
sky
2011/04/05 22:40:48
Move this to RUnMenuAt.
dill
2011/04/08 15:48:46
Done.
|
| } |
| NativeMenuWin::~NativeMenuWin() { |
| @@ -340,12 +342,16 @@ void NativeMenuWin::RunMenuAt(const gfx::Point& point, int alignment) { |
| // opening of the menu. |
| listeners_called_ = false; |
| + // Retrieving favicons from history requires nestable tasks. |
| + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
| + |
| // Command dispatch is done through WM_MENUCOMMAND, handled by the host |
| // window. |
| HWND hwnd = host_window_->hwnd(); |
| TrackPopupMenuEx(menu_, flags, point.x(), point.y(), host_window_->hwnd(), |
| NULL); |
| + model_->SetMenuModelDelegate(NULL); |
| UnhookWindowsHookEx(hhook); |
| open_native_menu_win_ = NULL; |
| } |
| @@ -416,6 +422,15 @@ void NativeMenuWin::SetMinimumWidth(int width) { |
| NOTIMPLEMENTED(); |
| } |
| +void NativeMenuWin::OnIconChanged(int model_index) { |
| + // Translate the model_index to the menu_index. |
| + int first_item_index_ = model_->GetFirstItemIndex(GetNativeMenu()); |
| + int menu_index = model_index + first_item_index_; |
| + // Unfortunately this repaints the entire menu. |
| + SetMenuItemState(menu_index, model_->IsEnabledAt(model_index), |
| + model_->IsItemCheckedAt(model_index), false); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // NativeMenuWin, private: |