| Index: chrome/browser/resources/local_omnibox_popup/local_omnibox_popup.js
|
| diff --git a/chrome/browser/resources/local_omnibox_popup/local_omnibox_popup.js b/chrome/browser/resources/local_omnibox_popup/local_omnibox_popup.js
|
| index c80c0aa1e75e1be1e8177fa8b30a67d080b7dff4..2a0c81a096f55489f3de00a6c1d3785b14d6e337 100644
|
| --- a/chrome/browser/resources/local_omnibox_popup/local_omnibox_popup.js
|
| +++ b/chrome/browser/resources/local_omnibox_popup/local_omnibox_popup.js
|
| @@ -2,6 +2,31 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +/**
|
| + * @fileoverview Support for omnibox behavior in offline mode or when API
|
| + * features are not supported on the server.
|
| + */
|
| +
|
| +// ==========================================================
|
| +// Enums.
|
| +// ==========================================================
|
| +
|
| +/**
|
| + * Possible behaviors for navigateContentWindow.
|
| + * @enum {number}
|
| + */
|
| +var WindowOpenDisposition = {
|
| + CURRENT_TAB: 1,
|
| + NEW_BACKGROUND_TAB: 2
|
| +};
|
| +
|
| +/**
|
| + * The JavaScript button event value for a middle click.
|
| + * @type {number}
|
| + * @const
|
| + */
|
| +var MIDDLE_MOUSE_BUTTON = 1;
|
| +
|
| // =============================================================================
|
| // Util functions
|
| // =============================================================================
|
| @@ -53,8 +78,8 @@ function addSuggestionToBox(suggestion, box, select) {
|
| contentsContainer.appendChild(contents);
|
| suggestionDiv.appendChild(contentsContainer);
|
| var restrictedId = suggestion.rid;
|
| - suggestionDiv.onclick = function() {
|
| - handleSuggestionClick(restrictedId);
|
| + suggestionDiv.onclick = function(event) {
|
| + handleSuggestionClick(restrictedId, event);
|
| };
|
|
|
| restrictedIds.push(restrictedId);
|
| @@ -193,13 +218,27 @@ function appendSuggestionStyles() {
|
| }
|
|
|
| /**
|
| + * Extract the desired navigation behavior from a click event.
|
| + * @param {Event} event The click event.
|
| + * @return {WindowOpenDisposition} The desired behavior for
|
| + * navigateContentWindow.
|
| + */
|
| +function getDispositionFromClick(event) {
|
| + if (event.button == MIDDLE_MOUSE_BUTTON)
|
| + return WindowOpenDisposition.NEW_BACKGROUND_TAB;
|
| + return WindowOpenDisposition.CURRENT_TAB;
|
| +}
|
| +
|
| +/**
|
| * Handles suggestion clicks.
|
| * @param {integer} restrictedId The restricted id of the suggestion being
|
| * clicked.
|
| + * @param {Event} event The click event.
|
| */
|
| -function handleSuggestionClick(restrictedId) {
|
| +function handleSuggestionClick(restrictedId, event) {
|
| clearSuggestions();
|
| - getApiObjectHandle().navigateContentWindow(restrictedId);
|
| + getApiObjectHandle().navigateContentWindow(restrictedId,
|
| + getDispositionFromClick(event));
|
| }
|
|
|
| /**
|
|
|