| 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/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool CommandUpdater::IsCommandEnabled(int id) const { | 36 bool CommandUpdater::IsCommandEnabled(int id) const { |
| 37 const CommandMap::const_iterator command(commands_.find(id)); | 37 const CommandMap::const_iterator command(commands_.find(id)); |
| 38 if (command == commands_.end()) | 38 if (command == commands_.end()) |
| 39 return false; | 39 return false; |
| 40 return command->second->enabled; | 40 return command->second->enabled; |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool CommandUpdater::ExecuteCommand(int id) { | 43 bool CommandUpdater::ExecuteCommand(int id) { |
| 44 return ExecuteCommandWithDisposition(id, CURRENT_TAB); | 44 return ExecuteCommandWithDisposition(id, WindowOpenDisposition::CURRENT_TAB); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool CommandUpdater::ExecuteCommandWithDisposition( | 47 bool CommandUpdater::ExecuteCommandWithDisposition( |
| 48 int id, | 48 int id, |
| 49 WindowOpenDisposition disposition) { | 49 WindowOpenDisposition disposition) { |
| 50 if (SupportsCommand(id) && IsCommandEnabled(id)) { | 50 if (SupportsCommand(id) && IsCommandEnabled(id)) { |
| 51 delegate_->ExecuteCommandWithDisposition(id, disposition); | 51 delegate_->ExecuteCommandWithDisposition(id, disposition); |
| 52 return true; | 52 return true; |
| 53 } | 53 } |
| 54 return false; | 54 return false; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 83 | 83 |
| 84 CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) { | 84 CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) { |
| 85 bool supported = SupportsCommand(id); | 85 bool supported = SupportsCommand(id); |
| 86 if (supported) | 86 if (supported) |
| 87 return commands_[id]; | 87 return commands_[id]; |
| 88 DCHECK(create); | 88 DCHECK(create); |
| 89 Command* command = new Command; | 89 Command* command = new Command; |
| 90 commands_[id] = command; | 90 commands_[id] = command; |
| 91 return command; | 91 return command; |
| 92 } | 92 } |
| OLD | NEW |