google_update_settings.h revision 4e180b6a0b4720a9b8e9e959a882386f690f08ff
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_INSTALLER_UTIL_GOOGLE_UPDATE_SETTINGS_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_INSTALLER_UTIL_GOOGLE_UPDATE_SETTINGS_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/basictypes.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/strings/string16.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/time/time.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/version.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/installer/util/util_constants.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BrowserDistribution; 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace installer { 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ChannelInfo; 205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class InstallationState; 21a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This class provides accessors to the Google Update 'ClientState' information 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// that recorded when the user downloads the chrome installer. It is 251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// google_update.exe responsibility to write the initial values. 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class GoogleUpdateSettings { 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Update policy constants defined by Google Update; do not change these. 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum UpdatePolicy { 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) UPDATES_DISABLED = 0, 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) AUTOMATIC_UPDATES = 1, 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) MANUAL_UPDATES_ONLY = 2, 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) AUTO_UPDATES_ONLY = 3, 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 36a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Defines product data that is tracked/used by Google Update. 37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) struct ProductData { 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The currently installed version. 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string version; 405f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // The time that Google Update last updated this product. (This means 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // either running an updater successfully, or doing an update check that 42a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // results in no update available.) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::Time last_success; 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The result reported by the most recent run of an installer/updater. 455f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) int last_result; 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The error code, if any, reported by the most recent run of an 47a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // installer or updater. This is typically platform independent. 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int last_error_code; 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The extra error code, if any, reported by the most recent run of 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // an installer or updater. This is typically an error code specific 515f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // to the platform -- i.e. on Windows, it will be a Win32 HRESULT. 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int last_extra_code; 53a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) }; 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if this install is system-wide, false if it is per-user. 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool IsSystemInstall(); 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns whether the user has given consent to collect UMA data and send 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // crash dumps to Google. This information is collected by the web server 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // used to download the chrome installer. 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool GetCollectStatsConsent(); 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets the user consent to send UMA and crash dumps to Google. Returns 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // false if the setting could not be recorded. 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool SetCollectStatsConsent(bool consented); 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns whether the user has given consent to collect UMA data and send 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // crash dumps to Google. This information is collected by the web server 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // used to download the chrome installer. 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool GetCollectStatsConsentAtLevel(bool system_install); 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets the user consent to send UMA and crash dumps to Google. Returns 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // false if the setting could not be recorded. 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool SetCollectStatsConsentAtLevel(bool system_install, 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool consented); 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the metrics id set in the registry (that can be used in crash 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // reports). If none found, returns empty string. 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool GetMetricsId(std::string* metrics_id); 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets the metrics id to be used in crash reports. 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool SetMetricsId(const std::string& metrics_id); 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // Sets the machine-wide EULA consented flag required on OEM installs. 8703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // Returns false if the setting could not be recorded. 885f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) static bool SetEULAConsent(const installer::InstallationState& machine_state, 895f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) BrowserDistribution* dist, 905f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) bool consented); 915f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 925f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Returns the last time chrome was run in days. It uses a recorded value 935f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // set by SetLastRunTime(). Returns -1 if the value was not found or if 945f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // the value is corrupted. 955f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) static int GetLastRunTime(); 965f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 975f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Stores the time that this function was last called using an encoded 985f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // form of the system local time. Retrieve the time using GetLastRunTime(). 995f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Returns false if the value could not be stored. 1005f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) static bool SetLastRunTime(); 1015f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 1025f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Removes the storage used by SetLastRunTime() and SetLastRunTime(). Returns 1035f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // false if the operation failed. Returns true if the storage was freed or 1045f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // if it never existed in the first place. 1055f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) static bool RemoveLastRunTime(); 1065f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 1075f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Returns in |browser| the browser used to download chrome as recorded 1085f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Google Update. Returns false if the information is not available. 1095f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) static bool GetBrowser(std::wstring* browser); 1105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 1115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Returns in |language| the language selected by the user when downloading 1125f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // chrome. This information is collected by the web server used to download 1135f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // the chrome installer. Returns false if the information is not available. 1145f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) static bool GetLanguage(std::wstring* language); 1155f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 1165f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // Returns in |brand| the RLZ brand code or distribution tag that has been 1175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // assigned to a partner. Returns false if the information is not available. 1185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTE: This function is Windows only. If the code you are writing is not 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // specifically for Windows, prefer calling google_util::GetBrand(). 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool GetBrand(std::wstring* brand); 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns in |brand| the RLZ reactivation brand code or distribution tag 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that has been assigned to a partner for reactivating a dormant chrome 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // install. Returns false if the information is not available. 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTE: This function is Windows only. If the code you are writing is not 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // specifically for Windows, prefer calling 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // google_util::GetReactivationBrand(). 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool GetReactivationBrand(std::wstring* brand); 1315f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns in |client| the google_update client field, which is currently 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // used to track experiments. Returns false if the entry does not exist. 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool GetClient(std::wstring* client); 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets the google_update client field. Unlike GetClient() this is set only 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // for the current user. Returns false if the operation failed. 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool SetClient(const std::wstring& client); 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns in 'client' the RLZ referral available for some distribution 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // partners. This value does not exist for most chrome or chromium installs. 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool GetReferral(std::wstring* referral); 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overwrites the current value of the referral with an empty string. Returns 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // true if this operation succeeded. 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool ClearReferral(); 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set did_run "dr" in the client state value. This is used to measure 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // active users. Returns false if writting to the registry failed. 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool UpdateDidRunState(bool did_run, bool system_level); 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set did_run "dr" in the client state value for |dist|. This is used to 1535f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // measure active users. Returns false if writting to the registry failed. 1545f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) static bool UpdateDidRunStateForDistribution(BrowserDistribution* dist, 1555f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) bool did_run, 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool system_level); 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns only the channel name: "" (stable), "dev", "beta", "canary", or 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // "unknown" if unknown. This value will not be modified by "-m" for a 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // multi-install. See kChromeChannel* in util_constants.h 1611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) static std::wstring GetChromeChannel(bool system_install); 1621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Return a human readable modifier for the version string, e.g. 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the channel (dev, beta, stable). Returns true if this operation succeeded, 1651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // on success, channel contains one of "", "unknown", "dev" or "beta" (unless 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // it is a multi-install product, in which case it will return "m", 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // "unknown-m", "dev-m", or "beta-m"). 168a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) static bool GetChromeChannelAndModifiers(bool system_install, 169a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) string16* channel); 170a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // This method changes the Google Update "ap" value to move the installation 1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // on to or off of one of the recovery channels. 1735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // - If incremental installer fails we append a magic string ("-full"), if 1741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // it is not present already, so that Google Update server next time will send 1751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // full installer to update Chrome on the local machine 1761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // - If we are currently running full installer, we remove this magic 1775f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // string (if it is present) regardless of whether installer failed or not. 1781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // There is no fall-back for full installer :) 1791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // - Unconditionally remove "-multifail" since we haven't crashed. 1801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // |state_key| should be obtained via InstallerState::state_key(). 1811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) static void UpdateInstallStatus(bool system_install, 1821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) installer::ArchiveType archive_type, 1831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int install_return_code, 1841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const std::wstring& product_guid); 1855f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 1865f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // This method updates the value for Google Update "ap" key for Chrome 1875f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // based on whether we are doing incremental install (or not) and whether 1885f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // the install succeeded. 1895f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // - If install worked, remove the magic string (if present). 1905f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) // - If incremental installer failed, append a magic string (if 1911e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // not present already). 192a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // - If full installer failed, still remove this magic 193a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // string (if it is present already). 194a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // 195a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // archive_type: tells whether this is incremental install or not. 196a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // install_return_code: if 0, means installation was successful. 197a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // value: current value of Google Update "ap" key. 198a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Returns true if |value| is modified. 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool UpdateGoogleUpdateApKey(installer::ArchiveType archive_type, 2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int install_return_code, 2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) installer::ChannelInfo* value); 2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // For system-level installs, we need to be able to communicate the results 2045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // of the Toast Experiments back to Google Update. The problem is just that 2055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // the experiment is run in the context of the user, which doesn't have 2065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // write access to the HKLM key that Google Update expects the results in. 207a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // However, when we are about to switch contexts from system to user, we can 208a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // duplicate the handle to the registry key and pass it (through handle 2095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // inheritance) to the newly created child process that is launched as the 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // user, allowing the child process to write to the key, with the 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // WriteGoogleUpdateSystemClientKey function below. 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static int DuplicateGoogleUpdateSystemClientKey(); 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Takes a |handle| to a registry key and writes |value| string into the 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // specified |key|. See DuplicateGoogleUpdateSystemClientKey for details. 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool WriteGoogleUpdateSystemClientKey(int handle, 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::wstring& key, 218a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const std::wstring& value); 219a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 2205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Returns the effective update policy for |app_guid| as dictated by 2215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Group Policy settings. |is_overridden|, if non-NULL, is populated with 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // true if an app-specific policy override is in force, or false otherwise. 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static UpdatePolicy GetAppUpdatePolicy(const std::wstring& app_guid, 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool* is_overridden); 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns Google Update's uninstall command line, or an empty string if none 227 // is found. 228 static string16 GetUninstallCommandLine(bool system_install); 229 230 // Returns the version of Google Update that is installed. 231 static Version GetGoogleUpdateVersion(bool system_install); 232 233 // Returns the time at which Google Update last started an automatic update 234 // check, or the null time if this information isn't available. 235 static base::Time GetGoogleUpdateLastStartedAU(bool system_install); 236 237 // Returns the time at which Google Update last successfully contacted Google 238 // servers and got a valid check response, or the null time if this 239 // information isn't available. 240 static base::Time GetGoogleUpdateLastChecked(bool system_install); 241 242 // Returns detailed update data for a product being managed by Google Update. 243 // Returns true if the |version| and |last_updated| fields in |data| 244 // are modified. The other items are considered optional. 245 static bool GetUpdateDetailForApp(bool system_install, 246 const wchar_t* app_guid, 247 ProductData* data); 248 249 // Returns product data for Google Update. (Equivalent to calling 250 // GetUpdateDetailForAppGuid with the app guid for Google Update itself.) 251 static bool GetUpdateDetailForGoogleUpdate(bool system_install, 252 ProductData* data); 253 254 // Returns product data for the current product. (Equivalent to calling 255 // GetUpdateDetailForApp with the app guid stored in BrowserDistribution.) 256 static bool GetUpdateDetail(bool system_install, ProductData* data); 257 258 // Sets |experiment_labels| as the Google Update experiment_labels value in 259 // the ClientState key for this Chrome product, if appropriate. If 260 // |experiment_labels| is empty, this will delete the value instead. This will 261 // return true if the label was successfully set (or deleted), false otherwise 262 // (even if the label does not need to be set for this particular distribution 263 // type). 264 static bool SetExperimentLabels(bool system_install, 265 const string16& experiment_labels); 266 267 // Reads the Google Update experiment_labels value in the ClientState key for 268 // this Chrome product and writes it into |experiment_labels|. If the key or 269 // value does not exist, |experiment_labels| will be set to the empty string. 270 // If this distribution of Chrome does not set the experiment_labels value, 271 // this will do nothing to |experiment_labels|. This will return true if the 272 // label did not exist, or was successfully read. 273 static bool ReadExperimentLabels(bool system_install, 274 string16* experiment_labels); 275 276 private: 277 DISALLOW_IMPLICIT_CONSTRUCTORS(GoogleUpdateSettings); 278}; 279 280#endif // CHROME_INSTALLER_UTIL_GOOGLE_UPDATE_SETTINGS_H_ 281