From f40e427a444a41e8f7cee18ed5490e1149c31b94 Mon Sep 17 00:00:00 2001 From: "mirandac@chromium.org" Date: Fri, 4 Mar 2011 19:51:27 +0000 Subject: Retry profile menu model change and clang fixes. BUG=none TEST=none Review URL: http://codereview.chromium.org/6632003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76952 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/profiles/profile_menu_model.cc | 43 ++++++++++++++++++++++++ chrome/browser/profiles/profile_menu_model.h | 48 +++++++++++++++++++++++++++ chrome/chrome_browser.gypi | 2 ++ views/controls/menu/menu_2.cc | 3 ++ views/controls/menu/menu_2.h | 2 +- 5 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 chrome/browser/profiles/profile_menu_model.cc create mode 100644 chrome/browser/profiles/profile_menu_model.h diff --git a/chrome/browser/profiles/profile_menu_model.cc b/chrome/browser/profiles/profile_menu_model.cc new file mode 100644 index 0000000..5baacc1 --- /dev/null +++ b/chrome/browser/profiles/profile_menu_model.cc @@ -0,0 +1,43 @@ +// Copyright (c) 2011 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. + +#include "chrome/browser/profiles/profile_menu_model.h" + +#include "grit/generated_resources.h" +#include "views/controls/menu/menu_2.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/models/accelerator.h" +#include "ui/base/models/simple_menu_model.h" + +ProfileMenuModel::ProfileMenuModel() + : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)) { + AddItem(0, l10n_util::GetStringUTF16( + IDS_PROFILES_CREATE_NEW_PROFILE_OPTION)); + menu_.reset(new views::Menu2(this)); +} + +ProfileMenuModel::~ProfileMenuModel() { +} + +void ProfileMenuModel::RunMenuAt(const gfx::Point& point) { + menu_->RunMenuAt(point, views::Menu2::ALIGN_TOPRIGHT); +} + +bool ProfileMenuModel::IsCommandIdChecked(int command_id) const { + return false; +} + +bool ProfileMenuModel::IsCommandIdEnabled(int command_id) const { + return false; +} + +bool ProfileMenuModel::GetAcceleratorForCommandId(int command_id, + ui::Accelerator* accelerator) { + return false; +} + +void ProfileMenuModel::ExecuteCommand(int command_id) { + NOTIMPLEMENTED(); +} + diff --git a/chrome/browser/profiles/profile_menu_model.h b/chrome/browser/profiles/profile_menu_model.h new file mode 100644 index 0000000..c168004 --- /dev/null +++ b/chrome/browser/profiles/profile_menu_model.h @@ -0,0 +1,48 @@ +// Copyright (c) 2011 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. + +#ifndef CHROME_BROWSER_PROFILES_PROFILE_MENU_MODEL_H_ +#define CHROME_BROWSER_PROFILES_PROFILE_MENU_MODEL_H_ +#pragma once + +#include "ui/base/models/simple_menu_model.h" +#include "ui/gfx/point.h" + +namespace ui { +class Accelerator; +} + +namespace views { +class Menu2; +} + +// ProfileMenuModel +// +// Menu for the multi-profile button displayed on the browser frame when the +// user is in a multi-profile-enabled account. Stub for now. TODO(mirandac): +// enable and fill in as part of multi-profile work. + +class ProfileMenuModel : public ui::SimpleMenuModel, + public ui::SimpleMenuModel::Delegate { + public: + ProfileMenuModel(); + virtual ~ProfileMenuModel(); + + void RunMenuAt(const gfx::Point& point); + + // ui::SimpleMenuModel::Delegate implementation + virtual bool IsCommandIdChecked(int command_id) const; + virtual bool IsCommandIdEnabled(int command_id) const; + virtual bool GetAcceleratorForCommandId(int command_id, + ui::Accelerator* accelerator); + virtual void ExecuteCommand(int command_id); + + private: + scoped_ptr menu_; + + DISALLOW_COPY_AND_ASSIGN(ProfileMenuModel); +}; + +#endif // CHROME_BROWSER_PROFILES_PROFILE_MENU_MODEL_H_ + diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index a5a2c12..7fde458 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1666,6 +1666,8 @@ 'browser/profiles/profile_io_data.h', 'browser/profiles/profile_manager.cc', 'browser/profiles/profile_manager.h', + 'browser/profiles/profile_menu_model.cc', + 'browser/profiles/profile_menu_model.h', 'browser/remoting/directory_add_request.cc', 'browser/remoting/directory_add_request.h', 'browser/remoting/remoting_options_handler.cc', diff --git a/views/controls/menu/menu_2.cc b/views/controls/menu/menu_2.cc index f64f275..388b4e9 100644 --- a/views/controls/menu/menu_2.cc +++ b/views/controls/menu/menu_2.cc @@ -16,6 +16,9 @@ Menu2::Menu2(ui::MenuModel* model) Rebuild(); } +Menu2::~Menu2() { +} + gfx::NativeMenu Menu2::GetNativeMenu() const { return wrapper_->GetNativeMenu(); } diff --git a/views/controls/menu/menu_2.h b/views/controls/menu/menu_2.h index 8916b7c..7204120 100644 --- a/views/controls/menu/menu_2.h +++ b/views/controls/menu/menu_2.h @@ -33,7 +33,7 @@ class Menu2 { // MyClass : menu_(this) {} // is likely to have problems. explicit Menu2(ui::MenuModel* model); - virtual ~Menu2() {} + virtual ~Menu2(); // How the menu is aligned relative to the point it is shown at. // The alignment is reversed by menu if text direction is right to left. -- cgit v1.1