Index: chrome/common/extensions/docs/examples/howto/tab_shortcuts/tab_shortcuts.js |
diff --git a/chrome/common/extensions/docs/examples/howto/tab_shortcuts/tab_shortcuts.js b/chrome/common/extensions/docs/examples/howto/tab_shortcuts/tab_shortcuts.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4ff711f9ef75be33c52219a0231260d002444516 |
--- /dev/null |
+++ b/chrome/common/extensions/docs/examples/howto/tab_shortcuts/tab_shortcuts.js |
@@ -0,0 +1,18 @@ |
+// Copyright (c) 2013 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. |
+ |
+/** |
+ * Register a callback function with the commands api, which will be called when |
+ * one of our registered commands is detected. |
+ */ |
+chrome.commands.onCommand.addListener(function(command) { |
+ // Call 'update' with an empty properties object to get access to the current |
+ // tab (given to us in the callback function). |
+ chrome.tabs.update({}, function(tab) { |
+ if (command == 'toggle-pin-tab') |
+ chrome.tabs.update({pinned: !tab.pinned}); |
+ else if (command == 'duplicate-tab') |
+ chrome.tabs.duplicate(tab.id); |
+ }); |
+}); |