2 # Copyright 2014 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.
6 # Script that can be used to register native messaging hosts in the output
11 SRC_DIR
="$(readlink -f "$
(dirname "$0")/..
/..
")"
12 ME2ME_HOST_NAME
="com.google.chrome.remote_desktop"
13 IT2ME_HOST_NAME
="com.google.chrome.remote_assistance"
16 local manifest_template
="$1"
18 local host_path_var_name
="$3"
21 local template_name
="$(basename ${manifest_template})"
22 local manifest_name
="${template_name%.*}"
23 local target_manifest
="${target_dir}/${manifest_name}"
25 echo Registering
${host_path} in ${target_manifest}
26 mkdir
-p "${target_dir}"
27 sed -e "s#{{ ${host_path_var_name} }}#${host_path}#g" \
28 < "$manifest_template" > "$target_manifest"
33 local chrome_data_dir
="$2"
36 "${SRC_DIR}/remoting/host/setup/${ME2ME_HOST_NAME}.json.jinja2" \
37 "${build_dir}/native_messaging_host" \
38 ME2ME_HOST_PATH
"${chrome_data_dir}"
41 "${SRC_DIR}/remoting/host/it2me/${IT2ME_HOST_NAME}.json.jinja2" \
42 "${build_dir}/remote_assistance_host" \
43 IT2ME_HOST_PATH
"${chrome_data_dir}"
46 register_hosts_for_all_channels
() {
49 if [ -n "$CHROME_USER_DATA_DIR" ]; then
50 register_hosts
"${build_dir}" \
51 "${CHROME_USER_DATA_DIR}/NativeMessagingHosts"
52 elif [ $
(uname
-s) == "Darwin" ]; then
53 register_hosts
"${build_dir}" \
54 "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts"
55 register_hosts
"${build_dir}" \
56 "${HOME}/Library/Application Support/Chromium/NativeMessagingHosts"
58 register_hosts
"${build_dir}" \
59 "${HOME}/.config/google-chrome/NativeMessagingHosts"
60 register_hosts
"${build_dir}" \
61 "${HOME}/.config/google-chrome-beta/NativeMessagingHosts"
62 register_hosts
"${build_dir}" \
63 "${HOME}/.config/google-chrome-unstable/NativeMessagingHosts"
64 register_hosts
"${build_dir}" \
65 "${HOME}/.config/chromium/NativeMessagingHosts"
70 local chrome_data_dir
="$1"
72 rm -f "${chrome_data_dir}/${ME2ME_HOST_NAME}.json"
73 rm -f "${chrome_data_dir}/${IT2ME_HOST_NAME}.json"
76 unregister_hosts_for_all_channels
() {
77 if [ -n "$CHROME_USER_DATA_DIR" ]; then
79 "${CHROME_USER_DATA_DIR}/NativeMessagingHosts"
80 elif [ $
(uname
-s) == "Darwin" ]; then
82 "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts"
84 "${HOME}/Library/Application Support/Chromium/NativeMessagingHosts"
86 unregister_hosts
"${HOME}/.config/google-chrome/NativeMessagingHosts"
87 unregister_hosts
"${HOME}/.config/google-chrome-beta/NativeMessagingHosts"
89 "${HOME}/.config/google-chrome-unstable/NativeMessagingHosts"
90 unregister_hosts
"${HOME}/.config/chromium/NativeMessagingHosts"
95 echo "Usage: $0 [-r|-u]" >&2
96 echo " -r Register Release build instead of Debug" >&2
97 echo " -u Unregister" >&2
102 if [[ $# -gt 1 ]]; then
104 elif [[ $# -eq 1 ]]; then
110 unregister_hosts_for_all_channels
120 register_hosts_for_all_channels
"${SRC_DIR}/out/${build_dir}"