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

Side by Side Diff: chrome/browser/resources/shared/js/cr/link_controller.js

Issue 6332020: BMM: Handle middle click correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview This file provides a class that can be used to open URLs based 6 * @fileoverview This file provides a class that can be used to open URLs based
7 * on user interactions. It ensures a consistent behavior when it comes to 7 * on user interactions. It ensures a consistent behavior when it comes to
8 * holding down Ctrl and Shift while clicking or activating the a link. 8 * holding down Ctrl and Shift while clicking or activating the a link.
9 * 9 *
10 * This depends on the {@code chrome.windows} and {@code chrome.tabs} 10 * This depends on the {@code chrome.windows} and {@code chrome.tabs}
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return this.localStrings_.getStringF('should_open_all', count); 75 return this.localStrings_.getStringF('should_open_all', count);
76 }, 76 },
77 77
78 /** 78 /**
79 * Open an URL from a mouse or keyboard event. 79 * Open an URL from a mouse or keyboard event.
80 * @param {string} url The URL to open. 80 * @param {string} url The URL to open.
81 * @param {!Event} e The event triggering the opening of the URL. 81 * @param {!Event} e The event triggering the opening of the URL.
82 */ 82 */
83 openUrlFromEvent: function(url, e) { 83 openUrlFromEvent: function(url, e) {
84 // We only support keydown Enter and non right click events. 84 // We only support keydown Enter and non right click events.
85 if (e.type == 'keydown') { 85 if (e.type == 'keydown' && e.keyIdentifier == 'Enter' ||
86 if(e.keyIdentifier != 'Enter') 86 e.button != 2) {
87 return; 87 var kind;
88 } else if (e.type != 'click' || e.button == 2) { 88 var ctrl = cr.isMac && e.metaKey || !cr.isMac && e.ctrlKey;
89 return; 89
90 if (e.button == 1 || ctrl) // middle, ctrl or keyboard
91 kind = e.shiftKey ? LinkKind.FOREGROUND_TAB : LinkKind.BACKGROUND_TAB;
92 else // left or keyboard
93 kind = e.shiftKey ? LinkKind.WINDOW : LinkKind.SELF;
94
95 this.openUrls([url], kind);
90 } 96 }
91
92 var kind;
93 var ctrl = cr.isMac && e.metaKey || !cr.isMac && e.ctrlKey;
94
95 if (e.button == 1 || ctrl) // middle, ctrl or keyboard
96 kind = e.shiftKey ? LinkKind.FOREGROUND_TAB : LinkKind.BACKGROUND_TAB;
97 else // left or keyboard
98 kind = e.shiftKey ? LinkKind.WINDOW : LinkKind.SELF;
99
100 this.openUrls([url], kind);
101 }, 97 },
102 98
103 99
104 /** 100 /**
105 * Opens a URL in a new tab, window or incognito window. 101 * Opens a URL in a new tab, window or incognito window.
106 * @param {string} url The URL to open. 102 * @param {string} url The URL to open.
107 * @param {LinkKind} kind The kind of open we want to do. 103 * @param {LinkKind} kind The kind of open we want to do.
108 */ 104 */
109 openUrl: function (url, kind) { 105 openUrl: function (url, kind) {
110 this.openUrls([url], kind); 106 this.openUrls([url], kind);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 146 }
151 } 147 }
152 }; 148 };
153 149
154 // Export 150 // Export
155 return { 151 return {
156 LinkController: LinkController, 152 LinkController: LinkController,
157 LinkKind: LinkKind 153 LinkKind: LinkKind
158 }; 154 };
159 }); 155 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698