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

Side by Side Diff: chrome/installer/setup/install.cc

Issue 159618: Use alternate icon for Chrome shortcuts if specified in master preferences. (Closed)
Patch Set: fix merge errors Created 11 years, 4 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
« no previous file with comments | « chrome/installer/setup/install.h ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include <shlobj.h> 5 #include <shlobj.h>
6 #include <time.h> 6 #include <time.h>
7 7
8 #include "chrome/installer/setup/install.h" 8 #include "chrome/installer/setup/install.h"
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 struct tm timeinfo = {0}; 135 struct tm timeinfo = {0};
136 localtime_s(&timeinfo, &rawtime); 136 localtime_s(&timeinfo, &rawtime);
137 wchar_t buffer[9]; 137 wchar_t buffer[9];
138 if (wcsftime(buffer, 9, L"%Y%m%d", &timeinfo) == 8) { 138 if (wcsftime(buffer, 9, L"%Y%m%d", &timeinfo) == 8) {
139 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 139 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
140 L"InstallDate", 140 L"InstallDate",
141 buffer, false); 141 buffer, false);
142 } 142 }
143 } 143 }
144 144
145 // Copy master preferences file provided to installer, in the same folder
146 // as chrome.exe so Chrome first run can find it. This function will be called
147 // only on the first install of Chrome.
148 void CopyPreferenceFileForFirstRun(bool system_level,
149 const std::wstring& prefs_source_path) {
150 std::wstring prefs_dest_path(
151 installer::GetChromeInstallPath(system_level));
152 file_util::AppendToPath(&prefs_dest_path,
153 installer_util::kDefaultMasterPrefs);
154 if (!file_util::CopyFile(prefs_source_path, prefs_dest_path))
155 LOG(ERROR) << "failed copying master profile";
156 }
157
145 // This method creates Chrome shortcuts in Start->Programs for all users or 158 // This method creates Chrome shortcuts in Start->Programs for all users or
146 // only for current user depending on whether it is system wide install or 159 // only for current user depending on whether it is system wide install or
147 // user only install. 160 // user only install.
148 // 161 //
149 // If first_install is true, it creates shortcuts for launching and 162 // If first_install is true, it creates shortcuts for launching and
150 // uninstalling chrome. 163 // uninstalling chrome.
151 // If first_install is false, the function only updates the shortcut for 164 // If first_install is false, the function only updates the shortcut for
152 // uninstalling chrome. According to 165 // uninstalling chrome. According to
153 // http://blogs.msdn.com/oldnewthing/archive/2005/11/24/496690.aspx, 166 // http://blogs.msdn.com/oldnewthing/archive/2005/11/24/496690.aspx,
154 // updating uninstall shortcut should not trigger Windows "new application 167 // updating uninstall shortcut should not trigger Windows "new application
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 if (!success) { 486 if (!success) {
474 LOG(ERROR) << "Install failed, rolling back... "; 487 LOG(ERROR) << "Install failed, rolling back... ";
475 install_list->Rollback(); 488 install_list->Rollback();
476 LOG(ERROR) << "Rollback complete. "; 489 LOG(ERROR) << "Rollback complete. ";
477 } 490 }
478 return success; 491 return success;
479 } 492 }
480 493
481 installer_util::InstallStatus installer::InstallOrUpdateChrome( 494 installer_util::InstallStatus installer::InstallOrUpdateChrome(
482 const std::wstring& exe_path, const std::wstring& archive_path, 495 const std::wstring& exe_path, const std::wstring& archive_path,
483 const std::wstring& install_temp_path, const DictionaryValue* prefs, 496 const std::wstring& install_temp_path, const std::wstring& prefs_path,
484 const Version& new_version, const Version* installed_version) { 497 const DictionaryValue* prefs, const Version& new_version,
498 const Version* installed_version) {
485 bool system_install = installer_util::GetDistroBooleanPreference(prefs, 499 bool system_install = installer_util::GetDistroBooleanPreference(prefs,
486 installer_util::master_preferences::kSystemLevel); 500 installer_util::master_preferences::kSystemLevel);
487 std::wstring install_path(GetChromeInstallPath(system_install)); 501 std::wstring install_path(GetChromeInstallPath(system_install));
488 if (install_path.empty()) { 502 if (install_path.empty()) {
489 LOG(ERROR) << "Could not get installation destination path."; 503 LOG(ERROR) << "Could not get installation destination path.";
490 return installer_util::INSTALL_FAILED; 504 return installer_util::INSTALL_FAILED;
491 } else { 505 } else {
492 LOG(INFO) << "install destination path: " << install_path; 506 LOG(INFO) << "install destination path: " << install_path;
493 } 507 }
494 508
495 std::wstring src_path(install_temp_path); 509 std::wstring src_path(install_temp_path);
496 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceDir)); 510 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceDir));
497 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceChromeDir)); 511 file_util::AppendToPath(&src_path, std::wstring(kInstallSourceChromeDir));
498 512
499 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 513 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
500 bool install_success = InstallNewVersion(exe_path, archive_path, src_path, 514 bool install_success = InstallNewVersion(exe_path, archive_path, src_path,
501 install_path, install_temp_path, reg_root, new_version); 515 install_path, install_temp_path, reg_root, new_version);
502 516
503 installer_util::InstallStatus result; 517 installer_util::InstallStatus result;
504 if (!install_success) { 518 if (!install_success) {
505 LOG(ERROR) << "Install failed."; 519 LOG(ERROR) << "Install failed.";
506 result = installer_util::INSTALL_FAILED; 520 result = installer_util::INSTALL_FAILED;
507 } else { 521 } else {
508 if (!installed_version) { 522 if (!installed_version) {
509 LOG(INFO) << "First install of version " << new_version.GetString(); 523 LOG(INFO) << "First install of version " << new_version.GetString();
510 result = installer_util::FIRST_INSTALL_SUCCESS; 524 result = installer_util::FIRST_INSTALL_SUCCESS;
525 CopyPreferenceFileForFirstRun(system_install, prefs_path);
511 } else if (new_version.GetString() == installed_version->GetString()) { 526 } else if (new_version.GetString() == installed_version->GetString()) {
512 LOG(INFO) << "Install repaired of version " << new_version.GetString(); 527 LOG(INFO) << "Install repaired of version " << new_version.GetString();
513 result = installer_util::INSTALL_REPAIRED; 528 result = installer_util::INSTALL_REPAIRED;
514 } else if (new_version.IsHigherThan(installed_version)) { 529 } else if (new_version.IsHigherThan(installed_version)) {
515 LOG(INFO) << "Version updated to " << new_version.GetString(); 530 LOG(INFO) << "Version updated to " << new_version.GetString();
516 result = installer_util::NEW_VERSION_UPDATED; 531 result = installer_util::NEW_VERSION_UPDATED;
517 } else { 532 } else {
518 LOG(ERROR) << "Not sure how we got here." 533 LOG(ERROR) << "Not sure how we got here."
519 << " New version: " << new_version.GetString() 534 << " New version: " << new_version.GetString()
520 << ", installed version: " << installed_version->GetString(); 535 << ", installed version: " << installed_version->GetString();
(...skipping 24 matching lines...) Expand all
545 } 560 }
546 561
547 std::wstring installer::GetInstallerPathUnderChrome( 562 std::wstring installer::GetInstallerPathUnderChrome(
548 const std::wstring& install_path, const std::wstring& new_version) { 563 const std::wstring& install_path, const std::wstring& new_version) {
549 std::wstring installer_path(install_path); 564 std::wstring installer_path(install_path);
550 file_util::AppendToPath(&installer_path, new_version); 565 file_util::AppendToPath(&installer_path, new_version);
551 file_util::AppendToPath(&installer_path, installer_util::kInstallerDir); 566 file_util::AppendToPath(&installer_path, installer_util::kInstallerDir);
552 return installer_path; 567 return installer_path;
553 } 568 }
554 569
OLDNEW
« no previous file with comments | « chrome/installer/setup/install.h ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698