summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/cocoa/tab_contents_controller.mm6
-rw-r--r--chrome/browser/command_updater.cc10
-rw-r--r--chrome/browser/command_updater.h3
3 files changed, 14 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm
index c6d25a7..6f4a88e 100644
--- a/chrome/browser/cocoa/tab_contents_controller.mm
+++ b/chrome/browser/cocoa/tab_contents_controller.mm
@@ -166,11 +166,7 @@ TabContentsCommandObserver::TabContentsCommandObserver(
TabContentsCommandObserver::~TabContentsCommandObserver() {
// Unregister the notifications
- commands_->RemoveCommandObserver(IDC_BACK, this);
- commands_->RemoveCommandObserver(IDC_FORWARD, this);
- commands_->RemoveCommandObserver(IDC_RELOAD, this);
- commands_->RemoveCommandObserver(IDC_HOME, this);
- commands_->RemoveCommandObserver(IDC_STAR, this);
+ commands_->RemoveCommandObserver(this);
}
void TabContentsCommandObserver::EnabledStateChangedForCommand(int command,
diff --git a/chrome/browser/command_updater.cc b/chrome/browser/command_updater.cc
index 8839965..db34bbd 100644
--- a/chrome/browser/command_updater.cc
+++ b/chrome/browser/command_updater.cc
@@ -59,3 +59,13 @@ void CommandUpdater::AddCommandObserver(int id, CommandObserver* observer) {
void CommandUpdater::RemoveCommandObserver(int id, CommandObserver* observer) {
GetCommand(id, false)->observers.RemoveObserver(observer);
}
+
+void CommandUpdater::RemoveCommandObserver(CommandObserver* observer) {
+ for (CommandMap::const_iterator it = commands_.begin();
+ it != commands_.end();
+ ++it) {
+ Command* command = it->second;
+ if (command)
+ command->observers.RemoveObserver(observer);
+ }
+}
diff --git a/chrome/browser/command_updater.h b/chrome/browser/command_updater.h
index ef937c6..cbc14fe 100644
--- a/chrome/browser/command_updater.h
+++ b/chrome/browser/command_updater.h
@@ -61,6 +61,9 @@ class CommandUpdater {
// Removes an observer to the state of a particular command.
void RemoveCommandObserver(int id, CommandObserver* observer);
+
+ // Removes |observer| for all commands on which it's registered.
+ void RemoveCommandObserver(CommandObserver* observer);
// Notify all observers of a particular command that the command has been
// enabled or disabled. If the command does not exist, it is created and