summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/background.html
blob: de48dde8ec1a77ba3b74d27fa0661df16d14b7a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<!--
 * Copyright (c) 2010 The Chromium Authors. All rights reserved.  Use of this
 * source code is governed by a BSD-style license that can be found in the
 * LICENSE file.
-->
<html>
  <head>
  </head>
  <body>
    <script>
      /**
       * Handles requests sent by the content script.  Shows an infobar.
       */
      function onRequest(request, sender, sendResponse) {
        // The number of matches is sent in the request - pass it to the
        // infobar.
        var url = "infobar.html#" + request.count;

        // Show the infobar on the tab where the request was sent.
        chrome.experimental.infobars.show({
            tabId: sender.tab.id,
            path: url
        });

        // Return nothing to let the connection be cleaned up.
        sendResponse({});
      };

      // Listen for the content script to send a message to the background page.
      chrome.extension.onRequest.addListener(onRequest);
    </script>
  </body>
</html>