This source file includes following definitions.
- LocalizeUrl
- GetUninstallSurveyUrl
- product_guid_
- DoPostUninstallOperations
- GetActiveSetupGuid
- GetAppGuid
- GetBaseAppName
- GetShortcutName
- GetIconIndex
- GetBaseAppId
- GetBrowserProgIdPrefix
- GetBrowserProgIdDesc
- GetInstallSubDir
- GetPublisherName
- GetAppDescription
- GetSafeBrowsingName
- GetStateKey
- GetStateMediumKey
- GetNetworkStatsServer
- GetHttpPipeliningTestServer
- GetDistributionData
- GetUninstallLinkName
- GetUninstallRegPath
- GetVersionKey
- GetIconFilename
- GetCommandExecuteImplClsid
- AppHostIsSupported
- UpdateInstallStatus
- ShouldSetExperimentLabels
- HasUserExperiments
#include "chrome/installer/util/google_chrome_distribution.h"
#include <windows.h>
#include <msi.h>
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/registry.h"
#include "base/win/windows_version.h"
#include "chrome/common/chrome_icon_resources_win.h"
#include "chrome/common/net/test_server_locations.h"
#include "chrome/installer/util/channel_info.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/l10n_string_util.h"
#include "chrome/installer/util/uninstall_metrics.h"
#include "chrome/installer/util/util_constants.h"
#include "chrome/installer/util/wmi.h"
#include "content/public/common/result_codes.h"
#include "installer_util_strings.h"
namespace {
const wchar_t kChromeGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}";
const wchar_t kBrowserAppId[] = L"Chrome";
const wchar_t kBrowserProgIdPrefix[] = L"ChromeHTML";
const wchar_t kBrowserProgIdDesc[] = L"Chrome HTML Document";
const wchar_t kCommandExecuteImplUuid[] =
L"{5C65F4B0-3651-4514-B207-D10CB699B14B}";
base::string16 LocalizeUrl(const wchar_t* url) {
base::string16 language;
if (!GoogleUpdateSettings::GetLanguage(&language))
language = L"en-US";
return ReplaceStringPlaceholders(url, language.c_str(), NULL);
}
base::string16 GetUninstallSurveyUrl() {
const wchar_t kSurveyUrl[] = L"http://www.google.com/support/chrome/bin/"
L"request.py?hl=$1&contact_type=uninstall";
return LocalizeUrl(kSurveyUrl);
}
}
GoogleChromeDistribution::GoogleChromeDistribution()
: BrowserDistribution(CHROME_BROWSER),
product_guid_(kChromeGuid) {
}
void GoogleChromeDistribution::DoPostUninstallOperations(
const Version& version,
const base::FilePath& local_data_path,
const base::string16& distribution_data) {
const base::string16 kVersionParam = L"crversion";
const base::string16 kOSParam = L"os";
base::win::OSInfo::VersionNumber version_number =
base::win::OSInfo::GetInstance()->version_number();
base::string16 os_version = base::StringPrintf(L"%d.%d.%d",
version_number.major, version_number.minor, version_number.build);
base::FilePath iexplore;
if (!PathService::Get(base::DIR_PROGRAM_FILES, &iexplore))
return;
iexplore = iexplore.AppendASCII("Internet Explorer");
iexplore = iexplore.AppendASCII("iexplore.exe");
base::string16 command = iexplore.value() + L" " + GetUninstallSurveyUrl() +
L"&" + kVersionParam + L"=" + base::UTF8ToWide(version.GetString()) +
L"&" + kOSParam + L"=" + os_version;
base::string16 uninstall_metrics;
if (installer::ExtractUninstallMetricsFromFile(local_data_path,
&uninstall_metrics)) {
command += uninstall_metrics;
if (!distribution_data.empty()) {
command += L"&";
command += distribution_data;
}
}
int pid = 0;
installer::WMIProcess::Launch(command, &pid);
}
base::string16 GoogleChromeDistribution::GetActiveSetupGuid() {
return product_guid();
}
base::string16 GoogleChromeDistribution::GetAppGuid() {
return product_guid();
}
base::string16 GoogleChromeDistribution::GetBaseAppName() {
return L"Google Chrome";
}
base::string16 GoogleChromeDistribution::GetShortcutName(
ShortcutType shortcut_type) {
int string_id = IDS_PRODUCT_NAME_BASE;
switch (shortcut_type) {
case SHORTCUT_CHROME_ALTERNATE:
string_id = IDS_OEM_MAIN_SHORTCUT_NAME_BASE;
break;
case SHORTCUT_APP_LAUNCHER:
string_id = IDS_APP_LIST_SHORTCUT_NAME_BASE;
break;
default:
DCHECK_EQ(shortcut_type, SHORTCUT_CHROME);
break;
}
return installer::GetLocalizedString(string_id);
}
int GoogleChromeDistribution::GetIconIndex(ShortcutType shortcut_type) {
if (shortcut_type == SHORTCUT_APP_LAUNCHER)
return icon_resources::kAppLauncherIndex;
DCHECK(shortcut_type == SHORTCUT_CHROME ||
shortcut_type == SHORTCUT_CHROME_ALTERNATE) << shortcut_type;
return icon_resources::kApplicationIndex;
}
base::string16 GoogleChromeDistribution::GetBaseAppId() {
return kBrowserAppId;
}
base::string16 GoogleChromeDistribution::GetBrowserProgIdPrefix() {
return kBrowserProgIdPrefix;
}
base::string16 GoogleChromeDistribution::GetBrowserProgIdDesc() {
return kBrowserProgIdDesc;
}
base::string16 GoogleChromeDistribution::GetInstallSubDir() {
base::string16 sub_dir(installer::kGoogleChromeInstallSubDir1);
sub_dir.append(L"\\");
sub_dir.append(installer::kGoogleChromeInstallSubDir2);
return sub_dir;
}
base::string16 GoogleChromeDistribution::GetPublisherName() {
const base::string16& publisher_name =
installer::GetLocalizedString(IDS_ABOUT_VERSION_COMPANY_NAME_BASE);
return publisher_name;
}
base::string16 GoogleChromeDistribution::GetAppDescription() {
const base::string16& app_description =
installer::GetLocalizedString(IDS_SHORTCUT_TOOLTIP_BASE);
return app_description;
}
std::string GoogleChromeDistribution::GetSafeBrowsingName() {
return "googlechrome";
}
base::string16 GoogleChromeDistribution::GetStateKey() {
base::string16 key(google_update::kRegPathClientState);
key.append(L"\\");
key.append(product_guid());
return key;
}
base::string16 GoogleChromeDistribution::GetStateMediumKey() {
base::string16 key(google_update::kRegPathClientStateMedium);
key.append(L"\\");
key.append(product_guid());
return key;
}
std::string GoogleChromeDistribution::GetNetworkStatsServer() const {
return chrome_common_net::kEchoTestServerLocation;
}
std::string GoogleChromeDistribution::GetHttpPipeliningTestServer() const {
return chrome_common_net::kPipelineTestServerBaseUrl;
}
base::string16 GoogleChromeDistribution::GetDistributionData(HKEY root_key) {
base::string16 sub_key(google_update::kRegPathClientState);
sub_key.append(L"\\");
sub_key.append(product_guid());
base::win::RegKey client_state_key(root_key, sub_key.c_str(), KEY_READ);
base::string16 result;
base::string16 brand_value;
if (client_state_key.ReadValue(google_update::kRegRLZBrandField,
&brand_value) == ERROR_SUCCESS) {
result = google_update::kRegRLZBrandField;
result.append(L"=");
result.append(brand_value);
result.append(L"&");
}
base::string16 client_value;
if (client_state_key.ReadValue(google_update::kRegClientField,
&client_value) == ERROR_SUCCESS) {
result.append(google_update::kRegClientField);
result.append(L"=");
result.append(client_value);
result.append(L"&");
}
base::string16 ap_value;
client_state_key.ReadValue(google_update::kRegApField, &ap_value);
result.append(google_update::kRegApField);
result.append(L"=");
result.append(ap_value);
return result;
}
base::string16 GoogleChromeDistribution::GetUninstallLinkName() {
const base::string16& link_name =
installer::GetLocalizedString(IDS_UNINSTALL_CHROME_BASE);
return link_name;
}
base::string16 GoogleChromeDistribution::GetUninstallRegPath() {
return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"
L"Google Chrome";
}
base::string16 GoogleChromeDistribution::GetVersionKey() {
base::string16 key(google_update::kRegPathClients);
key.append(L"\\");
key.append(product_guid());
return key;
}
base::string16 GoogleChromeDistribution::GetIconFilename() {
return installer::kChromeExe;
}
bool GoogleChromeDistribution::GetCommandExecuteImplClsid(
base::string16* handler_class_uuid) {
if (handler_class_uuid)
*handler_class_uuid = kCommandExecuteImplUuid;
return true;
}
bool GoogleChromeDistribution::AppHostIsSupported() {
return true;
}
void GoogleChromeDistribution::UpdateInstallStatus(bool system_install,
installer::ArchiveType archive_type,
installer::InstallStatus install_status) {
GoogleUpdateSettings::UpdateInstallStatus(system_install,
archive_type, InstallUtil::GetInstallReturnCode(install_status),
product_guid());
}
bool GoogleChromeDistribution::ShouldSetExperimentLabels() {
return true;
}
bool GoogleChromeDistribution::HasUserExperiments() {
return true;
}