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

Unified Diff: chrome/installer/setup/install_worker.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: simpler -- hardcoded template + SStringPrintf 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
« no previous file with comments | « chrome/installer/mini_installer/chrome.release ('k') | chrome/installer/setup/setup_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/setup/install_worker.cc
diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc
index cd17feea47e150abf09e29bb9bc847b780027d0f..39d2c160a8d4d64d2258ad91295c5f628dfc53a5 100644
--- a/chrome/installer/setup/install_worker.cc
+++ b/chrome/installer/setup/install_worker.cc
@@ -9,6 +9,7 @@
#include <oaidl.h>
#include <shlobj.h>
+#include <string>
#include <time.h>
#include <vector>
@@ -17,7 +18,9 @@
#include "base/file_util.h"
#include "base/logging.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/version.h"
#include "base/win/registry.h"
@@ -42,6 +45,76 @@
using base::win::RegKey;
+namespace {
+
+// Elements that make up install target paths.
+const wchar_t kDictionaries[] = L"Dictionaries";
+const wchar_t kImages[] = L"Images";
+const wchar_t kLogoImage[] = L"Logo.png";
+const wchar_t kSmallLogoImage[] = L"SmallLogo.png";
+const wchar_t kSplashScreenImage[] = L"splash-620x300.png";
+const wchar_t kVisualElementsManifest[] = L"VisualElementsManifest.xml";
+const wchar_t kWowHelperExe[] = L"wow_helper.exe";
+
+// Adds work items to |install_list| to lay down a version specific
+// VisualElementsManifest.xml beside chrome.exe.
+void AddVisualElementsInstallWorkItems(const FilePath& src_path,
+ const FilePath& target_path,
+ const FilePath& temp_path,
+ const Version& new_version,
+ WorkItemList* install_list) {
+ DCHECK(install_list);
+
+ string16 images_dir = ASCIIToUTF16(new_version.GetString());
+ images_dir.push_back(FilePath::kSeparators[0]);
+ images_dir.append(kImages);
+ images_dir.push_back(FilePath::kSeparators[0]);
+
+ // Some distributions of Chromium may not include visual elements. Only
+ // proceed if this distribution does.
+ if (!file_util::PathExists(src_path.Append(images_dir + kLogoImage))) {
gab 2012/05/01 01:59:13 No need to use a conditional work item list here,
+ LOG(WARNING) << "No visual elements found, skipping related work items.";
+ } else {
+ const wchar_t manifest_template[] =
+ L"<Application\r\n"
+ L" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n"
+ L" <VisualElements\r\n"
+ L" DisplayName=\"%ls\"\r\n"
+ L" Logo=\"%ls\"\r\n"
+ L" SmallLogo=\"%ls\"\r\n"
+ L" ForegroundText=\"light\"\r\n"
+ L" BackgroundColor=\"white\">\r\n"
+ L" <DefaultTile ShowName=\"allLogos\"/>\r\n"
+ L" <SplashScreen Image=\"%ls\"/>\r\n"
+ L" </VisualElements>\r\n"
+ L"</Application>";
+
+ // Fill the manifest with the desired values.
+ string16 manifest;
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ const string16 display_name = dist->GetAppShortCutName();
+ const string16 logo_path = images_dir + kLogoImage;
+ const string16 small_logo_path = images_dir + kSmallLogoImage;
+ const string16 splash_path = images_dir + kSplashScreenImage;
+ base::SStringPrintf(&manifest, manifest_template, display_name, logo_path,
gab 2012/05/01 01:59:13 Testing the installer now, this call fails silentl
+ small_logo_path, splash_path);
+
+ // Write the manifest to the directory where the archive was extracted.
+ const std::string manifest_utf8 = UTF16ToUTF8(manifest);
+ file_util::WriteFile(src_path.Append(kVisualElementsManifest),
+ manifest_utf8.c_str(), manifest_utf8.size());
+
+ // Add a work item to move the new manifest to |target_path|.
+ install_list->AddMoveTreeWorkItem(
+ src_path.Append(kVisualElementsManifest).value(),
+ target_path.Append(kVisualElementsManifest).value(),
+ temp_path.value(),
+ WorkItem::ALWAYS_MOVE);
+ }
+}
+
+} // namespace
+
namespace installer {
// Local helper to call AddRegisterComDllWorkItems for all DLLs in a set of
@@ -769,41 +842,15 @@ void AddInstallWorkItems(const InstallationState& original_state,
base::win::OSInfo::WOW64_DISABLED &&
base::win::GetVersion() <= base::win::VERSION_VISTA) {
install_list->AddMoveTreeWorkItem(
- src_path.Append(installer::kWowHelperExe).value(),
- target_path.Append(installer::kWowHelperExe).value(),
+ src_path.Append(kWowHelperExe).value(),
+ target_path.Append(kWowHelperExe).value(),
temp_path.value(),
WorkItem::ALWAYS_MOVE);
}
if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
- // Desktop only (i.e. not supporting Metro) versions of Chromium do not have
- // to include visual elements.
- scoped_ptr<WorkItemList> win8_work_items(
- WorkItem::CreateConditionalWorkItemList(new ConditionRunIfFileExists(
- src_path.Append(L"visualelementsmanifest.xml"))));
- // TODO (gab): All of these hard-coded strings are temporary and will be
- // deleted in the patch following this one.
- win8_work_items->AddMoveTreeWorkItem(
- src_path.Append(L"visualelementsmanifest.xml").value(),
- target_path.Append(L"visualelementsmanifest.xml").value(),
- temp_path.value(),
- WorkItem::ALWAYS_MOVE);
- win8_work_items->AddMoveTreeWorkItem(
- src_path.Append(L"logo.png").value(),
- target_path.Append(L"logo.png").value(),
- temp_path.value(),
- WorkItem::ALWAYS_MOVE);
- win8_work_items->AddMoveTreeWorkItem(
- src_path.Append(L"smalllogo.png").value(),
- target_path.Append(L"smalllogo.png").value(),
- temp_path.value(),
- WorkItem::ALWAYS_MOVE);
- win8_work_items->AddMoveTreeWorkItem(
- src_path.Append(L"splash-620x300.png").value(),
- target_path.Append(L"splash-620x300.png").value(),
- temp_path.value(),
- WorkItem::ALWAYS_MOVE);
- install_list->AddWorkItem(win8_work_items.release());
+ AddVisualElementsInstallWorkItems(src_path, target_path, temp_path,
+ new_version, install_list);
}
// In the past, we copied rather than moved for system level installs so that
@@ -826,8 +873,8 @@ void AddInstallWorkItems(const InstallationState& original_state,
// TODO(grt): Use AddMoveTreeWorkItem in a conditional WorkItemList, which
// will be more efficient in space and time.
install_list->AddCopyTreeWorkItem(
- src_path.Append(installer::kDictionaries).value(),
- target_path.Append(installer::kDictionaries).value(),
+ src_path.Append(kDictionaries).value(),
+ target_path.Append(kDictionaries).value(),
temp_path.value(), WorkItem::IF_NOT_PRESENT);
// Delete any old_chrome.exe if present (ignore failure if it's in use).
« no previous file with comments | « chrome/installer/mini_installer/chrome.release ('k') | chrome/installer/setup/setup_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698