15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file declares methods that are useful for integrating Chrome in
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Windows shell. These methods are all static and currently part of
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ShellUtil class.
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <windows.h>
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <map>
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <utility>
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/logging.h"
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/ref_counted.h"
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h"
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/installer/util/work_item_list.h"
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BrowserDistribution;
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace base {
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CancellationFlag;
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This is a utility class that provides common shell integration methods
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// that can be used by installer as well as Chrome.
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ShellUtil {
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Input to any methods that make changes to OS shell.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum ShellChange {
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    CURRENT_USER = 0x1,  // Make any shell changes only at the user level
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SYSTEM_LEVEL = 0x2   // Make any shell changes only at the system level
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Chrome's default handler state for a given protocol.
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum DefaultState {
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    UNKNOWN_DEFAULT,
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    NOT_DEFAULT,
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    IS_DEFAULT,
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Typical shortcut directories. Resolved in GetShortcutPath().
49c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Also used in ShortcutLocationIsSupported().
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum ShortcutLocation {
51a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    SHORTCUT_LOCATION_FIRST = 0,
52a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    SHORTCUT_LOCATION_DESKTOP = SHORTCUT_LOCATION_FIRST,
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SHORTCUT_LOCATION_QUICK_LAUNCH,
54a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    SHORTCUT_LOCATION_START_MENU_ROOT,
55a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    SHORTCUT_LOCATION_START_MENU_CHROME_DIR,
56a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR,
57c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    SHORTCUT_LOCATION_TASKBAR_PINS,  // base::win::VERSION_WIN7 +
58c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    SHORTCUT_LOCATION_APP_SHORTCUTS,  // base::win::VERSION_WIN8 +
59a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    NUM_SHORTCUT_LOCATIONS
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum ShortcutOperation {
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Create a new shortcut (overwriting if necessary).
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SHELL_SHORTCUT_CREATE_ALWAYS,
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // Create the per-user shortcut only if its system-level equivalent (with
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // the same name) is not present.
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL,
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Overwrite an existing shortcut (fail if the shortcut doesn't exist).
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // If the arguments are not specified on the new shortcut, keep the old
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // shortcut's arguments.
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SHELL_SHORTCUT_REPLACE_EXISTING,
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Update specified properties only on an existing shortcut.
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SHELL_SHORTCUT_UPDATE_EXISTING,
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Properties for shortcuts. Properties set will be applied to
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the shortcut on creation/update. On update, unset properties are ignored;
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // on create (and replaced) unset properties might have a default value (see
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // individual property setters below for details).
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Callers are encouraged to use the setters provided which take care of
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // setting |options| as desired.
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  struct ShortcutProperties {
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    enum IndividualProperties {
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      PROPERTIES_TARGET = 1 << 0,
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      PROPERTIES_ARGUMENTS = 1 << 1,
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      PROPERTIES_DESCRIPTION = 1 << 2,
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      PROPERTIES_ICON = 1 << 3,
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      PROPERTIES_APP_ID = 1 << 4,
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      PROPERTIES_SHORTCUT_NAME = 1 << 5,
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      PROPERTIES_DUAL_MODE = 1 << 6,
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    };
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    explicit ShortcutProperties(ShellChange level_in)
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        : level(level_in), icon_index(0), dual_mode(false),
95f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)          pin_to_taskbar(false), options(0U) {}
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Sets the target executable to launch from this shortcut.
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // This is mandatory when creating a shortcut.
992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    void set_target(const base::FilePath& target_in) {
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      target = target_in;
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      options |= PROPERTIES_TARGET;
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Sets the arguments to be passed to |target| when launching from this
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // shortcut.
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // The length of this string must be less than MAX_PATH.
1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    void set_arguments(const base::string16& arguments_in) {
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      // Size restriction as per MSDN at
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      // http://msdn.microsoft.com/library/windows/desktop/bb774954.aspx.
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      DCHECK(arguments_in.length() < MAX_PATH);
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      arguments = arguments_in;
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      options |= PROPERTIES_ARGUMENTS;
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Sets the localized description of the shortcut.
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // The length of this string must be less than MAX_PATH.
1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    void set_description(const base::string16& description_in) {
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      // Size restriction as per MSDN at
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      // http://msdn.microsoft.com/library/windows/desktop/bb774955.aspx.
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      DCHECK(description_in.length() < MAX_PATH);
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      description = description_in;
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      options |= PROPERTIES_DESCRIPTION;
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Sets the path to the icon (icon_index set to 0).
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // icon index unless otherwise specified in master_preferences).
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    void set_icon(const base::FilePath& icon_in, int icon_index_in) {
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      icon = icon_in;
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      icon_index = icon_index_in;
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      options |= PROPERTIES_ICON;
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Sets the app model id for the shortcut (Win7+).
1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    void set_app_id(const base::string16& app_id_in) {
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      app_id = app_id_in;
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      options |= PROPERTIES_APP_ID;
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Forces the shortcut's name to |shortcut_name_in|.
1403551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    // Default: the current distribution's GetShortcutName(SHORTCUT_CHROME).
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // The ".lnk" extension will automatically be added to this name.
1425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    void set_shortcut_name(const base::string16& shortcut_name_in) {
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      shortcut_name = shortcut_name_in;
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      options |= PROPERTIES_SHORTCUT_NAME;
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Sets whether this is a dual mode shortcut (Win8+).
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // NOTE: Only the default (no arguments and default browser appid) browser
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // shortcut in the Start menu (Start screen on Win8+) should be made dual
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // mode.
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    void set_dual_mode(bool dual_mode_in) {
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      dual_mode = dual_mode_in;
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      options |= PROPERTIES_DUAL_MODE;
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Sets whether to pin this shortcut to the taskbar after creating it
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // (ignored if the shortcut is only being updated).
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Note: This property doesn't have a mask in |options|.
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    void set_pin_to_taskbar(bool pin_to_taskbar_in) {
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      pin_to_taskbar = pin_to_taskbar_in;
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool has_target() const {
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return (options & PROPERTIES_TARGET) != 0;
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool has_arguments() const {
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return (options & PROPERTIES_ARGUMENTS) != 0;
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool has_description() const {
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return (options & PROPERTIES_DESCRIPTION) != 0;
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool has_icon() const {
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return (options & PROPERTIES_ICON) != 0;
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool has_app_id() const {
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return (options & PROPERTIES_APP_ID) != 0;
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool has_shortcut_name() const {
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return (options & PROPERTIES_SHORTCUT_NAME) != 0;
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool has_dual_mode() const {
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return (options & PROPERTIES_DUAL_MODE) != 0;
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // The level to install this shortcut at (CURRENT_USER for a per-user
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // shortcut and SYSTEM_LEVEL for an all-users shortcut).
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ShellChange level;
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    base::FilePath target;
1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::string16 arguments;
1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::string16 description;
1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    base::FilePath icon;
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    int icon_index;
2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::string16 app_id;
2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::string16 shortcut_name;
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool dual_mode;
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    bool pin_to_taskbar;
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // Bitfield made of IndividualProperties. Properties set in |options| will
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // be used to create/update the shortcut, others will be ignored on update
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // and possibly replaced by default values on create (see individual
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // property setters above for details on default values).
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    uint32 options;
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Relative path of the URL Protocol registry entry (prefixed with '\').
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegURLProtocol;
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Relative path of DefaultIcon registry entry (prefixed with '\').
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegDefaultIcon;
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Relative path of "shell" registry key.
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegShellPath;
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Relative path of shell open command in Windows registry
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (i.e. \\shell\\open\\command).
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegShellOpen;
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Relative path of registry key under which applications need to register
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to control Windows Start menu links.
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegStartMenuInternet;
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Relative path of Classes registry entry under which file associations
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // are added on Windows.
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegClasses;
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Relative path of RegisteredApplications registry entry under which
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // we add Chrome as a Windows application
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegRegisteredApplications;
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The key path and key name required to register Chrome on Windows such
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // that it can be launched from Start->Run just by name (chrome.exe).
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kAppPathsRegistryKey;
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kAppPathsRegistryPathName;
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry path that stores url associations on Vista.
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegVistaUrlPrefs;
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
244c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // File extensions that Chrome registers itself as the default handler
245c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // for when the user makes Chrome the default browser.
246c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  static const wchar_t* kDefaultFileAssociations[];
247c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
248c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // File extensions that Chrome registers itself as being capable of
249c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // handling.
250c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  static const wchar_t* kPotentialFileAssociations[];
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Protocols that Chrome registers itself as the default handler for
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // when the user makes Chrome the default browser.
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kBrowserProtocolAssociations[];
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Protocols that Chrome registers itself as being capable of handling.
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kPotentialProtocolAssociations[];
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name that is needed for ChromeHTML ProgId
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegUrlProtocol;
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Relative registry path from \Software\Classes\ChromeHTML to the ProgId
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Application definitions.
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegApplication;
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name for the AppUserModelId of an application.
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegAppUserModelId;
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name for the description of an application.
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegApplicationDescription;
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name for an application's name.
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegApplicationName;
2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name for the path to an application's icon.
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegApplicationIcon;
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name for an application's company.
2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegApplicationCompany;
2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Relative path of ".exe" registry key.
2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegExePath;
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name of the open verb.
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegVerbOpen;
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name of the opennewwindow verb.
2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegVerbOpenNewWindow;
2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name of the run verb.
2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegVerbRun;
2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name for command entries.
2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegCommand;
2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name for the DelegateExecute verb handler.
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegDelegateExecute;
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registry value name for the OpenWithProgids entry for file associations.
3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const wchar_t* kRegOpenWithProgids;
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if |chrome_exe| is registered in HKLM with |suffix|.
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note: This only checks one deterministic key in HKLM for |chrome_exe| and
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // doesn't otherwise validate a full Chrome install in HKLM.
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist,
3065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                            const base::string16& chrome_exe,
3075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                            const base::string16& suffix);
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
309c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Returns true if the current Windows version supports the presence of
310c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // shortcuts at |location|.
311c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  static bool ShortcutLocationIsSupported(ShellUtil::ShortcutLocation location);
312c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets |path| to the path for a shortcut at the |location| desired for the
3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // all-users path).
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns false on failure.
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool GetShortcutPath(ShellUtil::ShortcutLocation location,
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              BrowserDistribution* dist,
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              ShellChange level,
3202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                              base::FilePath* path);
3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Updates shortcut in |location| (or creates it if |options| specify
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // SHELL_SHORTCUT_CREATE_ALWAYS).
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |dist| gives the type of browser distribution currently in use.
3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |properties| and |operation| affect this method as described on their
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // invidividual definitions above.
327c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // |location| may be one of SHORTCUT_LOCATION_DESKTOP,
328a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // SHORTCUT_LOCATION_QUICK_LAUNCH, SHORTCUT_LOCATION_START_MENU_ROOT,
329a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // SHORTCUT_LOCATION_START_MENU_CHROME_DIR, or
330a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR.
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool CreateOrUpdateShortcut(
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      ShellUtil::ShortcutLocation location,
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      BrowserDistribution* dist,
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const ShellUtil::ShortcutProperties& properties,
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      ShellUtil::ShortcutOperation operation);
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns the string "|icon_path|,|icon_index|" (see, for example,
3382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx).
3395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static base::string16 FormatIconLocation(const base::string16& icon_path,
3405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                           int icon_index);
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method returns the command to open URLs/files using chrome. Typically
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // this command is written to the registry under shell\open\command key.
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |chrome_exe|: the full path to chrome.exe
3455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static base::string16 GetChromeShellOpenCmd(const base::string16& chrome_exe);
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method returns the command to be called by the DelegateExecute verb
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // handler to launch chrome on Windows 8. Typically this command is written to
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the registry under the HKCR\Chrome\.exe\shell\(open|run)\command key.
3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |chrome_exe|: the full path to chrome.exe
3515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static base::string16 GetChromeDelegateCommand(
3525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const base::string16& chrome_exe);
3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Gets a mapping of all registered browser names (excluding browsers in the
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |dist| distribution) and their reinstall command (which usually sets
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // browser as default).
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Given browsers can be registered in HKCU (as of Win7) and/or in HKLM, this
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // method looks in both and gives precedence to values in HKCU as per the msdn
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // standard: http://goo.gl/xjczJ.
3605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static void GetRegisteredBrowsers(
3615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      BrowserDistribution* dist,
3625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      std::map<base::string16, base::string16>* browsers);
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the suffix this user's Chrome install is registered with.
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Always returns the empty string on system-level installs.
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method is meant for external methods which need to know the suffix of
3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the current install at run-time, not for install-time decisions.
3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // There are no guarantees that this suffix will not change later:
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (e.g. if two user-level installs were previously installed in parallel on
3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the same machine, both without admin rights and with no user-level install
3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // having claimed the non-suffixed HKLM registrations, they both have no
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // suffix in their progId entries (as per the old suffix rules). If they were
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to both fully register (i.e. click "Make Chrome Default" and go through
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // UAC; or upgrade to Win8 and get the automatic no UAC full registration)
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // they would then both get a suffixed registration as per the new suffix
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // rules).
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |chrome_exe| The path to the currently installed (or running) chrome.exe.
3805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static base::string16 GetCurrentInstallationSuffix(
3815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      BrowserDistribution* dist,
3825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const base::string16& chrome_exe);
3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the application name of the program under |dist|.
3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This application name will be suffixed as is appropriate for the current
3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // install.
3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the name that is registered with Default Programs on Windows and
3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // that should thus be used to "make chrome default" and such.
3895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static base::string16 GetApplicationName(BrowserDistribution* dist,
3905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                           const base::string16& chrome_exe);
3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the AppUserModelId for |dist|. This identifier is unconditionally
3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // suffixed with a unique id for this user on user-level installs (in contrast
3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to other registration entries which are suffixed as described in
3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // GetCurrentInstallationSuffix() above).
3965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static base::string16 GetBrowserModelId(BrowserDistribution* dist,
3975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                          bool is_per_user_install);
3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns an AppUserModelId composed of each member of |components| separated
4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // by dots.
4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The returned appid is guaranteed to be no longer than
4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // chrome::kMaxAppModelIdLength (some of the components might have been
4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // shortened to enforce this).
4045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static base::string16 BuildAppModelId(
4055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const std::vector<base::string16>& components);
4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if Chrome can make itself the default browser without relying
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // on the Windows shell to prompt the user. This is the case for versions of
4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Windows prior to Windows 8.
4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool CanMakeChromeDefaultUnattended();
4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the DefaultState of Chrome for HTTP and HTTPS.
4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static DefaultState GetChromeDefaultState();
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Returns the DefaultState of the Chrome instance with the specified path
416a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // for HTTP and HTTPs.
417a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  static DefaultState GetChromeDefaultStateFromPath(
418a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      const base::FilePath& chrome_exe);
419a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the DefaultState of Chrome for |protocol|.
4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static DefaultState GetChromeDefaultProtocolClientState(
4225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const base::string16& protocol);
4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Make Chrome the default browser. This function works by going through
4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the url protocols and file associations that are related to general
4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // browsing, e.g. http, https, .html etc., and requesting to become the
4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // default handler for each. If any of these fails the operation will return
4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // false to indicate failure, which is consistent with the return value of
4292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // ShellIntegration::GetDefaultBrowser.
4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // In the case of failure any successful changes will be left, however no
4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // more changes will be attempted.
4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(benwells): Attempt to undo any changes that were successfully made.
4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // http://crbug.com/83970
4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // shell_change: Defined whether to register as default browser at system
4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //               level or user level. If value has ShellChange::SYSTEM_LEVEL
4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //               we should be running as admin user.
4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // chrome_exe: The chrome.exe path to register as default browser.
4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // elevate_if_not_admin: On Vista if user is not admin, try to elevate for
4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //                       Chrome registration.
4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool MakeChromeDefault(BrowserDistribution* dist,
4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                int shell_change,
4445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                const base::string16& chrome_exe,
4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                bool elevate_if_not_admin);
4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Shows and waits for the Windows 8 "How do you want to open webpages?"
4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // dialog if Chrome is not already the default HTTP/HTTPS handler. Also does
4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // XP-era registrations if Chrome is chosen or was already the default. Do
4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // not use on pre-Win8 OSes.
4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |dist| gives the type of browser distribution currently in use.
4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |chrome_exe| The chrome.exe path to register as default browser.
4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool ShowMakeChromeDefaultSystemUI(BrowserDistribution* dist,
4555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                            const base::string16& chrome_exe);
4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Make Chrome the default application for a protocol.
4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // chrome_exe: The chrome.exe path to register as default browser.
4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // protocol: The protocol to register as the default handler for.
4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool MakeChromeDefaultProtocolClient(BrowserDistribution* dist,
4615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                              const base::string16& chrome_exe,
4625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                              const base::string16& protocol);
4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Shows and waits for the Windows 8 "How do you want to open links of this
4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // type?" dialog if Chrome is not already the default |protocol|
4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // handler. Also does XP-era registrations if Chrome is chosen or was already
4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the default for |protocol|. Do not use on pre-Win8 OSes.
4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |dist| gives the type of browser distribution currently in use.
4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |chrome_exe| The chrome.exe path to register as default browser.
4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |protocol| is the protocol being registered.
4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool ShowMakeChromeDefaultProtocolClientSystemUI(
4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      BrowserDistribution* dist,
4745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const base::string16& chrome_exe,
4755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const base::string16& protocol);
4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Registers Chrome as a potential default browser and handler for filetypes
4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and protocols.
4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If Chrome is already registered, this method is a no-op.
4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method requires write access to HKLM (prior to Win8) so is just a
4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // best effort deal.
4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If write to HKLM is required, but fails, and:
4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // - |elevate_if_not_admin| is true (and OS is Vista or above):
4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   tries to launch setup.exe with admin priviledges (by prompting the user
4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   with a UAC) to do these tasks.
4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // - |elevate_if_not_admin| is false (or OS is XP):
4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   adds the ProgId entries to HKCU. These entries will not make Chrome show
4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   in Default Programs but they are still useful because Chrome can be
4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //   registered to run when the user clicks on an http link or an html file.
4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |chrome_exe| full path to chrome.exe.
4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |unique_suffix| Optional input. If given, this function appends the value
4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to default browser entries names that it creates in the registry.
4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Currently, this is only used to continue an install with the same suffix
4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // when elevating and calling setup.exe with admin privileges as described
4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // above.
4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |elevate_if_not_admin| if true will make this method try alternate methods
4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // as described above. This should only be true when following a user action
4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (e.g. "Make Chrome Default") as it allows this method to UAC.
5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true if Chrome is successfully registered (or already registered).
5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool RegisterChromeBrowser(BrowserDistribution* dist,
5035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                    const base::string16& chrome_exe,
5045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                    const base::string16& unique_suffix,
5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    bool elevate_if_not_admin);
5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This method declares to Windows that Chrome is capable of handling the
5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // given protocol. This function will call the RegisterChromeBrowser function
5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to register with Windows as capable of handling the protocol, if it isn't
5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // currently registered as capable.
5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Declaring the capability of handling a protocol is necessary to register
5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // as the default handler for the protocol in Vista and later versions of
5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Windows.
5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If called by the browser and elevation is required, it will elevate by
5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // calling setup.exe which will again call this function with elevate false.
5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |chrome_exe| full path to chrome.exe.
5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |unique_suffix| Optional input. If given, this function appends the value
5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to default browser entries names that it creates in the registry.
5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |protocol| The protocol to register as being capable of handling.s
5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |elevate_if_not_admin| if true will make this method try alternate methods
5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // as described above.
5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static bool RegisterChromeForProtocol(BrowserDistribution* dist,
5255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                        const base::string16& chrome_exe,
5265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                        const base::string16& unique_suffix,
5275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                        const base::string16& protocol,
5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        bool elevate_if_not_admin);
5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Removes installed shortcut(s) at |location|.
531c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to
532c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // remove all-users shortcuts.
5332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |target_exe|: Shortcut target exe; shortcuts will only be deleted when
5342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // their target is |target_exe|.
535a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // If |location| is a Chrome-specific folder, it will be deleted as well.
536c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Returns true if all shortcuts pointing to |target_exe| are successfully
537c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // deleted, including the case where no such shortcuts are found.
538c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  static bool RemoveShortcuts(ShellUtil::ShortcutLocation location,
539c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                              BrowserDistribution* dist,
540c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                              ShellChange level,
541c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                              const base::FilePath& target_exe);
542c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
5435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Updates the target of all shortcuts in |location| that satisfy the
5445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // following:
5455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // - the shortcut's original target is |old_target_exe|,
546d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // - the original arguments are non-empty.
5475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // If the shortcut's icon points to |old_target_exe|, then it also gets
5485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // redirected to |new_target_exe|.
54958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // Returns true if all updates to matching shortcuts are successful, including
55058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // the vacuous case where no matching shortcuts are found.
5515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static bool RetargetShortcutsWithArgs(
5525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ShellUtil::ShortcutLocation location,
5535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      BrowserDistribution* dist,
5545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ShellChange level,
5555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const base::FilePath& old_target_exe,
5565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const base::FilePath& new_target_exe);
5575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
5585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  typedef base::RefCountedData<base::CancellationFlag> SharedCancellationFlag;
5595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
5605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Appends Chrome shortcuts with non-whitelisted arguments to |shortcuts| if
5615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // not NULL. If |do_removal|, also removes non-whitelisted arguments from
5625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // those shortcuts. This method will abort and return false if |cancel| is
5635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // non-NULL and gets set at any point during this call.
5645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static bool ShortcutListMaybeRemoveUnknownArgs(
565c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      ShellUtil::ShortcutLocation location,
566c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      BrowserDistribution* dist,
567c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      ShellChange level,
5685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const base::FilePath& chrome_exe,
5695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      bool do_removal,
5705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const scoped_refptr<SharedCancellationFlag>& cancel,
5715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      std::vector<std::pair<base::FilePath, base::string16> >* shortcuts);
5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets |suffix| to the base 32 encoding of the md5 hash of this user's sid
5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // preceded by a dot.
5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is guaranteed to be unique on the machine and 27 characters long
5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // (including the '.').
5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This suffix is then meant to be added to all registration that may conflict
5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // with another user-level Chrome install.
5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note that prior to Chrome 21, the suffix registered used to be the user's
5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old
5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // installs registered that way, but it was wrong because some of the
5825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // characters allowed in a username are not allowed in a ProgId.
5835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true unless the OS call to retrieve the username fails.
5845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NOTE: Only the installer should use this suffix directly. Other callers
5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // should call GetCurrentInstallationSuffix().
5865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static bool GetUserSpecificRegistrySuffix(base::string16* suffix);
5875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets |suffix| to this user's username preceded by a dot. This suffix should
5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // only be used to support legacy installs that used this suffixing
5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // style.
5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns true unless the OS call to retrieve the username fails.
5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NOTE: Only the installer should use this suffix directly. Other callers
5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // should call GetCurrentInstallationSuffix().
5945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static bool GetOldUserSpecificRegistrySuffix(base::string16* suffix);
5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the base32 encoding (using the [A-Z2-7] alphabet) of |bytes|.
5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |size| is the length of |bytes|.
5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Note: This method does not suffix the output with '=' signs as technically
5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // required by the base32 standard for inputs that aren't a multiple of 5
6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // bytes.
6015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static base::string16 ByteArrayToBase32(const uint8* bytes, size_t size);
6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
6045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(ShellUtil);
6055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
6065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
609