Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / installer / util / app_commands.h
blob61ea14e3854731a799d884618c44514859620a34
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.
5 #ifndef CHROME_INSTALLER_UTIL_APP_COMMANDS_H_
6 #define CHROME_INSTALLER_UTIL_APP_COMMANDS_H_
8 #include <windows.h>
10 #include <map>
11 #include <string>
12 #include <utility>
14 #include "base/basictypes.h"
15 #include "chrome/installer/util/app_command.h"
17 namespace base {
18 namespace win {
19 class RegKey;
23 namespace installer {
25 // A collection of AppCommand objects.
26 class AppCommands {
27 public:
28 typedef std::map<std::wstring, AppCommand> CommandMap;
29 typedef std::pair<CommandMap::const_iterator, CommandMap::const_iterator>
30 CommandMapRange;
32 AppCommands();
33 ~AppCommands();
35 // Initialize an instance from the set of commands in a given registry key
36 // (typically the "Commands" subkey of a BrowserDistribution's "version key").
37 // |key| must have been opened with at least
38 // KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE access rights.
39 // |wow64access| must be one of 0, KEY_WOW64_32KEY or KEY_WOW64_64KEY and
40 // must match the original WOW64 access used to open |key| previously.
41 bool Initialize(const base::win::RegKey& key, REGSAM wow64access);
43 // Replaces the contents of this object with that of |other|.
44 AppCommands& CopyFrom(const AppCommands& other);
46 // Clears this instance.
47 void Clear();
49 // Retrieves the command identified by |command_id| from the set, copying it
50 // into |command| and returning true if present.
51 bool Get(const std::wstring& command_id, AppCommand* command) const;
53 // Sets a command in the collection, adding it if it doesn't already exist.
54 // Returns true if a new command is added; false if |command_id| was already
55 // present and has been replaced with |command|.
56 bool Set(const std::wstring& command_id, const AppCommand& command);
58 // Removes a command from the collection. Returns false if |command_id| was
59 // not found.
60 bool Remove(const std::wstring& command_id);
62 // Returns a pair of STL iterators defining the range of objects in the
63 // collection.
64 CommandMapRange GetIterators() const;
66 protected:
67 CommandMap commands_;
69 DISALLOW_COPY_AND_ASSIGN(AppCommands);
72 } // namespace installer
74 #endif // CHROME_INSTALLER_UTIL_APP_COMMANDS_H_