Index: chrome/browser/resources/local_ntp/window_disposition_util.js |
diff --git a/chrome/browser/resources/local_ntp/window_disposition_util.js b/chrome/browser/resources/local_ntp/window_disposition_util.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9282759560ec7501be5ad322bd27af1bc28940ab |
--- /dev/null |
+++ b/chrome/browser/resources/local_ntp/window_disposition_util.js |
@@ -0,0 +1,32 @@ |
+// Copyright 2014 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. |
+ |
+ |
+/** |
+ * @fileoverview Utilities for handling window disposition. |
+ */ |
+ |
+ |
+/** |
+ * The JavaScript button event value for a middle click. |
+ * @type {number} |
+ * @const |
+ */ |
+var MIDDLE_MOUSE_BUTTON = 1; |
+ |
+ |
+/** |
+ * Gets the desired navigation behavior from a event. This function works both |
+ * with mouse and keyboard events. |
+ * @param {Event} e The event object. |
+ * @return {WindowOpenDisposition} The desired navigation behavior. |
+ */ |
+function getDispositionFromEvent(e) { |
+ var middleButton = e.button == MIDDLE_MOUSE_BUTTON; |
+ return chrome.embeddedSearch.newTabPage.getDispositionFromClick(middleButton, |
+ e.altKey, |
+ e.ctrlKey, |
+ e.metaKey, |
+ e.shiftKey); |
+} |