summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/local_ntp/window_disposition_util.js
blob: 9282759560ec7501be5ad322bd27af1bc28940ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);
}