Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7352)

Unified Diff: chrome/browser/ui/toolbar/wrench_menu_model.cc

Issue 5697005: Change SimpleMenuModel on OSX to support dynamic icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved background page badge fix to another CL. Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/wrench_menu_model.cc
diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc
index 50b6c498db9cf7b9229d5310ea5d3dc536225da4..6b7f043d7109f699d9ee0bf26f8a268c0a99223e 100644
--- a/chrome/browser/ui/toolbar/wrench_menu_model.cc
+++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc
@@ -221,9 +221,6 @@ WrenchMenuModel::WrenchMenuModel(menus::AcceleratorProvider* provider,
Source<Profile>(browser_->profile()));
registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
NotificationService::AllSources());
- registrar_.Add(this,
- NotificationType::BACKGROUND_PAGE_TRACKER_CHANGED,
- NotificationService::AllSources());
}
WrenchMenuModel::~WrenchMenuModel() {
@@ -235,7 +232,7 @@ bool WrenchMenuModel::DoesCommandIdDismissMenu(int command_id) const {
return command_id != IDC_ZOOM_MINUS && command_id != IDC_ZOOM_PLUS;
}
-bool WrenchMenuModel::IsLabelForCommandIdDynamic(int command_id) const {
+bool WrenchMenuModel::IsItemForCommandIdDynamic(int command_id) const {
return command_id == IDC_ZOOM_PERCENT_DISPLAY ||
#if defined(OS_MACOSX)
command_id == IDC_FULLSCREEN ||
@@ -244,6 +241,26 @@ bool WrenchMenuModel::IsLabelForCommandIdDynamic(int command_id) const {
command_id == IDC_VIEW_BACKGROUND_PAGES;
}
+bool WrenchMenuModel::GetIconForCommandId(int command_id,
+ SkBitmap* bitmap) const {
+ switch (command_id) {
+ case IDC_VIEW_BACKGROUND_PAGES: {
+ int num_pages = BackgroundPageTracker::GetSingleton()->
+ GetUnacknowledgedBackgroundPageCount();
+ if (num_pages > 0) {
+ *bitmap = GetBackgroundPageIcon();
+ return true;
+ } else {
+ // No icon.
+ return false;
+ }
+ }
+ default:
+ // No icon for other dynamic menu items.
+ return false;
+ }
+}
+
string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const {
switch (command_id) {
case IDC_SYNC_BOOKMARKS:
@@ -350,18 +367,6 @@ void WrenchMenuModel::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
switch (type.value) {
- case NotificationType::BACKGROUND_PAGE_TRACKER_CHANGED: {
- int num_pages = BackgroundPageTracker::GetSingleton()->
- GetUnacknowledgedBackgroundPageCount();
- if (num_pages > 0) {
- SetIcon(GetIndexOfCommandId(IDC_VIEW_BACKGROUND_PAGES),
- GetBackgroundPageIcon());
- } else {
- // Just set a blank icon (no icon).
- SetIcon(GetIndexOfCommandId(IDC_VIEW_BACKGROUND_PAGES), SkBitmap());
- }
- break;
- }
case NotificationType::ZOOM_LEVEL_CHANGED:
case NotificationType::NAV_ENTRY_COMMITTED:
UpdateZoomControls();
@@ -482,14 +487,6 @@ void WrenchMenuModel::Build() {
*rb.GetBitmapNamed(IDR_CONFLICT_MENU));
#endif
- // Add an icon to the View Background Pages item if there are unacknowledged
- // pages.
- if (BackgroundPageTracker::GetSingleton()->
- GetUnacknowledgedBackgroundPageCount() > 0) {
- SetIcon(GetIndexOfCommandId(IDC_VIEW_BACKGROUND_PAGES),
- GetBackgroundPageIcon());
- }
-
AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE);
if (browser_defaults::kShowExitMenuItem) {
AddSeparator();

Powered by Google App Engine
This is Rietveld 408576698