2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
8 DIR
="$( cd "$
( dirname "$0" )" && pwd )"
9 if [ "$(uname -s)" == "Darwin" ]; then
10 if [ "$(whoami)" == "root" ]; then
11 TARGET_DIR
="/Library/Google/Chrome/NativeMessagingHosts"
13 TARGET_DIR
="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts"
16 if [ "$(whoami)" == "root" ]; then
17 TARGET_DIR
="/etc/opt/chrome/native-messaging-hosts"
19 TARGET_DIR
="$HOME/.config/google-chrome/NativeMessagingHosts"
23 HOST_NAME
=com.google.chrome.example.
echo
25 # Create directory to store native messaging host.
26 mkdir
-p "$TARGET_DIR"
28 # Copy native messaging host manifest.
29 cp "$DIR/$HOST_NAME.json" "$TARGET_DIR"
31 # Update host path in the manifest.
32 HOST_PATH
=$DIR/native-messaging-example-host
33 ESCAPED_HOST_PATH
=${HOST_PATH////\\/}
34 sed -i -e "s/HOST_PATH/$ESCAPED_HOST_PATH/" "$TARGET_DIR/$HOST_NAME.json"
36 # Set permissions for the manifest so that all users can read it.
37 chmod o
+r
"$TARGET_DIR/$HOST_NAME.json"
39 echo "Native messaging host $HOST_NAME has been installed."