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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 elements_dir.push_back(base::FilePath::kSeparators[0]); | 278 elements_dir.push_back(base::FilePath::kSeparators[0]); |
279 elements_dir.append(installer::kVisualElements); | 279 elements_dir.append(installer::kVisualElements); |
280 | 280 |
281 // Some distributions of Chromium may not include visual elements. Only | 281 // Some distributions of Chromium may not include visual elements. Only |
282 // proceed if this distribution does. | 282 // proceed if this distribution does. |
283 if (!base::PathExists(src_path.Append(elements_dir))) { | 283 if (!base::PathExists(src_path.Append(elements_dir))) { |
284 VLOG(1) << "No visual elements found, not writing " | 284 VLOG(1) << "No visual elements found, not writing " |
285 << installer::kVisualElementsManifest << " to " << src_path.value(); | 285 << installer::kVisualElementsManifest << " to " << src_path.value(); |
286 return true; | 286 return true; |
287 } else { | 287 } else { |
288 // A printf_p-style format string for generating the visual elements | 288 // A printf-style format string for generating the visual elements |
289 // manifest. Required arguments, in order, are: | 289 // manifest. Required arguments, in order, are: |
290 // - Localized display name for the product. | 290 // - Localized display name for the product. |
291 // - Relative path to the VisualElements directory. | 291 // - Relative path to the VisualElements directory, three times. |
292 static const char kManifestTemplate[] = | 292 static const char kManifestTemplate[] = |
293 "<Application>\r\n" | 293 "<Application>\r\n" |
294 " <VisualElements\r\n" | 294 " <VisualElements\r\n" |
295 " DisplayName='%1$ls'\r\n" | 295 " DisplayName='%ls'\r\n" |
296 " Logo='%2$ls\\Logo.png'\r\n" | 296 " Logo='%ls\\Logo.png'\r\n" |
297 " SmallLogo='%2$ls\\SmallLogo.png'\r\n" | 297 " SmallLogo='%ls\\SmallLogo.png'\r\n" |
298 " ForegroundText='light'\r\n" | 298 " ForegroundText='light'\r\n" |
299 " BackgroundColor='#323232'>\r\n" | 299 " BackgroundColor='#323232'>\r\n" |
300 " <DefaultTile ShowName='allLogos'/>\r\n" | 300 " <DefaultTile ShowName='allLogos'/>\r\n" |
301 " <SplashScreen Image='%2$ls\\splash-620x300.png'/>\r\n" | 301 " <SplashScreen Image='%ls\\splash-620x300.png'/>\r\n" |
302 " </VisualElements>\r\n" | 302 " </VisualElements>\r\n" |
303 "</Application>"; | 303 "</Application>"; |
304 | 304 |
305 const base::string16 manifest_template( | 305 const base::string16 manifest_template( |
306 base::ASCIIToUTF16(kManifestTemplate)); | 306 base::ASCIIToUTF16(kManifestTemplate)); |
307 | 307 |
308 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | 308 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( |
309 BrowserDistribution::CHROME_BROWSER); | 309 BrowserDistribution::CHROME_BROWSER); |
310 // TODO(grt): http://crbug.com/75152 Write a reference to a localized | 310 // TODO(grt): http://crbug.com/75152 Write a reference to a localized |
311 // resource for |display_name|. | 311 // resource for |display_name|. |
312 base::string16 display_name(dist->GetDisplayName()); | 312 base::string16 display_name(dist->GetDisplayName()); |
313 EscapeXmlAttributeValueInSingleQuotes(&display_name); | 313 EscapeXmlAttributeValueInSingleQuotes(&display_name); |
314 | 314 |
315 // Fill the manifest with the desired values. | 315 // Fill the manifest with the desired values. |
316 base::string16 manifest16(base::StringPrintf( | 316 base::string16 manifest16(base::StringPrintf( |
317 manifest_template.c_str(), display_name.c_str(), elements_dir.c_str())); | 317 manifest_template.c_str(), display_name.c_str(), elements_dir.c_str(), |
| 318 elements_dir.c_str(), elements_dir.c_str())); |
318 | 319 |
319 // Write the manifest to |src_path|. | 320 // Write the manifest to |src_path|. |
320 const std::string manifest(base::UTF16ToUTF8(manifest16)); | 321 const std::string manifest(base::UTF16ToUTF8(manifest16)); |
321 int size = base::checked_cast<int>(manifest.size()); | 322 int size = base::checked_cast<int>(manifest.size()); |
322 if (base::WriteFile( | 323 if (base::WriteFile( |
323 src_path.Append(installer::kVisualElementsManifest), | 324 src_path.Append(installer::kVisualElementsManifest), |
324 manifest.c_str(), size) == size) { | 325 manifest.c_str(), size) == size) { |
325 VLOG(1) << "Successfully wrote " << installer::kVisualElementsManifest | 326 VLOG(1) << "Successfully wrote " << installer::kVisualElementsManifest |
326 << " to " << src_path.value(); | 327 << " to " << src_path.value(); |
327 return true; | 328 return true; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); | 640 INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); |
640 | 641 |
641 // Read master_preferences copied beside chrome.exe at install. | 642 // Read master_preferences copied beside chrome.exe at install. |
642 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 643 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
643 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 644 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
644 CreateOrUpdateShortcuts( | 645 CreateOrUpdateShortcuts( |
645 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 646 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
646 } | 647 } |
647 | 648 |
648 } // namespace installer | 649 } // namespace installer |
OLD | NEW |