From 738a929f8c4f2c243487012b6e4fee61ffd20ef3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 17 Aug 2013 17:10:16 +0800 Subject: [PATCH] [Win] Add flag to build window menu. --- browser/ui/win/native_menu_win.cc | 5 +++-- browser/ui/win/native_menu_win.h | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/browser/ui/win/native_menu_win.cc b/browser/ui/win/native_menu_win.cc index 3ab06309492e..cae6e54e7ba0 100644 --- a/browser/ui/win/native_menu_win.cc +++ b/browser/ui/win/native_menu_win.cc @@ -404,7 +404,8 @@ NativeMenuWin::NativeMenuWin(ui::MenuModel* model, HWND system_menu_for) position_to_select_(-1), menu_to_select_factory_(this), parent_(NULL), - destroyed_flag_(NULL) { + destroyed_flag_(NULL), + create_as_window_menu_(false) { } NativeMenuWin::~NativeMenuWin() { @@ -736,7 +737,7 @@ void NativeMenuWin::ResetNativeMenu() { } else { if (menu_) DestroyMenu(menu_); - menu_ = CreatePopupMenu(); + menu_ = create_as_window_menu_ ? CreateMenu() : CreatePopupMenu(); // Rather than relying on the return value of TrackPopupMenuEx, which is // always a command identifier, instead we tell the menu to notify us via // our host window and the WM_MENUCOMMAND message. diff --git a/browser/ui/win/native_menu_win.h b/browser/ui/win/native_menu_win.h index 05dc085a70ef..6a9652227c14 100644 --- a/browser/ui/win/native_menu_win.h +++ b/browser/ui/win/native_menu_win.h @@ -43,6 +43,10 @@ class NativeMenuWin : public MenuWrapper { virtual void RemoveMenuListener(views::MenuListener* listener) OVERRIDE; virtual void SetMinimumWidth(int width) OVERRIDE; + // Flag to create a window menu instead of popup menu. + void set_create_as_window_menu(bool flag) { create_as_window_menu_ = flag; } + bool create_as_window_menu() const { return create_as_window_menu_; } + private: // IMPORTANT: Note about indices. // Functions in this class deal in two index spaces: @@ -161,6 +165,9 @@ class NativeMenuWin : public MenuWrapper { // events doesn't have a mechanism to get a user data pointer. static NativeMenuWin* open_native_menu_win_; + // Create as window menu. + bool create_as_window_menu_; + DISALLOW_COPY_AND_ASSIGN(NativeMenuWin); };