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

Unified Diff: chrome/browser/command_updater.cc

Issue 11308259: chrome: Extract CommandUpdaterDelegate into its own header file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: FakeCommandObserver Created 8 years, 1 month 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/command_updater.cc
diff --git a/chrome/browser/command_updater.cc b/chrome/browser/command_updater.cc
index a92b8cb79ced7a1381c0716a50f4f3f1f7607624..4eb8391711f0c51ae8f5a74f79744dfa44d350be 100644
--- a/chrome/browser/command_updater.cc
+++ b/chrome/browser/command_updater.cc
@@ -10,9 +10,7 @@
#include "base/observer_list.h"
#include "base/stl_util.h"
#include "chrome/browser/command_observer.h"
-
-CommandUpdater::CommandUpdaterDelegate::~CommandUpdaterDelegate() {
-}
+#include "chrome/browser/command_updater_delegate.h"
class CommandUpdater::Command {
public:
@@ -22,14 +20,18 @@ class CommandUpdater::Command {
Command() : enabled(true) {}
};
-CommandUpdater::CommandUpdater(CommandUpdaterDelegate* handler)
- : delegate_(handler) {
+CommandUpdater::CommandUpdater(CommandUpdaterDelegate* delegate)
+ : delegate_(delegate) {
}
CommandUpdater::~CommandUpdater() {
STLDeleteContainerPairSecondPointers(commands_.begin(), commands_.end());
}
+bool CommandUpdater::SupportsCommand(int id) const {
+ return commands_.find(id) != commands_.end();
+}
+
bool CommandUpdater::IsCommandEnabled(int id) const {
const CommandMap::const_iterator command(commands_.find(id));
if (command == commands_.end())
@@ -37,10 +39,6 @@ bool CommandUpdater::IsCommandEnabled(int id) const {
return command->second->enabled;
}
-bool CommandUpdater::SupportsCommand(int id) const {
- return commands_.find(id) != commands_.end();
-}
-
bool CommandUpdater::ExecuteCommand(int id) {
return ExecuteCommandWithDisposition(id, CURRENT_TAB);
}
@@ -55,7 +53,22 @@ bool CommandUpdater::ExecuteCommandWithDisposition(
return false;
}
-CommandObserver::~CommandObserver() {
+void CommandUpdater::AddCommandObserver(int id, CommandObserver* observer) {
+ GetCommand(id, true)->observers.AddObserver(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);
+ }
}
void CommandUpdater::UpdateCommandEnabled(int id, bool enabled) {
@@ -76,21 +89,3 @@ CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) {
commands_[id] = command;
return command;
}
-
-void CommandUpdater::AddCommandObserver(int id, CommandObserver* observer) {
- GetCommand(id, true)->observers.AddObserver(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);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698