| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This file defines specific implementation of BrowserDistribution class for | 5 // This file defines specific implementation of BrowserDistribution class for |
| 6 // Google Chrome. | 6 // Google Chrome. |
| 7 | 7 |
| 8 #include "chrome/installer/util/google_chrome_distribution.h" | 8 #include "chrome/installer/util/google_chrome_distribution.h" |
| 9 | 9 |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 293 |
| 294 bool GoogleChromeDistribution::BuildUninstallMetricsString( | 294 bool GoogleChromeDistribution::BuildUninstallMetricsString( |
| 295 const DictionaryValue* uninstall_metrics_dict, string16* metrics) { | 295 const DictionaryValue* uninstall_metrics_dict, string16* metrics) { |
| 296 DCHECK(NULL != metrics); | 296 DCHECK(NULL != metrics); |
| 297 bool has_values = false; | 297 bool has_values = false; |
| 298 | 298 |
| 299 for (DictionaryValue::Iterator iter(*uninstall_metrics_dict); !iter.IsAtEnd(); | 299 for (DictionaryValue::Iterator iter(*uninstall_metrics_dict); !iter.IsAtEnd(); |
| 300 iter.Advance()) { | 300 iter.Advance()) { |
| 301 has_values = true; | 301 has_values = true; |
| 302 metrics->append(L"&"); | 302 metrics->append(L"&"); |
| 303 metrics->append(base::UTF8ToWide(iter.key())); | 303 metrics->append(UTF8ToWide(iter.key())); |
| 304 metrics->append(L"="); | 304 metrics->append(L"="); |
| 305 | 305 |
| 306 std::string value; | 306 std::string value; |
| 307 iter.value().GetAsString(&value); | 307 iter.value().GetAsString(&value); |
| 308 metrics->append(base::UTF8ToWide(value)); | 308 metrics->append(UTF8ToWide(value)); |
| 309 } | 309 } |
| 310 | 310 |
| 311 return has_values; | 311 return has_values; |
| 312 } | 312 } |
| 313 | 313 |
| 314 bool GoogleChromeDistribution::ExtractUninstallMetricsFromFile( | 314 bool GoogleChromeDistribution::ExtractUninstallMetricsFromFile( |
| 315 const base::FilePath& file_path, | 315 const base::FilePath& file_path, |
| 316 string16* uninstall_metrics_string) { | 316 string16* uninstall_metrics_string) { |
| 317 JSONFileValueSerializer json_serializer(file_path); | 317 JSONFileValueSerializer json_serializer(file_path); |
| 318 | 318 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 version_number.major, version_number.minor, version_number.build); | 375 version_number.major, version_number.minor, version_number.build); |
| 376 | 376 |
| 377 base::FilePath iexplore; | 377 base::FilePath iexplore; |
| 378 if (!PathService::Get(base::DIR_PROGRAM_FILES, &iexplore)) | 378 if (!PathService::Get(base::DIR_PROGRAM_FILES, &iexplore)) |
| 379 return; | 379 return; |
| 380 | 380 |
| 381 iexplore = iexplore.AppendASCII("Internet Explorer"); | 381 iexplore = iexplore.AppendASCII("Internet Explorer"); |
| 382 iexplore = iexplore.AppendASCII("iexplore.exe"); | 382 iexplore = iexplore.AppendASCII("iexplore.exe"); |
| 383 | 383 |
| 384 string16 command = iexplore.value() + L" " + GetUninstallSurveyUrl() + | 384 string16 command = iexplore.value() + L" " + GetUninstallSurveyUrl() + |
| 385 L"&" + kVersionParam + L"=" + | 385 L"&" + kVersionParam + L"=" + UTF8ToWide(version.GetString()) + L"&" + |
| 386 base::UTF8ToWide(version.GetString()) + L"&" + | |
| 387 kOSParam + L"=" + os_version; | 386 kOSParam + L"=" + os_version; |
| 388 | 387 |
| 389 string16 uninstall_metrics; | 388 string16 uninstall_metrics; |
| 390 if (ExtractUninstallMetricsFromFile(local_data_path, &uninstall_metrics)) { | 389 if (ExtractUninstallMetricsFromFile(local_data_path, &uninstall_metrics)) { |
| 391 // The user has opted into anonymous usage data collection, so append | 390 // The user has opted into anonymous usage data collection, so append |
| 392 // metrics and distribution data. | 391 // metrics and distribution data. |
| 393 command += uninstall_metrics; | 392 command += uninstall_metrics; |
| 394 if (!distribution_data.empty()) { | 393 if (!distribution_data.empty()) { |
| 395 command += L"&"; | 394 command += L"&"; |
| 396 command += distribution_data; | 395 command += distribution_data; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 { { IDS_TRY_TOAST_HEADING3, kMakeDefault }, | 653 { { IDS_TRY_TOAST_HEADING3, kMakeDefault }, |
| 655 { 0, 0 }, | 654 { 0, 0 }, |
| 656 { 0, 0 }, | 655 { 0, 0 }, |
| 657 { 0, 0 } | 656 { 0, 0 } |
| 658 } | 657 } |
| 659 } | 658 } |
| 660 }; | 659 }; |
| 661 | 660 |
| 662 string16 locale; | 661 string16 locale; |
| 663 GoogleUpdateSettings::GetLanguage(&locale); | 662 GoogleUpdateSettings::GetLanguage(&locale); |
| 664 if (locale.empty() || (locale == base::ASCIIToWide("en"))) | 663 if (locale.empty() || (locale == ASCIIToWide("en"))) |
| 665 locale = base::ASCIIToWide("en-US"); | 664 locale = ASCIIToWide("en-US"); |
| 666 | 665 |
| 667 string16 brand; | 666 string16 brand; |
| 668 if (!GoogleUpdateSettings::GetBrand(&brand)) { | 667 if (!GoogleUpdateSettings::GetBrand(&brand)) |
| 669 // Could still be viable for catch-all rules. | 668 brand = ASCIIToWide(""); // Could still be viable for catch-all rules. |
| 670 brand = base::ASCIIToWide(""); | |
| 671 } | |
| 672 | 669 |
| 673 for (int i = 0; i < arraysize(kExperiments); ++i) { | 670 for (int i = 0; i < arraysize(kExperiments); ++i) { |
| 674 if (kExperiments[i].locale != locale && | 671 if (kExperiments[i].locale != locale && |
| 675 kExperiments[i].locale != base::ASCIIToWide("*")) | 672 kExperiments[i].locale != ASCIIToWide("*")) |
| 676 continue; | 673 continue; |
| 677 | 674 |
| 678 std::vector<string16> brand_codes; | 675 std::vector<string16> brand_codes; |
| 679 base::SplitString(kExperiments[i].brands, L',', &brand_codes); | 676 base::SplitString(kExperiments[i].brands, L',', &brand_codes); |
| 680 if (brand_codes.empty()) | 677 if (brand_codes.empty()) |
| 681 return false; | 678 return false; |
| 682 for (std::vector<string16>::iterator it = brand_codes.begin(); | 679 for (std::vector<string16>::iterator it = brand_codes.begin(); |
| 683 it != brand_codes.end(); ++it) { | 680 it != brand_codes.end(); ++it) { |
| 684 if (*it != brand && *it != L"*") | 681 if (*it != brand && *it != L"*") |
| 685 continue; | 682 continue; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 VLOG(1) << "User drafted for toast experiment " << flavor; | 801 VLOG(1) << "User drafted for toast experiment " << flavor; |
| 805 SetClient(base_group + kToastExpBaseGroup, false); | 802 SetClient(base_group + kToastExpBaseGroup, false); |
| 806 // User level: The experiment needs to be performed in a different process | 803 // User level: The experiment needs to be performed in a different process |
| 807 // because google_update expects the upgrade process to be quick and nimble. | 804 // because google_update expects the upgrade process to be quick and nimble. |
| 808 // System level: We have already been relaunched, so we don't need to be | 805 // System level: We have already been relaunched, so we don't need to be |
| 809 // quick, but we relaunch to follow the exact same codepath. | 806 // quick, but we relaunch to follow the exact same codepath. |
| 810 CommandLine cmd_line(setup_path); | 807 CommandLine cmd_line(setup_path); |
| 811 cmd_line.AppendSwitchASCII(installer::switches::kInactiveUserToast, | 808 cmd_line.AppendSwitchASCII(installer::switches::kInactiveUserToast, |
| 812 base::IntToString(flavor)); | 809 base::IntToString(flavor)); |
| 813 cmd_line.AppendSwitchASCII(installer::switches::kExperimentGroup, | 810 cmd_line.AppendSwitchASCII(installer::switches::kExperimentGroup, |
| 814 base::WideToASCII(base_group)); | 811 WideToASCII(base_group)); |
| 815 LaunchSetup(&cmd_line, product, system_level); | 812 LaunchSetup(&cmd_line, product, system_level); |
| 816 } | 813 } |
| 817 | 814 |
| 818 // User qualifies for the experiment. To test, use --try-chrome-again=|flavor| | 815 // User qualifies for the experiment. To test, use --try-chrome-again=|flavor| |
| 819 // as a parameter to chrome.exe. | 816 // as a parameter to chrome.exe. |
| 820 void GoogleChromeDistribution::InactiveUserToastExperiment(int flavor, | 817 void GoogleChromeDistribution::InactiveUserToastExperiment(int flavor, |
| 821 const string16& experiment_group, | 818 const string16& experiment_group, |
| 822 const installer::Product& installation, | 819 const installer::Product& installation, |
| 823 const base::FilePath& application_path) { | 820 const base::FilePath& application_path) { |
| 824 // Add the 'welcome back' url for chrome to show. | 821 // Add the 'welcome back' url for chrome to show. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 installer::switches::kSystemLevelToast); | 863 installer::switches::kSystemLevelToast); |
| 867 | 864 |
| 868 CommandLine cmd(InstallUtil::GetChromeUninstallCmd(system_level_toast, | 865 CommandLine cmd(InstallUtil::GetChromeUninstallCmd(system_level_toast, |
| 869 GetType())); | 866 GetType())); |
| 870 base::LaunchProcess(cmd, base::LaunchOptions(), NULL); | 867 base::LaunchProcess(cmd, base::LaunchOptions(), NULL); |
| 871 } | 868 } |
| 872 | 869 |
| 873 bool GoogleChromeDistribution::ShouldSetExperimentLabels() { | 870 bool GoogleChromeDistribution::ShouldSetExperimentLabels() { |
| 874 return true; | 871 return true; |
| 875 } | 872 } |
| OLD | NEW |