OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 if (command) | 66 if (command) |
67 command->observers.RemoveObserver(observer); | 67 command->observers.RemoveObserver(observer); |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 void CommandUpdater::UpdateCommandEnabled(int id, bool enabled) { | 71 void CommandUpdater::UpdateCommandEnabled(int id, bool enabled) { |
72 Command* command = GetCommand(id, true); | 72 Command* command = GetCommand(id, true); |
73 if (command->enabled == enabled) | 73 if (command->enabled == enabled) |
74 return; // Nothing to do. | 74 return; // Nothing to do. |
75 command->enabled = enabled; | 75 command->enabled = enabled; |
76 FOR_EACH_OBSERVER(CommandObserver, command->observers, | 76 for (auto& observer : command->observers) |
77 EnabledStateChangedForCommand(id, enabled)); | 77 observer.EnabledStateChangedForCommand(id, enabled); |
78 } | 78 } |
79 | 79 |
80 CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) { | 80 CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) { |
81 bool supported = SupportsCommand(id); | 81 bool supported = SupportsCommand(id); |
82 if (supported) | 82 if (supported) |
83 return commands_[id].get(); | 83 return commands_[id].get(); |
84 | 84 |
85 DCHECK(create); | 85 DCHECK(create); |
86 std::unique_ptr<Command>& entry = commands_[id]; | 86 std::unique_ptr<Command>& entry = commands_[id]; |
87 entry = base::MakeUnique<Command>(); | 87 entry = base::MakeUnique<Command>(); |
88 return entry.get(); | 88 return entry.get(); |
89 } | 89 } |
OLD | NEW |