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..5bdd63dbf1f17819091e014bf46fd66c9b35f459 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,27 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+// ========================================================== |
+// Enums. |
+// ========================================================== |
+/** |
+ * Possible behaviors for navigateContentWindow. |
+ * @enum {number} |
+ * @private |
+ */ |
+var WindowOpenDisposition_ = { |
+ CURRENT_TAB: 1, |
+ NEW_BACKGROUND_TAB: 2 |
+}; |
+ |
+/** |
+ * The JavaScript button event value for a middle click. |
+ * @type {number} |
+ * @private |
+ * @const |
+ */ |
+var MIDDLE_MOUSE_BUTTON_ = 1; |
+ |
// ============================================================================= |
// Util functions |
// ============================================================================= |
@@ -53,8 +74,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); |
@@ -196,10 +217,15 @@ function appendSuggestionStyles() { |
* Handles suggestion clicks. |
* @param {integer} restrictedId The restricted id of the suggestion being |
* clicked. |
+ * @param {Event} event The native click event. |
*/ |
-function handleSuggestionClick(restrictedId) { |
+function handleSuggestionClick(restrictedId, event) { |
clearSuggestions(); |
- getApiObjectHandle().navigateContentWindow(restrictedId); |
+ var disposition = WindowOpenDisposition_.CURRENT_TAB; |
+ if (event.button == MIDDLE_MOUSE_BUTTON_) |
+ disposition = WindowOpenDisposition_.NEW_BACKGROUND_TAB; |
+ getApiObjectHandle().navigateContentWindow( |
samarth
2013/02/20 23:55:16
nit: fits on one line?
dougw
2013/02/21 00:49:00
Done.
|
+ restrictedId, disposition); |
} |
/** |