| OLD | NEW |
| (Empty) |
| 1 // Copyright 2011 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 // | |
| 16 // Apps may define commands using Registry entries. There are two supported | |
| 17 // formats: | |
| 18 // | |
| 19 // Legacy Format: | |
| 20 // ROOT\\Software\\Google\\Update\\Clients\\{app-guid} | |
| 21 // <command-id> = REG_SZ (command line) | |
| 22 // | |
| 23 // New Format: | |
| 24 // ROOT\\Software\\Google\\Update\\Clients\\{app-guid}\\Commands\\<command-id> | |
| 25 // CommandLine = REG_SZ | |
| 26 // SendsPings = DWORD | |
| 27 // WebAccessible = DWORD | |
| 28 // ReportingId = DWORD | |
| 29 // | |
| 30 // Only the command line is required, all other values default to 0. It is not | |
| 31 // possible to set other values using the Legacy format. | |
| 32 | |
| 33 #ifndef OMAHA_GOOPDATE_APP_COMMAND_H__ | |
| 34 #define OMAHA_GOOPDATE_APP_COMMAND_H__ | |
| 35 | |
| 36 #include <windows.h> | |
| 37 #include <string> | |
| 38 #include "base/basictypes.h" | |
| 39 | |
| 40 namespace omaha { | |
| 41 | |
| 42 // Loads, provides metadata for, and executes named commands for installed | |
| 43 // apps. | |
| 44 class AppCommand { | |
| 45 public: | |
| 46 static HRESULT Load(const CString& app_guid, | |
| 47 bool is_machine, | |
| 48 const CString& cmd_id, | |
| 49 const CString& session_id, | |
| 50 AppCommand** app_command); | |
| 51 | |
| 52 // Executes the command at the current integrity level. If successful, | |
| 53 // the caller is responsible for closing the process HANDLE. This method does | |
| 54 // not enforce the 'web accessible' constraint (this is the caller's | |
| 55 // responsibility). | |
| 56 HRESULT Execute(HANDLE* process) const; | |
| 57 | |
| 58 // Returns true if this command is allowed to be invoked through the | |
| 59 // OneClick control. | |
| 60 bool is_web_accessible() const { return is_web_accessible_; } | |
| 61 | |
| 62 private: | |
| 63 AppCommand(const CString& app_guid, | |
| 64 bool is_machine, | |
| 65 const CString& cmd_id, | |
| 66 const CString& cmd_line, | |
| 67 bool sends_pings, | |
| 68 const CString& session_id, | |
| 69 bool is_web_accessible, | |
| 70 DWORD reporting_id); | |
| 71 | |
| 72 // Starts a thread which waits for the process to exit, sends a ping, and then | |
| 73 // terminates. Waits up to 15 minutes before aborting the wait. A ping is also | |
| 74 // sent if the wait times out or if a failure occurs while starting the | |
| 75 // thread, initializing the wait, or retrieving the process exit code. | |
| 76 // | |
| 77 // Duplicates the process HANDLE, leaving the caller with ownership of the | |
| 78 // passed handle. | |
| 79 // | |
| 80 // The thread holds a COM object until the work is completed in order to | |
| 81 // avoid early termination if all other clients of the process release their | |
| 82 // references. | |
| 83 void StartBackgroundThread(HANDLE process) const; | |
| 84 | |
| 85 // Identifying information. | |
| 86 const CString app_guid_; | |
| 87 const bool is_machine_; | |
| 88 const CString cmd_id_; | |
| 89 const CString session_id_; | |
| 90 | |
| 91 // Configuration from the registry. | |
| 92 const CString cmd_line_; | |
| 93 const bool sends_pings_; | |
| 94 const bool is_web_accessible_; | |
| 95 const int reporting_id_; | |
| 96 | |
| 97 DISALLOW_COPY_AND_ASSIGN(AppCommand); | |
| 98 }; // class AppCommand | |
| 99 | |
| 100 } // namespace omaha | |
| 101 | |
| 102 #endif // OMAHA_GOOPDATE_APP_COMMAND_H__ | |
| OLD | NEW |