OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_INSTALLER_UTIL_APP_COMMANDS_H_ |
| 6 #define CHROME_INSTALLER_UTIL_APP_COMMANDS_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <windows.h> |
| 10 |
| 11 #include <map> |
| 12 #include <string> |
| 13 #include <utility> |
| 14 |
| 15 #include "base/basictypes.h" |
| 16 #include "chrome/installer/util/app_command.h" |
| 17 |
| 18 class WorkItemList; |
| 19 |
| 20 namespace base { |
| 21 namespace win { |
| 22 class RegKey; |
| 23 } |
| 24 } |
| 25 |
| 26 namespace installer { |
| 27 |
| 28 // A collection of AppCommand objects. |
| 29 class AppCommands { |
| 30 public: |
| 31 typedef std::map<std::wstring, AppCommand> CommandMap; |
| 32 typedef std::pair<CommandMap::const_iterator, CommandMap::const_iterator> |
| 33 CommandMapRange; |
| 34 |
| 35 AppCommands(); |
| 36 ~AppCommands(); |
| 37 |
| 38 // Initialize an instance from the set of commands in a given registry key |
| 39 // (typically the "Commands" subkey of a BrowserDistribution's "version key"). |
| 40 // |key| must have been opened with at least |
| 41 // KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE access rights. |
| 42 bool Initialize(const base::win::RegKey& key); |
| 43 |
| 44 // Replaces the contents of this object with that of |other|. |
| 45 AppCommands& CopyFrom(const AppCommands& other); |
| 46 |
| 47 // Clears this instance. |
| 48 void Clear(); |
| 49 |
| 50 // Retrieves the command identified by |command_id| from the set, copying it |
| 51 // into |command| and returning true if present. |
| 52 bool Get(const std::wstring& command_id, AppCommand* command) const; |
| 53 |
| 54 // Sets a command in the collection, adding it if it doesn't already exist. |
| 55 // Returns true if a new command is added; false if |command_id| was already |
| 56 // present and has been replaced with |command|. |
| 57 bool Set(const std::wstring& command_id, const AppCommand& command); |
| 58 |
| 59 // Removes a command from the collection. Returns false if |command_id| was |
| 60 // not found. |
| 61 bool Remove(const std::wstring& command_id); |
| 62 |
| 63 // Returns a pair of STL iterators defining the range of objects in the |
| 64 // collection. |
| 65 CommandMapRange GetIterators() const; |
| 66 |
| 67 protected: |
| 68 CommandMap commands_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(AppCommands); |
| 71 }; |
| 72 |
| 73 } // namespace installer |
| 74 |
| 75 #endif // CHROME_INSTALLER_UTIL_APP_COMMANDS_H_ |
OLD | NEW |