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_PRODUCT_COMMANDS_H_ |
| 6 #define CHROME_INSTALLER_UTIL_PRODUCT_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/product_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 ProductCommand objects. |
| 29 class ProductCommands { |
| 30 public: |
| 31 typedef std::map<std::wstring, ProductCommand> CommandMap; |
| 32 typedef std::pair<CommandMap::const_iterator, CommandMap::const_iterator> |
| 33 CommandMapRange; |
| 34 |
| 35 ProductCommands(); |
| 36 ~ProductCommands(); |
| 37 |
| 38 // Initialize an instance from the set of commands in a given registry key |
| 39 // (typically a BrowserDistribution's "version key"). |
| 40 bool Initialize(const base::win::RegKey& key); |
| 41 |
| 42 // Replaces the contents of this object with that of |other|. |
| 43 ProductCommands& CopyFrom(const ProductCommands& other); |
| 44 |
| 45 // Clears this instance. |
| 46 void Clear(); |
| 47 |
| 48 // Retrieves the command identified by |command_id| from the set, copying it |
| 49 // into |command| and returning true if present. |
| 50 bool Get(const std::wstring& command_id, ProductCommand* command) const; |
| 51 |
| 52 // Sets a command in the collection, adding it if it doesn't already exist. |
| 53 // Returns true if a new command is added; false if |command_id| was already |
| 54 // present and has been replaced with |command|. |
| 55 bool Set(const std::wstring& command_id, const ProductCommand& command); |
| 56 |
| 57 // Removes a command from the collection. Returns false if |command_id| was |
| 58 // not found. |
| 59 bool Remove(const std::wstring& command_id); |
| 60 |
| 61 // Returns a pair of STL iterators defining the range of objects in the |
| 62 // collection. |
| 63 CommandMapRange GetIterators() const; |
| 64 |
| 65 protected: |
| 66 CommandMap commands_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(ProductCommands); |
| 69 }; |
| 70 |
| 71 } // namespace installer |
| 72 |
| 73 #endif // CHROME_INSTALLER_UTIL_PRODUCT_COMMANDS_H_ |
OLD | NEW |