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

Side by Side Diff: chrome/browser/resources/local_ntp/local_ntp.js

Issue 623603002: [Local NTP] Fixing middle click paste in fakebox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 /** 6 /**
7 * @fileoverview The local InstantExtended NTP. 7 * @fileoverview The local InstantExtended NTP.
8 */ 8 */
9 9
10 10
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 attribution = $(IDS.ATTRIBUTION); 1074 attribution = $(IDS.ATTRIBUTION);
1075 ntpContents = $(IDS.NTP_CONTENTS); 1075 ntpContents = $(IDS.NTP_CONTENTS);
1076 1076
1077 if (configData.isGooglePage) { 1077 if (configData.isGooglePage) {
1078 var logo = document.createElement('div'); 1078 var logo = document.createElement('div');
1079 logo.id = IDS.LOGO; 1079 logo.id = IDS.LOGO;
1080 1080
1081 fakebox = document.createElement('div'); 1081 fakebox = document.createElement('div');
1082 fakebox.id = IDS.FAKEBOX; 1082 fakebox.id = IDS.FAKEBOX;
1083 var fakeboxHtml = []; 1083 var fakeboxHtml = [];
1084 fakeboxHtml.push('<div id="' + IDS.FAKEBOX_TEXT + '"></div>');
1084 fakeboxHtml.push('<input id="' + IDS.FAKEBOX_INPUT + 1085 fakeboxHtml.push('<input id="' + IDS.FAKEBOX_INPUT +
1085 '" autocomplete="off" tabindex="-1" type="url" aria-hidden="true">'); 1086 '" autocomplete="off" tabindex="-1" type="url" aria-hidden="true">');
1086 fakeboxHtml.push('<div id="' + IDS.FAKEBOX_TEXT + '"></div>');
1087 fakeboxHtml.push('<div id="cursor"></div>'); 1087 fakeboxHtml.push('<div id="cursor"></div>');
1088 fakebox.innerHTML = fakeboxHtml.join(''); 1088 fakebox.innerHTML = fakeboxHtml.join('');
1089 1089
1090 ntpContents.insertBefore(fakebox, ntpContents.firstChild); 1090 ntpContents.insertBefore(fakebox, ntpContents.firstChild);
1091 ntpContents.insertBefore(logo, ntpContents.firstChild); 1091 ntpContents.insertBefore(logo, ntpContents.firstChild);
1092 } else { 1092 } else {
1093 document.body.classList.add(CLASSES.NON_GOOGLE_PAGE); 1093 document.body.classList.add(CLASSES.NON_GOOGLE_PAGE);
1094 } 1094 }
1095 1095
1096 // Hide notifications after fade out, so we can't focus on links via keyboard. 1096 // Hide notifications after fade out, so we can't focus on links via keyboard.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 else if (isFakeboxFocused()) 1147 else if (isFakeboxFocused())
1148 searchboxApiHandle.stopCapturingKeyStrokes(); 1148 searchboxApiHandle.stopCapturingKeyStrokes();
1149 }; 1149 };
1150 searchboxApiHandle.onkeycapturechange = function() { 1150 searchboxApiHandle.onkeycapturechange = function() {
1151 setFakeboxFocus(searchboxApiHandle.isKeyCaptureEnabled); 1151 setFakeboxFocus(searchboxApiHandle.isKeyCaptureEnabled);
1152 }; 1152 };
1153 var inputbox = $(IDS.FAKEBOX_INPUT); 1153 var inputbox = $(IDS.FAKEBOX_INPUT);
1154 if (inputbox) { 1154 if (inputbox) {
1155 inputbox.onpaste = function(event) { 1155 inputbox.onpaste = function(event) {
1156 event.preventDefault(); 1156 event.preventDefault();
1157 searchboxApiHandle.paste(); 1157 // Send pasted text to Omnibox.
1158 var items = event.clipboardData.items;
1159 if (items.length > 0) {
huangs 2014/10/01 21:49:41 Combine with "&&".
Georges Khalil 2014/10/01 22:22:20 Done.
1160 if (items[0].type == 'text/plain') {
huangs 2014/10/01 21:49:41 We should ensure that other text would work, e.g.,
Georges Khalil 2014/10/01 22:22:20 Per discussion, no problem here.
1161 items[0].getAsString(function(text) {
1162 if (text) {
1163 searchboxApiHandle.paste(text);
1164 }
1165 });
1166 }
1167 }
1158 }; 1168 };
1159 inputbox.ondrop = function(event) { 1169 inputbox.ondrop = function(event) {
1160 event.preventDefault(); 1170 event.preventDefault();
1161 var text = event.dataTransfer.getData('text/plain'); 1171 var text = event.dataTransfer.getData('text/plain');
1162 if (text) { 1172 if (text) {
1163 searchboxApiHandle.paste(text); 1173 searchboxApiHandle.paste(text);
1164 } 1174 }
1165 }; 1175 };
1166 inputbox.ondragenter = function() { 1176 inputbox.ondragenter = function() {
1167 setFakeboxDragFocus(true); 1177 setFakeboxDragFocus(true);
(...skipping 28 matching lines...) Expand all
1196 1206
1197 return { 1207 return {
1198 init: init, 1208 init: init,
1199 listen: listen 1209 listen: listen
1200 }; 1210 };
1201 } 1211 }
1202 1212
1203 if (!window.localNTPUnitTest) { 1213 if (!window.localNTPUnitTest) {
1204 LocalNTP().listen(); 1214 LocalNTP().listen();
1205 } 1215 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698