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

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: remove shortname property 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 <map>
10 #include <oaidl.h> 11 #include <oaidl.h>
11 #include <shlobj.h> 12 #include <shlobj.h>
12 #include <time.h> 13 #include <time.h>
14 #include <utility>
13 #include <vector> 15 #include <vector>
14 16
15 #include "base/command_line.h" 17 #include "base/command_line.h"
16 #include "base/file_path.h" 18 #include "base/file_path.h"
17 #include "base/file_util.h" 19 #include "base/file_util.h"
18 #include "base/logging.h" 20 #include "base/logging.h"
19 #include "base/path_service.h" 21 #include "base/path_service.h"
20 #include "base/string_util.h" 22 #include "base/string_util.h"
21 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
22 #include "base/version.h" 24 #include "base/version.h"
(...skipping 12 matching lines...) Expand all
35 #include "chrome/installer/util/l10n_string_util.h" 37 #include "chrome/installer/util/l10n_string_util.h"
36 #include "chrome/installer/util/product.h" 38 #include "chrome/installer/util/product.h"
37 #include "chrome/installer/util/set_reg_value_work_item.h" 39 #include "chrome/installer/util/set_reg_value_work_item.h"
38 #include "chrome/installer/util/shell_util.h" 40 #include "chrome/installer/util/shell_util.h"
39 #include "chrome/installer/util/util_constants.h" 41 #include "chrome/installer/util/util_constants.h"
40 #include "chrome/installer/util/work_item_list.h" 42 #include "chrome/installer/util/work_item_list.h"
41 #include "chrome_frame/chrome_tab.h" 43 #include "chrome_frame/chrome_tab.h"
42 44
43 using base::win::RegKey; 45 using base::win::RegKey;
44 46
47 namespace {
48
49 // Elements that make up install target paths.
50 const wchar_t kDictionaries[] = L"Dictionaries";
51 const wchar_t kImages[] = L"Images";
52 const wchar_t kLogoImage[] = L"Logo.png";
53 const wchar_t kSmallLogoImage[] = L"SmallLogo.png";
54 const wchar_t kSplashScreenImage[] = L"splash-620x300.png";
55 const wchar_t kVisualElementsManifest[] = L"VisualElementsManifest.xml";
56 const wchar_t kVisualElementsManifestTemplate[] =
57 L"VisualElementsManifest_template.xml";
58 const wchar_t kWowHelperExe[] = L"wow_helper.exe";
59
60 // Template variables used in kVisualElementsManifestTemplateXml.
61 const wchar_t kDisplayNameVar[] = L"DISPLAYNAME";
62 const wchar_t kLogoVar[] = L"LOGO";
63 const wchar_t kSmallLogoVar[] = L"SMALLLOGO";
64 const wchar_t kSplashScreenVar[] = L"SPLASH";
65
66 } // namespace
67
45 namespace installer { 68 namespace installer {
46 69
47 // Local helper to call AddRegisterComDllWorkItems for all DLLs in a set of 70 // Local helper to call AddRegisterComDllWorkItems for all DLLs in a set of
48 // products managed by a given package. 71 // products managed by a given package.
49 void AddRegisterComDllWorkItemsForPackage(const InstallerState& installer_state, 72 void AddRegisterComDllWorkItemsForPackage(const InstallerState& installer_state,
50 const Version* old_version, 73 const Version* old_version,
51 const Version& new_version, 74 const Version& new_version,
52 WorkItemList* work_item_list) { 75 WorkItemList* work_item_list) {
53 // First collect the list of DLLs to be registered from each product. 76 // First collect the list of DLLs to be registered from each product.
54 std::vector<FilePath> com_dll_list; 77 std::vector<FilePath> com_dll_list;
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 785 }
763 786
764 // Extra executable for 64 bit systems. 787 // Extra executable for 64 bit systems.
765 // NOTE: We check for "not disabled" so that if the API call fails, we play it 788 // NOTE: We check for "not disabled" so that if the API call fails, we play it
766 // safe and copy the executable anyway. 789 // safe and copy the executable anyway.
767 // NOTE: the file wow_helper.exe is only needed for Vista and below. 790 // NOTE: the file wow_helper.exe is only needed for Vista and below.
768 if (base::win::OSInfo::GetInstance()->wow64_status() != 791 if (base::win::OSInfo::GetInstance()->wow64_status() !=
769 base::win::OSInfo::WOW64_DISABLED && 792 base::win::OSInfo::WOW64_DISABLED &&
770 base::win::GetVersion() <= base::win::VERSION_VISTA) { 793 base::win::GetVersion() <= base::win::VERSION_VISTA) {
771 install_list->AddMoveTreeWorkItem( 794 install_list->AddMoveTreeWorkItem(
772 src_path.Append(installer::kWowHelperExe).value(), 795 src_path.Append(kWowHelperExe).value(),
773 target_path.Append(installer::kWowHelperExe).value(), 796 target_path.Append(kWowHelperExe).value(),
774 temp_path.value(), 797 temp_path.value(),
775 WorkItem::ALWAYS_MOVE); 798 WorkItem::ALWAYS_MOVE);
776 } 799 }
777 800
778 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { 801 if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
779 // Desktop only (i.e. not supporting Metro) versions of Chromium do not have 802 // Desktop only (i.e. not supporting Metro) versions of Chromium do not have
780 // to include visual elements. 803 // to include visual elements.
781 scoped_ptr<WorkItemList> win8_work_items( 804 scoped_ptr<WorkItemList> win8_work_items(
782 WorkItem::CreateConditionalWorkItemList(new ConditionRunIfFileExists( 805 WorkItem::CreateConditionalWorkItemList(new ConditionRunIfFileExists(
783 src_path.Append(L"visualelementsmanifest.xml")))); 806 src_path.Append(kVisualElementsManifestTemplate))));
784 // TODO (gab): All of these hard-coded strings are temporary and will be 807
785 // deleted in the patch following this one. 808 // Map all template variables to their desired values for this install.
786 win8_work_items->AddMoveTreeWorkItem( 809 std::map<string16, string16> mappings;
787 src_path.Append(L"visualelementsmanifest.xml").value(), 810 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
788 target_path.Append(L"visualelementsmanifest.xml").value(), 811 string16 images_dir = ASCIIToUTF16(new_version.GetString());
812 images_dir.push_back(FilePath::kSeparators[0]);
813 images_dir.append(kImages);
814 images_dir.push_back(FilePath::kSeparators[0]);
815 mappings.insert(make_pair(kDisplayNameVar, dist->GetAppShortCutName()));
816 mappings.insert(make_pair(kLogoVar, images_dir + kLogoImage));
817 mappings.insert(make_pair(kSmallLogoVar, images_dir + kSmallLogoImage));
818 mappings.insert(make_pair(
819 kSplashScreenVar, images_dir + kSplashScreenImage));
820
821 win8_work_items->AddFileFromTemplateWorkItem(
822 src_path.Append(kVisualElementsManifestTemplate).value(),
823 target_path.Append(kVisualElementsManifest).value(),
789 temp_path.value(), 824 temp_path.value(),
790 WorkItem::ALWAYS_MOVE); 825 mappings);
791 win8_work_items->AddMoveTreeWorkItem( 826
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()); 827 install_list->AddWorkItem(win8_work_items.release());
807 } 828 }
808 829
809 // In the past, we copied rather than moved for system level installs so that 830 // 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| 831 // the permissions of %ProgramFiles% would be picked up. Now that |temp_path|
811 // is in %ProgramFiles% for system level installs (and in %LOCALAPPDATA% 832 // is in %ProgramFiles% for system level installs (and in %LOCALAPPDATA%
812 // otherwise), there is no need to do this. 833 // otherwise), there is no need to do this.
813 // Note that we pass true for check_duplicates to avoid failing on in-use 834 // 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. 835 // repair runs if the current_version is the same as the new_version.
815 bool check_for_duplicates = 836 bool check_for_duplicates =
816 (current_version != NULL && current_version->get() != NULL && 837 (current_version != NULL && current_version->get() != NULL &&
817 current_version->get()->Equals(new_version)); 838 current_version->get()->Equals(new_version));
818 install_list->AddMoveTreeWorkItem( 839 install_list->AddMoveTreeWorkItem(
819 src_path.AppendASCII(new_version.GetString()).value(), 840 src_path.AppendASCII(new_version.GetString()).value(),
820 target_path.AppendASCII(new_version.GetString()).value(), 841 target_path.AppendASCII(new_version.GetString()).value(),
821 temp_path.value(), 842 temp_path.value(),
822 check_for_duplicates ? WorkItem::CHECK_DUPLICATES : 843 check_for_duplicates ? WorkItem::CHECK_DUPLICATES :
823 WorkItem::ALWAYS_MOVE); 844 WorkItem::ALWAYS_MOVE);
824 845
825 // Copy the default Dictionaries only if the folder doesn't exist already. 846 // Copy the default Dictionaries only if the folder doesn't exist already.
826 // TODO(grt): Use AddMoveTreeWorkItem in a conditional WorkItemList, which 847 // TODO(grt): Use AddMoveTreeWorkItem in a conditional WorkItemList, which
827 // will be more efficient in space and time. 848 // will be more efficient in space and time.
828 install_list->AddCopyTreeWorkItem( 849 install_list->AddCopyTreeWorkItem(
829 src_path.Append(installer::kDictionaries).value(), 850 src_path.Append(kDictionaries).value(),
830 target_path.Append(installer::kDictionaries).value(), 851 target_path.Append(kDictionaries).value(),
831 temp_path.value(), WorkItem::IF_NOT_PRESENT); 852 temp_path.value(), WorkItem::IF_NOT_PRESENT);
832 853
833 // Delete any old_chrome.exe if present (ignore failure if it's in use). 854 // Delete any old_chrome.exe if present (ignore failure if it's in use).
834 install_list->AddDeleteTreeWorkItem( 855 install_list->AddDeleteTreeWorkItem(
835 target_path.Append(installer::kChromeOldExe), temp_path) 856 target_path.Append(installer::kChromeOldExe), temp_path)
836 ->set_ignore_failure(true); 857 ->set_ignore_failure(true);
837 858
838 // Copy installer in install directory and 859 // Copy installer in install directory and
839 // add shortcut in Control Panel->Add/Remove Programs. 860 // add shortcut in Control Panel->Add/Remove Programs.
840 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path, 861 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path,
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 } else { 1446 } else {
1426 DCHECK(operation == REMOVE_COMMAND); 1447 DCHECK(operation == REMOVE_COMMAND);
1427 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), 1448 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(),
1428 cmd_key)->set_log_message( 1449 cmd_key)->set_log_message(
1429 "removing quick-enable-cf command"); 1450 "removing quick-enable-cf command");
1430 } 1451 }
1431 } 1452 }
1432 } 1453 }
1433 1454
1434 } // namespace installer 1455 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698