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

Side by Side Diff: chrome/browser/command_updater.cc

Issue 3012001: Move implementation from header to source. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: blank line Created 10 years, 5 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/command_updater.h" 5 #include "chrome/browser/command_updater.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
12 12
13 CommandUpdater::CommandUpdaterDelegate::~CommandUpdaterDelegate() {
14 }
15
13 class CommandUpdater::Command { 16 class CommandUpdater::Command {
14 public: 17 public:
15 bool enabled; 18 bool enabled;
16 ObserverList<CommandObserver> observers; 19 ObserverList<CommandObserver> observers;
17 20
18 Command() : enabled(true) {} 21 Command() : enabled(true) {}
19 }; 22 };
20 23
21 CommandUpdater::CommandUpdater(CommandUpdaterDelegate* handler) 24 CommandUpdater::CommandUpdater(CommandUpdaterDelegate* handler)
22 : delegate_(handler) { 25 : delegate_(handler) {
(...skipping 12 matching lines...) Expand all
35 38
36 bool CommandUpdater::SupportsCommand(int id) const { 39 bool CommandUpdater::SupportsCommand(int id) const {
37 return commands_.find(id) != commands_.end(); 40 return commands_.find(id) != commands_.end();
38 } 41 }
39 42
40 void CommandUpdater::ExecuteCommand(int id) { 43 void CommandUpdater::ExecuteCommand(int id) {
41 if (IsCommandEnabled(id)) 44 if (IsCommandEnabled(id))
42 delegate_->ExecuteCommand(id); 45 delegate_->ExecuteCommand(id);
43 } 46 }
44 47
48 CommandUpdater::CommandObserver::~CommandObserver() {
49 }
50
45 void CommandUpdater::UpdateCommandEnabled(int id, bool enabled) { 51 void CommandUpdater::UpdateCommandEnabled(int id, bool enabled) {
46 Command* command = GetCommand(id, true); 52 Command* command = GetCommand(id, true);
47 if (command->enabled == enabled) 53 if (command->enabled == enabled)
48 return; // Nothing to do. 54 return; // Nothing to do.
49 command->enabled = enabled; 55 command->enabled = enabled;
50 FOR_EACH_OBSERVER(CommandObserver, command->observers, 56 FOR_EACH_OBSERVER(CommandObserver, command->observers,
51 EnabledStateChangedForCommand(id, enabled)); 57 EnabledStateChangedForCommand(id, enabled));
52 } 58 }
53 59
54 CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) { 60 CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) {
(...skipping 16 matching lines...) Expand all
71 77
72 void CommandUpdater::RemoveCommandObserver(CommandObserver* observer) { 78 void CommandUpdater::RemoveCommandObserver(CommandObserver* observer) {
73 for (CommandMap::const_iterator it = commands_.begin(); 79 for (CommandMap::const_iterator it = commands_.begin();
74 it != commands_.end(); 80 it != commands_.end();
75 ++it) { 81 ++it) {
76 Command* command = it->second; 82 Command* command = it->second;
77 if (command) 83 if (command)
78 command->observers.RemoveObserver(observer); 84 command->observers.RemoveObserver(observer);
79 } 85 }
80 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698