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

Unified Diff: chrome/installer/setup/install.cc

Issue 10160011: Create VisualElementsManifest.xml from template -- install VisualElements in the version directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments and move to public interface for testing Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/setup/install.cc
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index 2ceac7d014e88894a874b857919800e55d7a0409..9057fac9e217ee31fa5b06347d20b2a84c932c32 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -6,15 +6,15 @@
#include <shlobj.h>
#include <time.h>
-#include <vector>
#include "base/command_line.h"
-#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
+#include "base/string16.h"
#include "base/string_util.h"
+#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "base/win/windows_version.h"
#include "chrome/common/chrome_constants.h"
@@ -31,10 +31,8 @@
#include "chrome/installer/util/installer_state.h"
#include "chrome/installer/util/master_preferences.h"
#include "chrome/installer/util/master_preferences_constants.h"
-#include "chrome/installer/util/product.h"
#include "chrome/installer/util/set_reg_value_work_item.h"
#include "chrome/installer/util/shell_util.h"
-#include "chrome/installer/util/util_constants.h"
#include "chrome/installer/util/work_item_list.h"
// Build-time generated include file.
@@ -353,6 +351,73 @@ installer::InstallStatus InstallNewVersion(
namespace installer {
+bool CreateVisualElementsManifest(const FilePath& src_path,
+ const Version& version) {
+
grt (UTC plus 2) 2012/05/03 20:01:50 remove empty line
gab 2012/05/04 00:04:12 Done.
+ // Construct the relative path to the versioned VisualElements directory.
+ string16 elements_dir(ASCIIToUTF16(version.GetString()));
+ elements_dir.push_back(FilePath::kSeparators[0]);
+ elements_dir.append(installer::kVisualElements);
+
+ // Some distributions of Chromium may not include visual elements. Only
+ // proceed if this distribution does.
+ if (!file_util::PathExists(src_path.Append(elements_dir))) {
+ VLOG(1) << "No visual elements found, not writing "
+ << installer::kVisualElementsManifest << " to " << src_path.value();
+ return true;
+ } else {
+ // A printf_p-style format string for generating the visual elements
+ // manifest. Required arguments, in order, are:
+ // - Localized display name for the product.
+ // - Relative path to the VisualElements directory.
+ static const char kManifestTemplate[] =
+ "<Application>\r\n"
+ " <VisualElements\r\n"
+ " DisplayName='%1$ls'\r\n"
+ " Logo='%2$ls\\Logo.png'\r\n"
+ " SmallLogo='%2$ls\\SmallLogo.png'\r\n"
+ " ForegroundText='light'\r\n"
+ " BackgroundColor='white'>\r\n"
+ " <DefaultTile ShowName='allLogos'/>\r\n"
+ " <SplashScreen Image='%2$ls\\splash-620x300.png'/>\r\n"
+ " </VisualElements>\r\n"
+ "</Application>";
+
+ const string16 manifest_template(ASCIIToUTF16(kManifestTemplate));
+
+ BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution(
+ BrowserDistribution::CHROME_BROWSER);
+ // TODO(grt): http://crbug.com/75152 Write a reference to a localized
+ // resource for |display_name|.
+ string16 display_name(dist->GetAppShortCutName());
+ // Escape the display name as per the XML AttValue production
+ // (http://www.w3.org/TR/2008/REC-xml-20081126/#NT-AttValue) for a value in
+ // single quotes.
+ ReplaceChars(display_name, L"&", L"&amp;", &display_name);
+ ReplaceChars(display_name, L"'", L"&apos;", &display_name);
+ ReplaceChars(display_name, L"<", L"&lt;", &display_name);
+
+ // Fill the manifest with the desired values.
+ string16 manifest16(base::StringPrintf(manifest_template.c_str(),
+ display_name.c_str(),
+ elements_dir.c_str()));
+
+ // Write the manifest to |src_path|.
+ const std::string manifest(UTF16ToUTF8(manifest16));
+ if (file_util::WriteFile(
+ src_path.Append(installer::kVisualElementsManifest),
+ manifest.c_str(), manifest.size())) {
+ VLOG(1) << "Successfully wrote " << installer::kVisualElementsManifest
+ << " to " << src_path.value();
+ return true;
+ } else {
+ PLOG(ERROR) << "Error writing " << installer::kVisualElementsManifest
+ << " to " << src_path.value();
+ return false;
+ }
+ }
+}
+
InstallStatus InstallOrUpdateProduct(
const InstallationState& original_state,
const InstallerState& installer_state,
@@ -377,6 +442,14 @@ InstallStatus InstallOrUpdateProduct(
}
}
+ // On Windows 8 and above: create VisualElementManifest.xml in |src_path| (if
+ // required) so that it looks as if it had been extracted from the archive
+ // when calling InstallNewVersion() below.
+ if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
+ installer_state.UpdateStage(installer::CREATING_VISUAL_MANIFEST);
+ CreateVisualElementsManifest(src_path, new_version);
+ }
+
scoped_ptr<Version> existing_version;
InstallStatus result = InstallNewVersion(original_state, installer_state,
setup_path, archive_path, src_path, install_temp_path, new_version,

Powered by Google App Engine
This is Rietveld 408576698