| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_APP_MENU_MODEL_H_ | 5 #ifndef CHROME_BROWSER_APP_MENU_MODEL_H_ |
| 6 #define CHROME_BROWSER_APP_MENU_MODEL_H_ | 6 #define CHROME_BROWSER_APP_MENU_MODEL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "app/menus/simple_menu_model.h" | 11 #include "app/menus/simple_menu_model.h" |
| 12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "chrome/browser/user_data_manager.h" | 14 #include "chrome/browser/user_data_manager.h" |
| 15 | 15 |
| 16 class Browser; | 16 class Browser; |
| 17 | 17 |
| 18 // A menu model that builds the contents of the app menu. | 18 // A menu model that builds the contents of the app menu. |
| 19 class AppMenuModel : public menus::SimpleMenuModel { | 19 class AppMenuModel : public menus::SimpleMenuModel { |
| 20 public: | 20 public: |
| 21 explicit AppMenuModel(menus::SimpleMenuModel::Delegate* delegate, | 21 explicit AppMenuModel(menus::SimpleMenuModel::Delegate* delegate, |
| 22 Browser* browser); | 22 Browser* browser); |
| 23 virtual ~AppMenuModel(); | 23 virtual ~AppMenuModel(); |
| 24 | 24 |
| 25 // Override this to handle the sync menu item (whose label is | 25 // Overridden from menus::SimpleMenuModel: |
| 26 // updated dynamically). | |
| 27 virtual bool IsLabelDynamicAt(int index) const; | 26 virtual bool IsLabelDynamicAt(int index) const; |
| 28 virtual string16 GetLabelAt(int index) const; | 27 virtual string16 GetLabelAt(int index) const; |
| 28 virtual bool HasIcons() const { return true; } |
| 29 virtual bool GetIconAt(int index, SkBitmap* icon) const; |
| 29 | 30 |
| 30 // Build/update profile submenu. Return true if profiles submenu is built or | 31 // Build/update profile submenu. Return true if profiles submenu is built or |
| 31 // updated. False otherwise. | 32 // updated. False otherwise. |
| 32 bool BuildProfileSubMenu(); | 33 bool BuildProfileSubMenu(); |
| 33 | 34 |
| 34 private: | 35 private: |
| 35 void Build(); | 36 void Build(); |
| 36 | 37 |
| 37 bool ProfilesChanged(const std::vector<std::wstring>& profiles) const; | 38 bool ProfilesChanged(const std::vector<std::wstring>& profiles) const; |
| 38 | 39 |
| 39 string16 GetSyncMenuLabel() const; | 40 string16 GetSyncMenuLabel() const; |
| 40 bool IsSyncItem(int index) const; | 41 string16 GetAboutEntryMenuLabel() const; |
| 42 bool IsDynamicItem(int index) const; |
| 41 | 43 |
| 42 // Contents of the profiles menu to populate with profile names. | 44 // Contents of the profiles menu to populate with profile names. |
| 43 scoped_ptr<menus::SimpleMenuModel> profiles_menu_contents_; | 45 scoped_ptr<menus::SimpleMenuModel> profiles_menu_contents_; |
| 44 | 46 |
| 45 // Profile names that are in profiles_menu_contents_. This is used to | 47 // Profile names that are in profiles_menu_contents_. This is used to |
| 46 // detect profile change. | 48 // detect profile change. |
| 47 std::vector<std::wstring> known_profiles_; | 49 std::vector<std::wstring> known_profiles_; |
| 48 | 50 |
| 49 Browser* browser_; // weak | 51 Browser* browser_; // weak |
| 50 | 52 |
| 51 DISALLOW_COPY_AND_ASSIGN(AppMenuModel); | 53 DISALLOW_COPY_AND_ASSIGN(AppMenuModel); |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 #endif // CHROME_BROWSER_APP_MENU_MODEL_H_ | 56 #endif // CHROME_BROWSER_APP_MENU_MODEL_H_ |
| OLD | NEW |