| 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 #include "chrome/installer/setup/install.h" | 5 #include "chrome/installer/setup/install.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 const ShellUtil::ShortcutProperties& properties, | 124 const ShellUtil::ShortcutProperties& properties, |
| 125 ShellUtil::ShortcutOperation operation) { | 125 ShellUtil::ShortcutOperation operation) { |
| 126 LogShortcutOperation(location, dist, properties, operation, false); | 126 LogShortcutOperation(location, dist, properties, operation, false); |
| 127 if (!ShellUtil::CreateOrUpdateShortcut(location, dist, properties, | 127 if (!ShellUtil::CreateOrUpdateShortcut(location, dist, properties, |
| 128 operation)) { | 128 operation)) { |
| 129 LogShortcutOperation(location, dist, properties, operation, true); | 129 LogShortcutOperation(location, dist, properties, operation, true); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 void AddChromeToMediaPlayerList() { | 133 void AddChromeToMediaPlayerList() { |
| 134 string16 reg_path(installer::kMediaPlayerRegPath); | 134 base::string16 reg_path(installer::kMediaPlayerRegPath); |
| 135 // registry paths can also be appended like file system path | 135 // registry paths can also be appended like file system path |
| 136 reg_path.push_back(base::FilePath::kSeparators[0]); | 136 reg_path.push_back(base::FilePath::kSeparators[0]); |
| 137 reg_path.append(installer::kChromeExe); | 137 reg_path.append(installer::kChromeExe); |
| 138 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; | 138 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; |
| 139 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( | 139 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( |
| 140 HKEY_LOCAL_MACHINE, reg_path)); | 140 HKEY_LOCAL_MACHINE, reg_path)); |
| 141 | 141 |
| 142 // if the operation fails we log the error but still continue | 142 // if the operation fails we log the error but still continue |
| 143 if (!work_item.get()->Do()) | 143 if (!work_item.get()->Do()) |
| 144 LOG(ERROR) << "Could not add Chrome to media player inclusion list."; | 144 LOG(ERROR) << "Could not add Chrome to media player inclusion list."; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 if (!app_launcher_exists) | 290 if (!app_launcher_exists) |
| 291 return installer::INSTALL_SHORTCUT_CREATE_ALL; | 291 return installer::INSTALL_SHORTCUT_CREATE_ALL; |
| 292 | 292 |
| 293 return installer::INSTALL_SHORTCUT_REPLACE_EXISTING; | 293 return installer::INSTALL_SHORTCUT_REPLACE_EXISTING; |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // end namespace | 296 } // end namespace |
| 297 | 297 |
| 298 namespace installer { | 298 namespace installer { |
| 299 | 299 |
| 300 void EscapeXmlAttributeValueInSingleQuotes(string16* att_value) { | 300 void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value) { |
| 301 base::ReplaceChars(*att_value, L"&", L"&", att_value); | 301 base::ReplaceChars(*att_value, L"&", L"&", att_value); |
| 302 base::ReplaceChars(*att_value, L"'", L"'", att_value); | 302 base::ReplaceChars(*att_value, L"'", L"'", att_value); |
| 303 base::ReplaceChars(*att_value, L"<", L"<", att_value); | 303 base::ReplaceChars(*att_value, L"<", L"<", att_value); |
| 304 } | 304 } |
| 305 | 305 |
| 306 bool CreateVisualElementsManifest(const base::FilePath& src_path, | 306 bool CreateVisualElementsManifest(const base::FilePath& src_path, |
| 307 const Version& version) { | 307 const Version& version) { |
| 308 // Construct the relative path to the versioned VisualElements directory. | 308 // Construct the relative path to the versioned VisualElements directory. |
| 309 string16 elements_dir(ASCIIToUTF16(version.GetString())); | 309 base::string16 elements_dir(ASCIIToUTF16(version.GetString())); |
| 310 elements_dir.push_back(base::FilePath::kSeparators[0]); | 310 elements_dir.push_back(base::FilePath::kSeparators[0]); |
| 311 elements_dir.append(installer::kVisualElements); | 311 elements_dir.append(installer::kVisualElements); |
| 312 | 312 |
| 313 // Some distributions of Chromium may not include visual elements. Only | 313 // Some distributions of Chromium may not include visual elements. Only |
| 314 // proceed if this distribution does. | 314 // proceed if this distribution does. |
| 315 if (!base::PathExists(src_path.Append(elements_dir))) { | 315 if (!base::PathExists(src_path.Append(elements_dir))) { |
| 316 VLOG(1) << "No visual elements found, not writing " | 316 VLOG(1) << "No visual elements found, not writing " |
| 317 << installer::kVisualElementsManifest << " to " << src_path.value(); | 317 << installer::kVisualElementsManifest << " to " << src_path.value(); |
| 318 return true; | 318 return true; |
| 319 } else { | 319 } else { |
| 320 // A printf_p-style format string for generating the visual elements | 320 // A printf_p-style format string for generating the visual elements |
| 321 // manifest. Required arguments, in order, are: | 321 // manifest. Required arguments, in order, are: |
| 322 // - Localized display name for the product. | 322 // - Localized display name for the product. |
| 323 // - Relative path to the VisualElements directory. | 323 // - Relative path to the VisualElements directory. |
| 324 static const char kManifestTemplate[] = | 324 static const char kManifestTemplate[] = |
| 325 "<Application>\r\n" | 325 "<Application>\r\n" |
| 326 " <VisualElements\r\n" | 326 " <VisualElements\r\n" |
| 327 " DisplayName='%1$ls'\r\n" | 327 " DisplayName='%1$ls'\r\n" |
| 328 " Logo='%2$ls\\Logo.png'\r\n" | 328 " Logo='%2$ls\\Logo.png'\r\n" |
| 329 " SmallLogo='%2$ls\\SmallLogo.png'\r\n" | 329 " SmallLogo='%2$ls\\SmallLogo.png'\r\n" |
| 330 " ForegroundText='light'\r\n" | 330 " ForegroundText='light'\r\n" |
| 331 " BackgroundColor='#323232'>\r\n" | 331 " BackgroundColor='#323232'>\r\n" |
| 332 " <DefaultTile ShowName='allLogos'/>\r\n" | 332 " <DefaultTile ShowName='allLogos'/>\r\n" |
| 333 " <SplashScreen Image='%2$ls\\splash-620x300.png'/>\r\n" | 333 " <SplashScreen Image='%2$ls\\splash-620x300.png'/>\r\n" |
| 334 " </VisualElements>\r\n" | 334 " </VisualElements>\r\n" |
| 335 "</Application>"; | 335 "</Application>"; |
| 336 | 336 |
| 337 const string16 manifest_template(ASCIIToUTF16(kManifestTemplate)); | 337 const base::string16 manifest_template(ASCIIToUTF16(kManifestTemplate)); |
| 338 | 338 |
| 339 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | 339 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( |
| 340 BrowserDistribution::CHROME_BROWSER); | 340 BrowserDistribution::CHROME_BROWSER); |
| 341 // TODO(grt): http://crbug.com/75152 Write a reference to a localized | 341 // TODO(grt): http://crbug.com/75152 Write a reference to a localized |
| 342 // resource for |display_name|. | 342 // resource for |display_name|. |
| 343 string16 display_name(dist->GetDisplayName()); | 343 base::string16 display_name(dist->GetDisplayName()); |
| 344 EscapeXmlAttributeValueInSingleQuotes(&display_name); | 344 EscapeXmlAttributeValueInSingleQuotes(&display_name); |
| 345 | 345 |
| 346 // Fill the manifest with the desired values. | 346 // Fill the manifest with the desired values. |
| 347 string16 manifest16(base::StringPrintf(manifest_template.c_str(), | 347 base::string16 manifest16(base::StringPrintf( |
| 348 display_name.c_str(), | 348 manifest_template.c_str(), display_name.c_str(), elements_dir.c_str())); |
| 349 elements_dir.c_str())); | |
| 350 | 349 |
| 351 // Write the manifest to |src_path|. | 350 // Write the manifest to |src_path|. |
| 352 const std::string manifest(UTF16ToUTF8(manifest16)); | 351 const std::string manifest(UTF16ToUTF8(manifest16)); |
| 353 int size = base::checked_numeric_cast<int>(manifest.size()); | 352 int size = base::checked_numeric_cast<int>(manifest.size()); |
| 354 if (file_util::WriteFile( | 353 if (file_util::WriteFile( |
| 355 src_path.Append(installer::kVisualElementsManifest), | 354 src_path.Append(installer::kVisualElementsManifest), |
| 356 manifest.c_str(), size) == size) { | 355 manifest.c_str(), size) == size) { |
| 357 VLOG(1) << "Successfully wrote " << installer::kVisualElementsManifest | 356 VLOG(1) << "Successfully wrote " << installer::kVisualElementsManifest |
| 358 << " to " << src_path.value(); | 357 << " to " << src_path.value(); |
| 359 return true; | 358 return true; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 DCHECK(product.is_chrome()); | 476 DCHECK(product.is_chrome()); |
| 478 | 477 |
| 479 // Try to add Chrome to Media Player shim inclusion list. We don't do any | 478 // Try to add Chrome to Media Player shim inclusion list. We don't do any |
| 480 // error checking here because this operation will fail if user doesn't | 479 // error checking here because this operation will fail if user doesn't |
| 481 // have admin rights and we want to ignore the error. | 480 // have admin rights and we want to ignore the error. |
| 482 AddChromeToMediaPlayerList(); | 481 AddChromeToMediaPlayerList(); |
| 483 | 482 |
| 484 // Make Chrome the default browser if desired when possible. Otherwise, only | 483 // Make Chrome the default browser if desired when possible. Otherwise, only |
| 485 // register it with Windows. | 484 // register it with Windows. |
| 486 BrowserDistribution* dist = product.distribution(); | 485 BrowserDistribution* dist = product.distribution(); |
| 487 const string16 chrome_exe( | 486 const base::string16 chrome_exe( |
| 488 installer_state.target_path().Append(installer::kChromeExe).value()); | 487 installer_state.target_path().Append(installer::kChromeExe).value()); |
| 489 VLOG(1) << "Registering Chrome as browser: " << chrome_exe; | 488 VLOG(1) << "Registering Chrome as browser: " << chrome_exe; |
| 490 if (make_chrome_default && ShellUtil::CanMakeChromeDefaultUnattended()) { | 489 if (make_chrome_default && ShellUtil::CanMakeChromeDefaultUnattended()) { |
| 491 int level = ShellUtil::CURRENT_USER; | 490 int level = ShellUtil::CURRENT_USER; |
| 492 if (installer_state.system_install()) | 491 if (installer_state.system_install()) |
| 493 level = level | ShellUtil::SYSTEM_LEVEL; | 492 level = level | ShellUtil::SYSTEM_LEVEL; |
| 494 ShellUtil::MakeChromeDefault(dist, level, chrome_exe, true); | 493 ShellUtil::MakeChromeDefault(dist, level, chrome_exe, true); |
| 495 } else { | 494 } else { |
| 496 ShellUtil::RegisterChromeBrowser(dist, chrome_exe, string16(), false); | 495 ShellUtil::RegisterChromeBrowser(dist, chrome_exe, base::string16(), false); |
| 497 } | 496 } |
| 498 } | 497 } |
| 499 | 498 |
| 500 InstallStatus InstallOrUpdateProduct( | 499 InstallStatus InstallOrUpdateProduct( |
| 501 const InstallationState& original_state, | 500 const InstallationState& original_state, |
| 502 const InstallerState& installer_state, | 501 const InstallerState& installer_state, |
| 503 const base::FilePath& setup_path, | 502 const base::FilePath& setup_path, |
| 504 const base::FilePath& archive_path, | 503 const base::FilePath& archive_path, |
| 505 const base::FilePath& install_temp_path, | 504 const base::FilePath& install_temp_path, |
| 506 const base::FilePath& src_path, | 505 const base::FilePath& src_path, |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 if (app_host_path.empty()) | 702 if (app_host_path.empty()) |
| 704 return false; | 703 return false; |
| 705 | 704 |
| 706 CommandLine cmd(app_host_path); | 705 CommandLine cmd(app_host_path); |
| 707 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); | 706 cmd.AppendSwitchASCII(::switches::kInstallFromWebstore, app_code); |
| 708 VLOG(1) << "App install command: " << cmd.GetCommandLineString(); | 707 VLOG(1) << "App install command: " << cmd.GetCommandLineString(); |
| 709 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); | 708 return base::LaunchProcess(cmd, base::LaunchOptions(), NULL); |
| 710 } | 709 } |
| 711 | 710 |
| 712 } // namespace installer | 711 } // namespace installer |
| OLD | NEW |