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

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

Issue 2230203002: chrome: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed accidental components/ change Created 4 years, 4 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) 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/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "chrome/browser/command_observer.h" 12 #include "chrome/browser/command_observer.h"
13 #include "chrome/browser/command_updater_delegate.h" 13 #include "chrome/browser/command_updater_delegate.h"
14 14
15 class CommandUpdater::Command { 15 class CommandUpdater::Command {
16 public: 16 public:
17 bool enabled; 17 bool enabled;
18 base::ObserverList<CommandObserver> observers; 18 base::ObserverList<CommandObserver> observers;
19 19
20 Command() : enabled(true) {} 20 Command() : enabled(true) {}
21 }; 21 };
22 22
23 CommandUpdater::CommandUpdater(CommandUpdaterDelegate* delegate) 23 CommandUpdater::CommandUpdater(CommandUpdaterDelegate* delegate)
24 : delegate_(delegate) { 24 : delegate_(delegate) {
25 } 25 }
26 26
27 CommandUpdater::~CommandUpdater() { 27 CommandUpdater::~CommandUpdater() {
28 STLDeleteContainerPairSecondPointers(commands_.begin(), commands_.end()); 28 base::STLDeleteContainerPairSecondPointers(commands_.begin(),
29 commands_.end());
29 } 30 }
30 31
31 bool CommandUpdater::SupportsCommand(int id) const { 32 bool CommandUpdater::SupportsCommand(int id) const {
32 return commands_.find(id) != commands_.end(); 33 return commands_.find(id) != commands_.end();
33 } 34 }
34 35
35 bool CommandUpdater::IsCommandEnabled(int id) const { 36 bool CommandUpdater::IsCommandEnabled(int id) const {
36 const CommandMap::const_iterator command(commands_.find(id)); 37 const CommandMap::const_iterator command(commands_.find(id));
37 if (command == commands_.end()) 38 if (command == commands_.end())
38 return false; 39 return false;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 83
83 CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) { 84 CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) {
84 bool supported = SupportsCommand(id); 85 bool supported = SupportsCommand(id);
85 if (supported) 86 if (supported)
86 return commands_[id]; 87 return commands_[id];
87 DCHECK(create); 88 DCHECK(create);
88 Command* command = new Command; 89 Command* command = new Command;
89 commands_[id] = command; 90 commands_[id] = command;
90 return command; 91 return command;
91 } 92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698