Chromium Code Reviews| 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..737fdc35b00044d0f2ceb40be56ff2f7e4268f83 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> |
|
grt (UTC plus 2)
2012/05/01 04:17:03
style: c++ headers follow c headers, so move this
gab
2012/05/01 22:19:02
I agree that a space makes it clearer (and I'm pre
|
| #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, |
|
grt (UTC plus 2)
2012/05/01 04:17:03
i think this should be split up into two parts. h
gab
2012/05/02 20:55:58
Done. unit test to come in next patch set.
grt (UTC plus 2)
2012/05/03 17:49:36
it's inside InstallNewVersion.
gab
2012/05/03 19:03:48
Oh, how did I miss that...! I'll change CreateVisu
|
| + 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()); |
|
grt (UTC plus 2)
2012/05/01 04:17:03
i'm told that this is the encouraged style rather
gab
2012/05/01 22:19:02
Done.
gab
2012/05/01 22:19:02
Done.
|
| + 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))) { |
| + LOG(WARNING) << "No visual elements found, skipping related work items."; |
|
grt (UTC plus 2)
2012/05/01 04:17:03
is VLOG(1) more appropriate here, or is this reall
gab
2012/05/01 22:19:02
Technically all distributions should have visual e
|
| + } else { |
| + const wchar_t manifest_template[] = |
|
grt (UTC plus 2)
2012/05/01 04:17:03
i think it'd be helpful to put a comment above the
grt (UTC plus 2)
2012/05/01 04:17:03
- make this static to be sure that uses of it are
gab
2012/05/01 22:19:02
Done.
gab
2012/05/01 22:19:02
Done.
|
| + L"<Application\r\n" |
| + L" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n" |
|
grt (UTC plus 2)
2012/05/01 04:17:03
remove this namespace decl since it isn't used.
gab
2012/05/01 22:19:02
Done.
|
| + L" <VisualElements\r\n" |
| + L" DisplayName=\"%ls\"\r\n" |
|
grt (UTC plus 2)
2012/05/01 04:17:03
since the attributes are conceptually a continuati
grt (UTC plus 2)
2012/05/01 04:17:03
i think the template will look cleaner with single
gab
2012/05/01 22:19:02
Makes sense, done.
gab
2012/05/01 22:19:02
Didn't know that XML didn't care, good to know, an
|
| + L" Logo=\"%ls\"\r\n" |
|
grt (UTC plus 2)
2012/05/01 04:17:03
the bits underlying StringPrintf appear to support
gab
2012/05/02 20:55:58
This works, done in previous patchset.
|
| + L" SmallLogo=\"%ls\"\r\n" |
| + L" ForegroundText=\"light\"\r\n" |
| + L" BackgroundColor=\"white\">\r\n" |
| + L" <DefaultTile ShowName=\"allLogos\"/>\r\n" |
|
grt (UTC plus 2)
2012/05/01 04:17:03
the two-space indent is good here and on the next
gab
2012/05/01 22:19:02
Right.
|
| + 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(); |
|
grt (UTC plus 2)
2012/05/01 04:17:03
this will return the distribution of whatever prod
gab
2012/05/01 22:19:02
Wouldn't that trigger Chromium to have display nam
grt (UTC plus 2)
2012/05/02 15:09:43
No. The base BrowserDistribution class (rather th
gab
2012/05/02 20:55:58
Ah, I see, CHROME_BROWSER != GOOGLE_CHROME :)!
Do
|
| + const string16 display_name = dist->GetAppShortCutName(); |
|
grt (UTC plus 2)
2012/05/01 04:17:03
XML attribute values may not contain '<' or '&'.
grt (UTC plus 2)
2012/05/01 04:23:24
oh yeah:
// TODO(grt): http://crbug.com/75152 Writ
gab
2012/05/01 22:19:02
Done.
I think however fixes the localization issu
gab
2012/05/01 22:19:02
Done. Not sure where you found documentation sayin
grt (UTC plus 2)
2012/05/02 15:09:43
http://www.w3.org/TR/2008/REC-xml-20081126/#NT-Att
gab
2012/05/02 20:55:58
Great, thanks, added it to the comment.
|
| + 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, |
|
grt (UTC plus 2)
2012/05/01 04:17:03
is there a benefit to using SStringPrintf over Str
gab
2012/05/01 22:19:02
Looks like I overlooked the code and assumed Strin
|
| + 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), |
|
grt (UTC plus 2)
2012/05/01 04:17:03
check the return value and, in case of error, log
gab
2012/05/01 22:19:02
Done.
|
| + 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). |