Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: chrome/installer/util/google_chrome_distribution.cc

Issue 12314090: Add utf_string_conversions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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(UTF8ToWide(iter.key())); 303 metrics->append(base::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(UTF8ToWide(value)); 308 metrics->append(base::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
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"=" + UTF8ToWide(version.GetString()) + L"&" + 385 L"&" + kVersionParam + L"=" +
386 base::UTF8ToWide(version.GetString()) + L"&" +
386 kOSParam + L"=" + os_version; 387 kOSParam + L"=" + os_version;
387 388
388 string16 uninstall_metrics; 389 string16 uninstall_metrics;
389 if (ExtractUninstallMetricsFromFile(local_data_path, &uninstall_metrics)) { 390 if (ExtractUninstallMetricsFromFile(local_data_path, &uninstall_metrics)) {
390 // The user has opted into anonymous usage data collection, so append 391 // The user has opted into anonymous usage data collection, so append
391 // metrics and distribution data. 392 // metrics and distribution data.
392 command += uninstall_metrics; 393 command += uninstall_metrics;
393 if (!distribution_data.empty()) { 394 if (!distribution_data.empty()) {
394 command += L"&"; 395 command += L"&";
395 command += distribution_data; 396 command += distribution_data;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 { { IDS_TRY_TOAST_HEADING3, kMakeDefault }, 654 { { IDS_TRY_TOAST_HEADING3, kMakeDefault },
654 { 0, 0 }, 655 { 0, 0 },
655 { 0, 0 }, 656 { 0, 0 },
656 { 0, 0 } 657 { 0, 0 }
657 } 658 }
658 } 659 }
659 }; 660 };
660 661
661 string16 locale; 662 string16 locale;
662 GoogleUpdateSettings::GetLanguage(&locale); 663 GoogleUpdateSettings::GetLanguage(&locale);
663 if (locale.empty() || (locale == ASCIIToWide("en"))) 664 if (locale.empty() || (locale == base::ASCIIToWide("en")))
664 locale = ASCIIToWide("en-US"); 665 locale = base::ASCIIToWide("en-US");
665 666
666 string16 brand; 667 string16 brand;
667 if (!GoogleUpdateSettings::GetBrand(&brand)) 668 if (!GoogleUpdateSettings::GetBrand(&brand)) {
668 brand = ASCIIToWide(""); // Could still be viable for catch-all rules. 669 // Could still be viable for catch-all rules.
670 brand = base::ASCIIToWide("");
671 }
669 672
670 for (int i = 0; i < arraysize(kExperiments); ++i) { 673 for (int i = 0; i < arraysize(kExperiments); ++i) {
671 if (kExperiments[i].locale != locale && 674 if (kExperiments[i].locale != locale &&
672 kExperiments[i].locale != ASCIIToWide("*")) 675 kExperiments[i].locale != base::ASCIIToWide("*"))
673 continue; 676 continue;
674 677
675 std::vector<string16> brand_codes; 678 std::vector<string16> brand_codes;
676 base::SplitString(kExperiments[i].brands, L',', &brand_codes); 679 base::SplitString(kExperiments[i].brands, L',', &brand_codes);
677 if (brand_codes.empty()) 680 if (brand_codes.empty())
678 return false; 681 return false;
679 for (std::vector<string16>::iterator it = brand_codes.begin(); 682 for (std::vector<string16>::iterator it = brand_codes.begin();
680 it != brand_codes.end(); ++it) { 683 it != brand_codes.end(); ++it) {
681 if (*it != brand && *it != L"*") 684 if (*it != brand && *it != L"*")
682 continue; 685 continue;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 VLOG(1) << "User drafted for toast experiment " << flavor; 804 VLOG(1) << "User drafted for toast experiment " << flavor;
802 SetClient(base_group + kToastExpBaseGroup, false); 805 SetClient(base_group + kToastExpBaseGroup, false);
803 // User level: The experiment needs to be performed in a different process 806 // User level: The experiment needs to be performed in a different process
804 // because google_update expects the upgrade process to be quick and nimble. 807 // because google_update expects the upgrade process to be quick and nimble.
805 // System level: We have already been relaunched, so we don't need to be 808 // System level: We have already been relaunched, so we don't need to be
806 // quick, but we relaunch to follow the exact same codepath. 809 // quick, but we relaunch to follow the exact same codepath.
807 CommandLine cmd_line(setup_path); 810 CommandLine cmd_line(setup_path);
808 cmd_line.AppendSwitchASCII(installer::switches::kInactiveUserToast, 811 cmd_line.AppendSwitchASCII(installer::switches::kInactiveUserToast,
809 base::IntToString(flavor)); 812 base::IntToString(flavor));
810 cmd_line.AppendSwitchASCII(installer::switches::kExperimentGroup, 813 cmd_line.AppendSwitchASCII(installer::switches::kExperimentGroup,
811 WideToASCII(base_group)); 814 base::WideToASCII(base_group));
812 LaunchSetup(&cmd_line, product, system_level); 815 LaunchSetup(&cmd_line, product, system_level);
813 } 816 }
814 817
815 // User qualifies for the experiment. To test, use --try-chrome-again=|flavor| 818 // User qualifies for the experiment. To test, use --try-chrome-again=|flavor|
816 // as a parameter to chrome.exe. 819 // as a parameter to chrome.exe.
817 void GoogleChromeDistribution::InactiveUserToastExperiment(int flavor, 820 void GoogleChromeDistribution::InactiveUserToastExperiment(int flavor,
818 const string16& experiment_group, 821 const string16& experiment_group,
819 const installer::Product& installation, 822 const installer::Product& installation,
820 const base::FilePath& application_path) { 823 const base::FilePath& application_path) {
821 // Add the 'welcome back' url for chrome to show. 824 // Add the 'welcome back' url for chrome to show.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 installer::switches::kSystemLevelToast); 866 installer::switches::kSystemLevelToast);
864 867
865 CommandLine cmd(InstallUtil::GetChromeUninstallCmd(system_level_toast, 868 CommandLine cmd(InstallUtil::GetChromeUninstallCmd(system_level_toast,
866 GetType())); 869 GetType()));
867 base::LaunchProcess(cmd, base::LaunchOptions(), NULL); 870 base::LaunchProcess(cmd, base::LaunchOptions(), NULL);
868 } 871 }
869 872
870 bool GoogleChromeDistribution::ShouldSetExperimentLabels() { 873 bool GoogleChromeDistribution::ShouldSetExperimentLabels() {
871 return true; 874 return true;
872 } 875 }
OLDNEW
« no previous file with comments | « chrome/installer/util/auto_launch_util.cc ('k') | chrome/installer/util/google_update_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698