From ce7db337437bb826f5081ab784a7ccda2916dbd7 Mon Sep 17 00:00:00 2001 From: "tfarina@chromium.org" Date: Thu, 5 Apr 2012 17:09:35 +0000 Subject: views: Extract SystemMenuModel from native_menu_win.*. This patch moves a model used by BrowserFrameWin near where it's really used, and into a place that looks more appropriated, which is to frame/ directory, near to system_menu_model_delegate.*. R=sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/9966007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130950 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/views/controls/menu/native_menu_win.cc | 16 +--------------- ui/views/controls/menu/native_menu_win.h | 26 ++++++-------------------- 2 files changed, 7 insertions(+), 35 deletions(-) (limited to 'ui') diff --git a/ui/views/controls/menu/native_menu_win.cc b/ui/views/controls/menu/native_menu_win.cc index aa4adbd..1d518ea 100644 --- a/ui/views/controls/menu/native_menu_win.cc +++ b/ui/views/controls/menu/native_menu_win.cc @@ -17,6 +17,7 @@ #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util_win.h" +#include "ui/base/models/menu_model.h" #include "ui/base/win/hwnd_util.h" #include "ui/gfx/canvas.h" #include "ui/gfx/font.h" @@ -739,21 +740,6 @@ void NativeMenuWin::CreateHostWindow() { } //////////////////////////////////////////////////////////////////////////////// -// SystemMenuModel: - -SystemMenuModel::SystemMenuModel(ui::SimpleMenuModel::Delegate* delegate) - : SimpleMenuModel(delegate) { -} - -SystemMenuModel::~SystemMenuModel() { -} - -int SystemMenuModel::GetFirstItemIndex(gfx::NativeMenu native_menu) const { - // We allow insertions before last item (Close). - return std::max(0, GetMenuItemCount(native_menu) - 1); -} - -//////////////////////////////////////////////////////////////////////////////// // MenuWrapper, public: // static diff --git a/ui/views/controls/menu/native_menu_win.h b/ui/views/controls/menu/native_menu_win.h index 08e07ba..c4b5543 100644 --- a/ui/views/controls/menu/native_menu_win.h +++ b/ui/views/controls/menu/native_menu_win.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,10 +13,14 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" -#include "ui/base/models/simple_menu_model.h" +#include "base/string16.h" #include "ui/views/controls/menu/menu_wrapper.h" #include "ui/views/views_export.h" +namespace ui { +class MenuModel; +} + namespace views { // A Windows implementation of MenuWrapper. @@ -161,24 +165,6 @@ class VIEWS_EXPORT NativeMenuWin : public MenuWrapper { DISALLOW_COPY_AND_ASSIGN(NativeMenuWin); }; -// A SimpleMenuModel subclass that allows the system menu for a window to be -// wrapped. -class VIEWS_EXPORT SystemMenuModel : public ui::SimpleMenuModel { - public: - explicit SystemMenuModel(Delegate* delegate); - virtual ~SystemMenuModel(); - - // Overridden from ui::MenuModel: - virtual int GetFirstItemIndex(gfx::NativeMenu native_menu) const; - - protected: - // Overridden from SimpleMenuModel: - virtual int FlipIndex(int index) const { return GetItemCount() - index - 1; } - - private: - DISALLOW_COPY_AND_ASSIGN(SystemMenuModel); -}; - } // namespace views #endif // UI_VIEWS_CONTROLS_MENU_NATIVE_MENU_WIN_H_ -- cgit v1.1