Hookup the PDF extension to the chrome extensions zoom API
[chromium-blink-merge.git] / remoting / tools / register_local_nm_hosts.sh
blob8a0b2537f1d1774e19b8907b17303a4258424b15
1 #!/bin/sh
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
7 # directory.
9 set -e
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"
15 install_manifest() {
16 local manifest_template="$1"
17 local host_path="$2"
18 local host_path_var_name="$3"
19 local target_dir="$4"
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"
31 register_hosts() {
32 local build_dir="$1"
33 local chrome_data_dir="$2"
35 install_manifest \
36 "${SRC_DIR}/remoting/host/setup/${ME2ME_HOST_NAME}.json.jinja2" \
37 "${build_dir}/native_messaging_host" \
38 ME2ME_HOST_PATH "${chrome_data_dir}"
40 install_manifest \
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() {
47 local build_dir="$1"
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"
54 else
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"
66 unregister_hosts() {
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
75 unregister_hosts \
76 "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts"
77 unregister_hosts \
78 "${HOME}/Library/Application Support/Chromium/NativeMessagingHosts"
79 else
80 unregister_hosts "${HOME}/.config/google-chrome/NativeMessagingHosts"
81 unregister_hosts "${HOME}/.config/google-chrome-beta/NativeMessagingHosts"
82 unregister_hosts \
83 "${HOME}/.config/google-chrome-unstable/NativeMessagingHosts"
84 unregister_hosts "${HOME}/.config/chromium/NativeMessagingHosts"
88 print_usage() {
89 echo "Usage: $0 [-r|-u]" >&2
90 echo " -r Register Release build instead of Debug" >&2
91 echo " -u Unregister" >&2
94 build_dir="Debug"
96 if [[ $# -gt 1 ]]; then
97 print_usage
98 elif [[ $# -eq 1 ]]; then
99 case "$1" in
100 "-r")
101 build_dir="Release"
103 "-u")
104 unregister_hosts_for_all_channels
105 exit 0
108 print_usage
109 exit 1
111 esac
114 register_hosts_for_all_channels "${SRC_DIR}/out/${build_dir}"