Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1096)

Unified Diff: chrome/common/extensions/docs/examples/howto/tab_shortcuts/tab_shortcuts.js

Issue 12481004: Created a sample extension that shows off event pages, new tab apis, and keyboard shortcuts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nit Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/docs/examples/howto/tab_shortcuts/manifest.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ });
+});
« no previous file with comments | « chrome/common/extensions/docs/examples/howto/tab_shortcuts/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698