• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_COMMAND_H_
6 #define CHROME_INSTALLER_UTIL_APP_COMMAND_H_
7 
8 #include <windows.h>
9 
10 #include "base/strings/string16.h"
11 
12 class WorkItemList;
13 
14 namespace base {
15 namespace win {
16 class RegKey;
17 }
18 }
19 
20 namespace installer {
21 
22 // A description of a command registered by setup.exe that can be invoked by
23 // Google Update.  This class is CopyConstructible and Assignable for use in
24 // STL containers.
25 class AppCommand {
26  public:
27   AppCommand();
28   // Constructs a new command that will execute the given |command_line|.
29   // All other properties default to false.
30   explicit AppCommand(const base::string16& command_line);
31   // The implicit dtor, copy ctor and assignment operator are desired.
32 
33   // Initializes an instance from the command in |key|.
34   bool Initialize(const base::win::RegKey& key);
35 
36   // Adds to |item_list| work items to write this object to the key named
37   // |command_path| under |predefined_root|.
38   void AddWorkItems(HKEY predefined_root,
39                     const base::string16& command_path,
40                     WorkItemList* item_list) const;
41 
42   // Returns the command-line for the app command as it is represented in the
43   // registry.  Use CommandLine::FromString() on this value to check arguments
44   // or to launch the command.
command_line()45   const base::string16& command_line() const { return command_line_; }
set_command_line(const base::string16 & command_line)46   void set_command_line(const base::string16& command_line) {
47     command_line_ = command_line;
48   }
49 
sends_pings()50   bool sends_pings() const { return sends_pings_; }
set_sends_pings(bool sends_pings)51   void set_sends_pings(bool sends_pings) { sends_pings_ = sends_pings; }
52 
is_web_accessible()53   bool is_web_accessible() const { return is_web_accessible_; }
set_is_web_accessible(bool is_web_accessible)54   void set_is_web_accessible(bool is_web_accessible) {
55     is_web_accessible_ = is_web_accessible;
56   }
57 
is_auto_run_on_os_upgrade()58   bool is_auto_run_on_os_upgrade() const { return is_auto_run_on_os_upgrade_; }
set_is_auto_run_on_os_upgrade(bool is_auto_run_on_os_upgrade)59   void set_is_auto_run_on_os_upgrade(bool is_auto_run_on_os_upgrade) {
60     is_auto_run_on_os_upgrade_ = is_auto_run_on_os_upgrade;
61   }
62 
is_run_as_user()63   bool is_run_as_user() const { return is_run_as_user_; }
set_is_run_as_user(bool is_run_as_user)64   void set_is_run_as_user(bool is_run_as_user) {
65     is_run_as_user_ = is_run_as_user;
66   }
67 
68  protected:
69   base::string16 command_line_;
70   bool sends_pings_;
71   bool is_web_accessible_;
72   bool is_auto_run_on_os_upgrade_;
73   bool is_run_as_user_;
74 
75  private:
76   struct NamedBoolVar {
77     bool AppCommand::* data;
78     const wchar_t* name;
79   };
80 
81   static const NamedBoolVar kNameBoolVars[];
82 };
83 
84 }  // namespace installer
85 
86 #endif  // CHROME_INSTALLER_UTIL_APP_COMMAND_H_
87