1 #!/bin/bash 2 # 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 # Use of this source code is governed by a BSD-style license that can be 5 # found in the LICENSE file. 6 7 # Let the wrapped binary know that it has been run through the wrapper. 8 export CHROME_WRAPPER="`readlink -f "$0"`" 9 10 HERE="`dirname "$CHROME_WRAPPER"`" 11 12 # Check if the CPU supports SSE2. If not, try to pop up a dialog to explain the 13 # problem and exit. Otherwise the browser will just crash with a SIGILL. 14 # http://crbug.com/348761 15 grep ^flags /proc/cpuinfo|grep -qs sse2 16 if [ $? != 0 ]; then 17 SSE2_DEPRECATION_MSG="This computer can no longer run Google Chrome because \ 18 its hardware is no longer supported." 19 if which zenity &> /dev/null; then 20 zenity --warning --text="$SSE2_DEPRECATION_MSG" 21 elif which gmessage &> /dev/null; then 22 gmessage "$SSE2_DEPRECATION_MSG" 23 elif which xmessage &> /dev/null; then 24 xmessage "$SSE2_DEPRECATION_MSG" 25 else 26 echo "$SSE2_DEPRECATION_MSG" 1>&2 27 fi 28 exit 1 29 fi 30 31 # We include some xdg utilities next to the binary, and we want to prefer them 32 # over the system versions when we know the system versions are very old. We 33 # detect whether the system xdg utilities are sufficiently new to be likely to 34 # work for us by looking for xdg-settings. If we find it, we leave $PATH alone, 35 # so that the system xdg utilities (including any distro patches) will be used. 36 if ! which xdg-settings &> /dev/null; then 37 # Old xdg utilities. Prepend $HERE to $PATH to use ours instead. 38 export PATH="$HERE:$PATH" 39 else 40 # Use system xdg utilities. But first create mimeapps.list if it doesn't 41 # exist; some systems have bugs in xdg-mime that make it fail without it. 42 xdg_app_dir="${XDG_DATA_HOME:-$HOME/.local/share/applications}" 43 mkdir -p "$xdg_app_dir" 44 [ -f "$xdg_app_dir/mimeapps.list" ] || touch "$xdg_app_dir/mimeapps.list" 45 fi 46 47 # Always use our versions of ffmpeg libs. 48 # This also makes RPMs find the compatibly-named library symlinks. 49 if [[ -n "$LD_LIBRARY_PATH" ]]; then 50 LD_LIBRARY_PATH="$HERE:$HERE/lib:$LD_LIBRARY_PATH" 51 else 52 LD_LIBRARY_PATH="$HERE:$HERE/lib" 53 fi 54 export LD_LIBRARY_PATH 55 56 export CHROME_VERSION_EXTRA="@@CHANNEL@@" 57 58 # We don't want bug-buddy intercepting our crashes. http://crbug.com/24120 59 export GNOME_DISABLE_CRASH_DIALOG=SET_BY_GOOGLE_CHROME 60 61 # Automagically migrate user data directory. 62 # TODO(phajdan.jr): Remove along with migration code in the browser for M33. 63 if [[ -n "@@SXS_USER_DATA_DIR@@" ]]; then 64 if [[ ! -d "@@SXS_USER_DATA_DIR@@" ]]; then 65 "$HERE/@@PROGNAME@@" "--migrate-data-dir-for-sxs=@@SXS_USER_DATA_DIR@@" \ 66 --enable-logging=stderr --log-level=0 67 fi 68 fi 69 70 # Make sure that the profile directory specified in the environment, if any, 71 # overrides the default. 72 if [[ -n "$CHROME_USER_DATA_DIR" ]]; then 73 PROFILE_DIRECTORY_FLAG="--user-data-dir=$CHROME_USER_DATA_DIR" 74 fi 75 76 # Sanitize std{in,out,err} because they'll be shared with untrusted child 77 # processes (http://crbug.com/376567). 78 exec < /dev/null 79 exec > >(exec cat) 80 exec 2> >(exec cat >&2) 81 82 # Note: exec -a below is a bashism. 83 exec -a "$0" "$HERE/@@PROGNAME@@" @@DEFAULT_FLAGS@@ "$PROFILE_DIRECTORY_FLAG" \ 84 "$@" 85