summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/examples/api/infobars/sandwichbar
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common/extensions/docs/examples/api/infobars/sandwichbar')
-rw-r--r--chrome/common/extensions/docs/examples/api/infobars/sandwichbar/background.html34
-rw-r--r--chrome/common/extensions/docs/examples/api/infobars/sandwichbar/contentscript.js13
-rw-r--r--chrome/common/extensions/docs/examples/api/infobars/sandwichbar/infobar.html42
-rw-r--r--chrome/common/extensions/docs/examples/api/infobars/sandwichbar/manifest.json20
-rw-r--r--chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-128.pngbin0 -> 8078 bytes
-rw-r--r--chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-16.pngbin0 -> 708 bytes
-rw-r--r--chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-19.pngbin0 -> 657 bytes
-rw-r--r--chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-48.pngbin0 -> 2621 bytes
8 files changed, 109 insertions, 0 deletions
diff --git a/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/background.html b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/background.html
new file mode 100644
index 0000000..de48dde
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/background.html
@@ -0,0 +1,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>
diff --git a/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/contentscript.js b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/contentscript.js
new file mode 100644
index 0000000..6fa03ec
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/contentscript.js
@@ -0,0 +1,13 @@
+/*
+ * 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.
+ */
+var regex = /sandwich/gi;
+matches = document.body.innerText.match(regex);
+if (matches) {
+ var payload = {
+ count: matches.length // Pass the number of matches back.
+ };
+ chrome.extension.sendRequest(payload, function(response) {});
+} \ No newline at end of file
diff --git a/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/infobar.html b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/infobar.html
new file mode 100644
index 0000000..3a765a5
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/infobar.html
@@ -0,0 +1,42 @@
+<!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>
+ <style>
+ html {
+ height: 40px;
+ }
+ body {
+ background: #fffddd;
+ font: 16px Arial;
+ height: 100%;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-box-pack: center;
+ }
+ em {
+ font-weight: bold;
+ font-style: normal;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="wrap">
+ The word <em>sandwich</em> appears <em id="count">X</em> times on this
+ page.
+ </div>
+ <script>
+ // Obtain the count of sandwiches from the page URL.
+ var count = window.location.hash.substring(1);
+ if (count) {
+ // Replace the placeholder text with the actual count.
+ var domcount = document.querySelector('#count');
+ domcount.innerText = count;
+ }
+ </script>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/manifest.json b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/manifest.json
new file mode 100644
index 0000000..89bdb51
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/manifest.json
@@ -0,0 +1,20 @@
+{
+ "name" : "SandwichBar",
+ "version" : "1.0.0",
+ "description" : "Shows an infobar on pages which contain the word 'sandwich'",
+ "background_page" : "background.html",
+ "permissions" : [ "experimental" ],
+ "icons" : {
+ "16" : "sandwich-16.png",
+ "48" : "sandwich-48.png",
+ "128" : "sandwich-128.png"
+ },
+ "content_scripts" : [
+ {
+ "matches" : [ "http://*/*" ],
+ "js" : [ "contentscript.js" ],
+ "run_at" : "document_idle",
+ "all_frames" : false
+ }
+ ]
+}
diff --git a/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-128.png b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-128.png
new file mode 100644
index 0000000..a233154
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-128.png
Binary files differ
diff --git a/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-16.png b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-16.png
new file mode 100644
index 0000000..86f3b3c
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-16.png
Binary files differ
diff --git a/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-19.png b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-19.png
new file mode 100644
index 0000000..e84dc86
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-19.png
Binary files differ
diff --git a/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-48.png b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-48.png
new file mode 100644
index 0000000..d7f2324
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/infobars/sandwichbar/sandwich-48.png
Binary files differ