summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/examples
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common/extensions/docs/examples')
-rw-r--r--chrome/common/extensions/docs/examples/api/tabs/pin.zipbin0 -> 2153 bytes
-rw-r--r--chrome/common/extensions/docs/examples/api/tabs/pin/README2
-rw-r--r--chrome/common/extensions/docs/examples/api/tabs/pin/background.html22
-rw-r--r--chrome/common/extensions/docs/examples/api/tabs/pin/inject.js13
-rw-r--r--chrome/common/extensions/docs/examples/api/tabs/pin/manifest.json15
5 files changed, 52 insertions, 0 deletions
diff --git a/chrome/common/extensions/docs/examples/api/tabs/pin.zip b/chrome/common/extensions/docs/examples/api/tabs/pin.zip
new file mode 100644
index 0000000..63f48d23
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/tabs/pin.zip
Binary files differ
diff --git a/chrome/common/extensions/docs/examples/api/tabs/pin/README b/chrome/common/extensions/docs/examples/api/tabs/pin/README
new file mode 100644
index 0000000..d9d5c65
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/tabs/pin/README
@@ -0,0 +1,2 @@
+Demo Chrome Extension that uses the Tab Pinning API. Enables a new keyboard
+shortcut (Ctrl + Shift + P) to toggle pinning and unpinning of the current tab.
diff --git a/chrome/common/extensions/docs/examples/api/tabs/pin/background.html b/chrome/common/extensions/docs/examples/api/tabs/pin/background.html
new file mode 100644
index 0000000..47aa9fa
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/tabs/pin/background.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<!--
+ * Copyright (c) 2011 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.
+-->
+<head>
+<title>Keyboard Pin</title>
+<script>
+chrome.extension.onRequest.addListener(
+ function(request, sender, sendResponse) {
+ if (request.toggle_pin) {
+ // Get the currently selected tab
+ chrome.tabs.getSelected(null, function(tab) {
+ // Toggle the pinned status
+ chrome.tabs.update(tab.id, {'pinned': !tab.pinned});
+ });
+ }
+ }
+);
+</script>
+</head>
diff --git a/chrome/common/extensions/docs/examples/api/tabs/pin/inject.js b/chrome/common/extensions/docs/examples/api/tabs/pin/inject.js
new file mode 100644
index 0000000..3117e40
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/tabs/pin/inject.js
@@ -0,0 +1,13 @@
+// Copyright (c) 2011 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.
+window.addEventListener("keydown", function(event) {
+ // Bind to both command (for Mac) and control (for Win/Linux)
+ var modifier = event.ctrlKey || event.metaKey;
+ if (modifier && event.shiftKey && event.keyCode == 80) {
+ // Send message to background page to toggle tab
+ chrome.extension.sendRequest({toggle_pin: true}, function(response) {
+ // Do stuff on successful response
+ });
+ }
+}, false);
diff --git a/chrome/common/extensions/docs/examples/api/tabs/pin/manifest.json b/chrome/common/extensions/docs/examples/api/tabs/pin/manifest.json
new file mode 100644
index 0000000..e7969cd
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/api/tabs/pin/manifest.json
@@ -0,0 +1,15 @@
+{
+ "name": "Keyboard Pin",
+ "version": "0.1",
+ "description": "Creates a keyboard shortcut (C + Shift + P) to toggle the pinned state of the currently selected tab",
+ "permissions": [
+ "tabs"
+ ],
+ "background_page": "background.html",
+ "content_scripts": [
+ {
+ "matches": ["<all_urls>"],
+ "js": ["inject.js"]
+ }
+ ]
+}