install.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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
3// found in the LICENSE file.
4//
5// This file contains the specification of setup main functions.
6
7#ifndef CHROME_INSTALLER_SETUP_INSTALL_H_
8#define CHROME_INSTALLER_SETUP_INSTALL_H_
9
10#include <vector>
11
12#include "base/strings/string16.h"
13#include "base/version.h"
14#include "chrome/installer/util/installation_state.h"
15#include "chrome/installer/util/installer_state.h"
16#include "chrome/installer/util/master_preferences.h"
17#include "chrome/installer/util/product.h"
18#include "chrome/installer/util/util_constants.h"
19
20namespace base {
21class FilePath;
22}
23
24namespace installer {
25
26class InstallationState;
27class InstallerState;
28class MasterPreferences;
29
30enum InstallShortcutOperation {
31  // Create all shortcuts (potentially skipping those explicitly stated not to
32  // be installed in the InstallShortcutPreferences).
33  INSTALL_SHORTCUT_CREATE_ALL,
34  // Create each per-user shortcut (potentially skipping those explicitly stated
35  // not to be installed in the InstallShortcutPreferences), but only if the
36  // system-level equivalent of that shortcut is not present on the system.
37  INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL,
38  // Replace all shortcuts that still exist with the most recent version of
39  // each individual shortcut.
40  INSTALL_SHORTCUT_REPLACE_EXISTING,
41};
42
43enum InstallShortcutLevel {
44  // Install shortcuts for the current user only.
45  CURRENT_USER,
46  // Install global shortcuts visible to all users. Note: the Quick Launch
47  // and taskbar pin shortcuts are still installed per-user (as they have no
48  // all-users version).
49  ALL_USERS,
50};
51
52// Escape |att_value| as per the XML AttValue production
53// (http://www.w3.org/TR/2008/REC-xml-20081126/#NT-AttValue) for a value in
54// single quotes.
55void EscapeXmlAttributeValueInSingleQuotes(base::string16* att_value);
56
57// Creates VisualElementsManifest.xml beside chrome.exe in |src_path| if
58// |src_path|\VisualElements exists.
59// Returns true unless the manifest is supposed to be created, but fails to be.
60bool CreateVisualElementsManifest(const base::FilePath& src_path,
61                                  const Version& version);
62
63// Overwrites shortcuts (desktop, quick launch, and start menu) if they are
64// present on the system.
65// |prefs| can affect the behavior of this method through
66// kDoNotCreateDesktopShortcut, kDoNotCreateQuickLaunchShortcut, and
67// kAltShortcutText.
68// |install_level| specifies whether to install per-user shortcuts or shortcuts
69// for all users on the system (this should only be used to update legacy
70// system-level installs).
71// If |install_operation| is a creation command, appropriate shortcuts will be
72// created even if they don't exist.
73// If creating the Start menu shortcut is successful, it is also pinned to the
74// taskbar.
75void CreateOrUpdateShortcuts(
76    const base::FilePath& target,
77    const Product& product,
78    const MasterPreferences& prefs,
79    InstallShortcutLevel install_level,
80    InstallShortcutOperation install_operation);
81
82// Registers Chrome on this machine.
83// If |make_chrome_default|, also attempts to make Chrome default where doing so
84// requires no more user interaction than a UAC prompt. In practice, this means
85// on versions of Windows prior to Windows 8.
86void RegisterChromeOnMachine(const InstallerState& installer_state,
87                             const Product& product,
88                             bool make_chrome_default);
89
90// This function installs or updates a new version of Chrome. It returns
91// install status (failed, new_install, updated etc).
92//
93// setup_path: Path to the executable (setup.exe) as it will be copied
94//           to Chrome install folder after install is complete
95// archive_path: Path to the archive (chrome.7z) as it will be copied
96//               to Chrome install folder after install is complete
97// install_temp_path: working directory used during install/update. It should
98//                    also has a sub dir source that contains a complete
99//                    and unpacked Chrome package.
100// src_path: the unpacked Chrome package (inside |install_temp_path|).
101// prefs: master preferences. See chrome/installer/util/master_preferences.h.
102// new_version: new Chrome version that needs to be installed
103// package: Represents the target installation folder and all distributions
104//          to be installed in that folder.
105//
106// Note: since caller unpacks Chrome to install_temp_path\source, the caller
107// is responsible for cleaning up install_temp_path.
108InstallStatus InstallOrUpdateProduct(
109    const InstallationState& original_state,
110    const InstallerState& installer_state,
111    const base::FilePath& setup_path,
112    const base::FilePath& archive_path,
113    const base::FilePath& install_temp_path,
114    const base::FilePath& src_path,
115    const base::FilePath& prefs_path,
116    const installer::MasterPreferences& prefs,
117    const Version& new_version);
118
119// Performs installation-related tasks following an OS upgrade.
120// |chrome| The installed product (must be a browser).
121void HandleOsUpgradeForBrowser(const InstallerState& installer_state,
122                               const Product& chrome);
123
124// Performs per-user installation-related tasks on Active Setup (ran on first
125// login for each user post system-level Chrome install).
126// |installation_root|: The root of this install (i.e. the directory in which
127// chrome.exe is installed).
128// Shortcut creation is skipped if the First Run beacon is present (unless
129// |force| is set to true).
130// |chrome| The installed product (must be a browser).
131void HandleActiveSetupForBrowser(const base::FilePath& installation_root,
132                                 const Product& chrome,
133                                 bool force);
134
135// Launches app_host.exe to install content from web store (non-blocking).
136// Returns true on successful execution (although successful installation
137// is not guaranteed).
138bool InstallFromWebstore(const std::string& app_code);
139
140}  // namespace installer
141
142#endif  // CHROME_INSTALLER_SETUP_INSTALL_H_
143