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 [ $
(uname
-s) == "Darwin" ]; then
50 register_hosts
"${build_dir}" \
51 "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts"
52 register_hosts
"${build_dir}" \
53 "${HOME}/Library/Application Support/Chromium/NativeMessagingHosts"
55 register_hosts
"${build_dir}" \
56 "${HOME}/.config/google-chrome/NativeMessagingHosts"
57 register_hosts
"${build_dir}" \
58 "${HOME}/.config/google-chrome-beta/NativeMessagingHosts"
59 register_hosts
"${build_dir}" \
60 "${HOME}/.config/google-chrome-unstable/NativeMessagingHosts"
61 register_hosts
"${build_dir}" \
62 "${HOME}/.config/chromium/NativeMessagingHosts"
67 local chrome_data_dir
="$1"
69 rm -f "${chrome_data_dir}/${ME2ME_HOST_NAME}.json"
70 rm -f "${chrome_data_dir}/${IT2ME_HOST_NAME}.json"
73 unregister_hosts_for_all_channels
() {
74 if [ $
(uname
-s) == "Darwin" ]; then
76 "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts"
78 "${HOME}/Library/Application Support/Chromium/NativeMessagingHosts"
80 unregister_hosts
"${HOME}/.config/google-chrome/NativeMessagingHosts"
81 unregister_hosts
"${HOME}/.config/google-chrome-beta/NativeMessagingHosts"
83 "${HOME}/.config/google-chrome-unstable/NativeMessagingHosts"
84 unregister_hosts
"${HOME}/.config/chromium/NativeMessagingHosts"
89 echo "Usage: $0 [-r|-u]" >&2
90 echo " -r Register Release build instead of Debug" >&2
91 echo " -u Unregister" >&2
96 if [[ $# -gt 1 ]]; then
98 elif [[ $# -eq 1 ]]; then
104 unregister_hosts_for_all_channels
114 register_hosts_for_all_channels
"${SRC_DIR}/out/${build_dir}"