| OLD | NEW |
| (Empty) |
| 1 // Copyright 2007-2010 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 #ifndef OMAHA_COMMON_APP_REGISTRY_UTILS_H_ | |
| 17 #define OMAHA_COMMON_APP_REGISTRY_UTILS_H_ | |
| 18 | |
| 19 #include <windows.h> | |
| 20 #include <atlstr.h> | |
| 21 #include <vector> | |
| 22 #include "omaha/base/constants.h" | |
| 23 | |
| 24 // Functions that modify the application state in the registry. This file should | |
| 25 // only be included by AppManager, which manages the persisting of all | |
| 26 // application information, ApplicationUsageData for similar reasons, and | |
| 27 // self-install code, which must modify these values directly in some cases. | |
| 28 | |
| 29 namespace omaha { | |
| 30 | |
| 31 namespace app_registry_utils { | |
| 32 | |
| 33 // Returns the application registration path for the specified app. | |
| 34 CString GetAppClientsKey(bool is_machine, const CString& app_guid); | |
| 35 | |
| 36 // Returns the application state path for the specified app. | |
| 37 CString GetAppClientStateKey(bool is_machine, const CString& app_guid); | |
| 38 | |
| 39 // Returns the medium integrity application state path for the specified app. | |
| 40 CString GetAppClientStateMediumKey(bool is_machine, const CString& app_guid); | |
| 41 | |
| 42 // Returns whether the EULA is accepted for the app. | |
| 43 bool IsAppEulaAccepted(bool is_machine, | |
| 44 const CString& app_guid, | |
| 45 bool require_explicit_acceptance); | |
| 46 | |
| 47 // Sets eulaaccepted=0 in the app's ClientState. | |
| 48 HRESULT SetAppEulaNotAccepted(bool is_machine, const CString& app_guid); | |
| 49 | |
| 50 // Clears any eulaaccepted=0 values for the app. | |
| 51 HRESULT ClearAppEulaNotAccepted(bool is_machine, const CString& app_guid); | |
| 52 | |
| 53 // Determines whether usage stats are enabled for a specific app. | |
| 54 bool AreAppUsageStatsEnabled(bool is_machine, const CString& app_guid); | |
| 55 | |
| 56 // Configures Omaha's collection of usage stats and crash reports. | |
| 57 HRESULT SetUsageStatsEnable(bool is_machine, | |
| 58 const CString& app_guid, | |
| 59 Tristate usage_stats_enable); | |
| 60 | |
| 61 // Writes branding information for Google Update in the registry if it does not | |
| 62 // already exist. Otherwise, the information remains unchanged. | |
| 63 // Writes a default Omaha-specific brand code if one is not specified in args. | |
| 64 HRESULT SetGoogleUpdateBranding(const CString& client_state_key_path, | |
| 65 const CString& brand_code, | |
| 66 const CString& client_id); | |
| 67 | |
| 68 // Writes branding information for apps in the registry if it does not | |
| 69 // already exist. Otherwise, the information remains unchanged. | |
| 70 // Writes a default Omaha-specific brand code if one is not specified in args. | |
| 71 HRESULT SetAppBranding(const CString& client_state_key_path, | |
| 72 const CString& brand_code, | |
| 73 const CString& client_id, | |
| 74 const CString& referral_id); | |
| 75 | |
| 76 // Updates the application state after a successful install or update. | |
| 77 void PersistSuccessfulInstall(const CString& client_state_key_path, | |
| 78 bool is_update, | |
| 79 bool is_offline); | |
| 80 | |
| 81 // Updates the application state after a successful update check event, which | |
| 82 // is either a "noupdate" response or a successful online update. | |
| 83 void PersistSuccessfulUpdateCheck(const CString& client_state_key_path); | |
| 84 | |
| 85 // Clears the stored information about update available events for the app. | |
| 86 // Call when an update has succeeded. | |
| 87 void ClearUpdateAvailableStats(const CString& client_state_key_path); | |
| 88 | |
| 89 // Returns the number of clients registered under the "Clients" sub key. | |
| 90 // Does not guarantee a consistent state. Caller should use appropriate locks if | |
| 91 // necessary. | |
| 92 HRESULT GetNumClients(bool is_machine, size_t* num_clients); | |
| 93 | |
| 94 // Reads app version from Clients key. | |
| 95 void GetAppVersion(bool is_machine, const CString& app_id, CString* pv); | |
| 96 | |
| 97 // Reads persistent data for an application. The parameters can be NULL to | |
| 98 // indicate that value is not required. | |
| 99 void GetClientStateData(bool is_machine, | |
| 100 const CString& app_id, | |
| 101 CString* pv, | |
| 102 CString* ap, | |
| 103 CString* lang, | |
| 104 CString* brand_code, | |
| 105 CString* client_id, | |
| 106 CString* iid, | |
| 107 CString* experiment_labels); | |
| 108 | |
| 109 // Reads all uninstalled apps from the registry. | |
| 110 HRESULT GetUninstalledApps(bool is_machine, std::vector<CString>* app_ids); | |
| 111 | |
| 112 // Removes the client state for the given app. | |
| 113 HRESULT RemoveClientState(bool is_machine, const CString& app_guid); | |
| 114 | |
| 115 // Removes the client state for the apps. | |
| 116 void RemoveClientStateForApps(bool is_machine, | |
| 117 const std::vector<CString>& apps); | |
| 118 | |
| 119 // Retrieves experiment labels for an app from the Registry. | |
| 120 HRESULT GetExperimentLabels(bool is_machine, const CString& app_id, | |
| 121 CString* labels_out); | |
| 122 | |
| 123 // Overwrites the experiment labels for an app in the Registry. | |
| 124 HRESULT SetExperimentLabels(bool is_machine, const CString& app_id, | |
| 125 const CString& new_labels); | |
| 126 | |
| 127 } // namespace app_registry_utils | |
| 128 | |
| 129 } // namespace omaha | |
| 130 | |
| 131 #endif // OMAHA_COMMON_APP_REGISTRY_UTILS_H_ | |
| OLD | NEW |