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

Side by Side 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: lintttttt Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // This file contains the definitions of the installer functions that build 5 // This file contains the definitions of the installer functions that build
6 // the WorkItemList used to install the application. 6 // the WorkItemList used to install the application.
7 7
8 #include "chrome/installer/setup/install_worker.h" 8 #include "chrome/installer/setup/install_worker.h"
9 9
10 #include <oaidl.h> 10 #include <oaidl.h>
11 #include <shlobj.h> 11 #include <shlobj.h>
12 #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
12 #include <time.h> 13 #include <time.h>
13 #include <vector> 14 #include <vector>
14 15
15 #include "base/command_line.h" 16 #include "base/command_line.h"
16 #include "base/file_path.h" 17 #include "base/file_path.h"
17 #include "base/file_util.h" 18 #include "base/file_util.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/path_service.h" 20 #include "base/path_service.h"
21 #include "base/string16.h"
20 #include "base/string_util.h" 22 #include "base/string_util.h"
23 #include "base/stringprintf.h"
21 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
22 #include "base/version.h" 25 #include "base/version.h"
23 #include "base/win/registry.h" 26 #include "base/win/registry.h"
24 #include "base/win/windows_version.h" 27 #include "base/win/windows_version.h"
25 #include "chrome/common/chrome_constants.h" 28 #include "chrome/common/chrome_constants.h"
26 #include "chrome/installer/setup/install.h" 29 #include "chrome/installer/setup/install.h"
27 #include "chrome/installer/setup/setup_constants.h" 30 #include "chrome/installer/setup/setup_constants.h"
28 #include "chrome/installer/util/conditional_work_item_list.h" 31 #include "chrome/installer/util/conditional_work_item_list.h"
29 #include "chrome/installer/util/create_reg_key_work_item.h" 32 #include "chrome/installer/util/create_reg_key_work_item.h"
30 #include "chrome/installer/util/google_update_constants.h" 33 #include "chrome/installer/util/google_update_constants.h"
31 #include "chrome/installer/util/helper.h" 34 #include "chrome/installer/util/helper.h"
32 #include "chrome/installer/util/installation_state.h" 35 #include "chrome/installer/util/installation_state.h"
33 #include "chrome/installer/util/installer_state.h" 36 #include "chrome/installer/util/installer_state.h"
34 #include "chrome/installer/util/install_util.h" 37 #include "chrome/installer/util/install_util.h"
35 #include "chrome/installer/util/l10n_string_util.h" 38 #include "chrome/installer/util/l10n_string_util.h"
36 #include "chrome/installer/util/product.h" 39 #include "chrome/installer/util/product.h"
37 #include "chrome/installer/util/set_reg_value_work_item.h" 40 #include "chrome/installer/util/set_reg_value_work_item.h"
38 #include "chrome/installer/util/shell_util.h" 41 #include "chrome/installer/util/shell_util.h"
39 #include "chrome/installer/util/util_constants.h" 42 #include "chrome/installer/util/util_constants.h"
40 #include "chrome/installer/util/work_item_list.h" 43 #include "chrome/installer/util/work_item_list.h"
41 #include "chrome_frame/chrome_tab.h" 44 #include "chrome_frame/chrome_tab.h"
42 45
43 using base::win::RegKey; 46 using base::win::RegKey;
44 47
48 namespace {
49
50 // Elements that make up install target paths.
51 const wchar_t kDictionaries[] = L"Dictionaries";
52 const wchar_t kImages[] = L"Images";
53 const wchar_t kLogoImage[] = L"Logo.png";
54 const wchar_t kSmallLogoImage[] = L"SmallLogo.png";
55 const wchar_t kSplashScreenImage[] = L"splash-620x300.png";
56 const wchar_t kVisualElementsManifest[] = L"VisualElementsManifest.xml";
57 const wchar_t kWowHelperExe[] = L"wow_helper.exe";
58
59 // Adds work items to |install_list| to lay down a version specific
60 // VisualElementsManifest.xml beside chrome.exe.
61 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
62 const FilePath& target_path,
63 const FilePath& temp_path,
64 const Version& new_version,
65 WorkItemList* install_list) {
66 DCHECK(install_list);
67
68 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.
69 images_dir.push_back(FilePath::kSeparators[0]);
70 images_dir.append(kImages);
71 images_dir.push_back(FilePath::kSeparators[0]);
72
73 // Some distributions of Chromium may not include visual elements. Only
74 // proceed if this distribution does.
75 if (!file_util::PathExists(src_path.Append(images_dir + kLogoImage))) {
76 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
77 } else {
78 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.
79 L"<Application\r\n"
80 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.
81 L" <VisualElements\r\n"
82 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
83 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.
84 L" SmallLogo=\"%ls\"\r\n"
85 L" ForegroundText=\"light\"\r\n"
86 L" BackgroundColor=\"white\">\r\n"
87 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.
88 L" <SplashScreen Image=\"%ls\"/>\r\n"
89 L" </VisualElements>\r\n"
90 L"</Application>";
91
92 // Fill the manifest with the desired values.
93 string16 manifest;
94 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
95 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.
96 const string16 logo_path = images_dir + kLogoImage;
97 const string16 small_logo_path = images_dir + kSmallLogoImage;
98 const string16 splash_path = images_dir + kSplashScreenImage;
99 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
100 small_logo_path, splash_path);
101
102 // Write the manifest to the directory where the archive was extracted.
103 const std::string manifest_utf8 = UTF16ToUTF8(manifest);
104 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.
105 manifest_utf8.c_str(), manifest_utf8.size());
106
107 // Add a work item to move the new manifest to |target_path|.
108 install_list->AddMoveTreeWorkItem(
109 src_path.Append(kVisualElementsManifest).value(),
110 target_path.Append(kVisualElementsManifest).value(),
111 temp_path.value(),
112 WorkItem::ALWAYS_MOVE);
113 }
114 }
115
116 } // namespace
117
45 namespace installer { 118 namespace installer {
46 119
47 // Local helper to call AddRegisterComDllWorkItems for all DLLs in a set of 120 // Local helper to call AddRegisterComDllWorkItems for all DLLs in a set of
48 // products managed by a given package. 121 // products managed by a given package.
49 void AddRegisterComDllWorkItemsForPackage(const InstallerState& installer_state, 122 void AddRegisterComDllWorkItemsForPackage(const InstallerState& installer_state,
50 const Version* old_version, 123 const Version* old_version,
51 const Version& new_version, 124 const Version& new_version,
52 WorkItemList* work_item_list) { 125 WorkItemList* work_item_list) {
53 // First collect the list of DLLs to be registered from each product. 126 // First collect the list of DLLs to be registered from each product.
54 std::vector<FilePath> com_dll_list; 127 std::vector<FilePath> com_dll_list;
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 835 }
763 836
764 // Extra executable for 64 bit systems. 837 // Extra executable for 64 bit systems.
765 // NOTE: We check for "not disabled" so that if the API call fails, we play it 838 // NOTE: We check for "not disabled" so that if the API call fails, we play it
766 // safe and copy the executable anyway. 839 // safe and copy the executable anyway.
767 // NOTE: the file wow_helper.exe is only needed for Vista and below. 840 // NOTE: the file wow_helper.exe is only needed for Vista and below.
768 if (base::win::OSInfo::GetInstance()->wow64_status() != 841 if (base::win::OSInfo::GetInstance()->wow64_status() !=
769 base::win::OSInfo::WOW64_DISABLED && 842 base::win::OSInfo::WOW64_DISABLED &&
770 base::win::GetVersion() <= base::win::VERSION_VISTA) { 843 base::win::GetVersion() <= base::win::VERSION_VISTA) {
771 install_list->AddMoveTreeWorkItem( 844 install_list->AddMoveTreeWorkItem(
772 src_path.Append(installer::kWowHelperExe).value(), 845 src_path.Append(kWowHelperExe).value(),
773 target_path.Append(installer::kWowHelperExe).value(), 846 target_path.Append(kWowHelperExe).value(),
774 temp_path.value(), 847 temp_path.value(),
775 WorkItem::ALWAYS_MOVE); 848 WorkItem::ALWAYS_MOVE);
776 } 849 }
777 850
778 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { 851 if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
779 // Desktop only (i.e. not supporting Metro) versions of Chromium do not have 852 AddVisualElementsInstallWorkItems(src_path, target_path, temp_path,
780 // to include visual elements. 853 new_version, install_list);
781 scoped_ptr<WorkItemList> win8_work_items(
782 WorkItem::CreateConditionalWorkItemList(new ConditionRunIfFileExists(
783 src_path.Append(L"visualelementsmanifest.xml"))));
784 // TODO (gab): All of these hard-coded strings are temporary and will be
785 // deleted in the patch following this one.
786 win8_work_items->AddMoveTreeWorkItem(
787 src_path.Append(L"visualelementsmanifest.xml").value(),
788 target_path.Append(L"visualelementsmanifest.xml").value(),
789 temp_path.value(),
790 WorkItem::ALWAYS_MOVE);
791 win8_work_items->AddMoveTreeWorkItem(
792 src_path.Append(L"logo.png").value(),
793 target_path.Append(L"logo.png").value(),
794 temp_path.value(),
795 WorkItem::ALWAYS_MOVE);
796 win8_work_items->AddMoveTreeWorkItem(
797 src_path.Append(L"smalllogo.png").value(),
798 target_path.Append(L"smalllogo.png").value(),
799 temp_path.value(),
800 WorkItem::ALWAYS_MOVE);
801 win8_work_items->AddMoveTreeWorkItem(
802 src_path.Append(L"splash-620x300.png").value(),
803 target_path.Append(L"splash-620x300.png").value(),
804 temp_path.value(),
805 WorkItem::ALWAYS_MOVE);
806 install_list->AddWorkItem(win8_work_items.release());
807 } 854 }
808 855
809 // In the past, we copied rather than moved for system level installs so that 856 // In the past, we copied rather than moved for system level installs so that
810 // the permissions of %ProgramFiles% would be picked up. Now that |temp_path| 857 // the permissions of %ProgramFiles% would be picked up. Now that |temp_path|
811 // is in %ProgramFiles% for system level installs (and in %LOCALAPPDATA% 858 // is in %ProgramFiles% for system level installs (and in %LOCALAPPDATA%
812 // otherwise), there is no need to do this. 859 // otherwise), there is no need to do this.
813 // Note that we pass true for check_duplicates to avoid failing on in-use 860 // Note that we pass true for check_duplicates to avoid failing on in-use
814 // repair runs if the current_version is the same as the new_version. 861 // repair runs if the current_version is the same as the new_version.
815 bool check_for_duplicates = 862 bool check_for_duplicates =
816 (current_version != NULL && current_version->get() != NULL && 863 (current_version != NULL && current_version->get() != NULL &&
817 current_version->get()->Equals(new_version)); 864 current_version->get()->Equals(new_version));
818 install_list->AddMoveTreeWorkItem( 865 install_list->AddMoveTreeWorkItem(
819 src_path.AppendASCII(new_version.GetString()).value(), 866 src_path.AppendASCII(new_version.GetString()).value(),
820 target_path.AppendASCII(new_version.GetString()).value(), 867 target_path.AppendASCII(new_version.GetString()).value(),
821 temp_path.value(), 868 temp_path.value(),
822 check_for_duplicates ? WorkItem::CHECK_DUPLICATES : 869 check_for_duplicates ? WorkItem::CHECK_DUPLICATES :
823 WorkItem::ALWAYS_MOVE); 870 WorkItem::ALWAYS_MOVE);
824 871
825 // Copy the default Dictionaries only if the folder doesn't exist already. 872 // Copy the default Dictionaries only if the folder doesn't exist already.
826 // TODO(grt): Use AddMoveTreeWorkItem in a conditional WorkItemList, which 873 // TODO(grt): Use AddMoveTreeWorkItem in a conditional WorkItemList, which
827 // will be more efficient in space and time. 874 // will be more efficient in space and time.
828 install_list->AddCopyTreeWorkItem( 875 install_list->AddCopyTreeWorkItem(
829 src_path.Append(installer::kDictionaries).value(), 876 src_path.Append(kDictionaries).value(),
830 target_path.Append(installer::kDictionaries).value(), 877 target_path.Append(kDictionaries).value(),
831 temp_path.value(), WorkItem::IF_NOT_PRESENT); 878 temp_path.value(), WorkItem::IF_NOT_PRESENT);
832 879
833 // Delete any old_chrome.exe if present (ignore failure if it's in use). 880 // Delete any old_chrome.exe if present (ignore failure if it's in use).
834 install_list->AddDeleteTreeWorkItem( 881 install_list->AddDeleteTreeWorkItem(
835 target_path.Append(installer::kChromeOldExe), temp_path) 882 target_path.Append(installer::kChromeOldExe), temp_path)
836 ->set_ignore_failure(true); 883 ->set_ignore_failure(true);
837 884
838 // Copy installer in install directory and 885 // Copy installer in install directory and
839 // add shortcut in Control Panel->Add/Remove Programs. 886 // add shortcut in Control Panel->Add/Remove Programs.
840 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path, 887 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path,
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 } else { 1472 } else {
1426 DCHECK(operation == REMOVE_COMMAND); 1473 DCHECK(operation == REMOVE_COMMAND);
1427 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), 1474 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(),
1428 cmd_key)->set_log_message( 1475 cmd_key)->set_log_message(
1429 "removing quick-enable-cf command"); 1476 "removing quick-enable-cf command");
1430 } 1477 }
1431 } 1478 }
1432 } 1479 }
1433 1480
1434 } // namespace installer 1481 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698