OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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. |
Mathieu
2014/10/02 19:10:30
nit: "Get the contents of the clipboard and explic
| |
1158 var items = event.clipboardData.items; | |
1159 if (items.length > 0 && items[0].type == 'text/plain') { | |
Mathieu
2014/10/02 19:10:30
nit: if (items.length && ...
| |
1160 items[0].getAsString(function(text) { | |
1161 if (text) { | |
1162 searchboxApiHandle.paste(text); | |
1163 } | |
1164 }); | |
1165 } | |
1158 }; | 1166 }; |
1159 inputbox.ondrop = function(event) { | 1167 inputbox.ondrop = function(event) { |
1160 event.preventDefault(); | 1168 event.preventDefault(); |
1161 var text = event.dataTransfer.getData('text/plain'); | 1169 var text = event.dataTransfer.getData('text/plain'); |
1162 if (text) { | 1170 if (text) { |
1163 searchboxApiHandle.paste(text); | 1171 searchboxApiHandle.paste(text); |
1164 } | 1172 } |
1165 }; | 1173 }; |
1166 inputbox.ondragenter = function() { | 1174 inputbox.ondragenter = function() { |
1167 setFakeboxDragFocus(true); | 1175 setFakeboxDragFocus(true); |
(...skipping 28 matching lines...) Expand all Loading... | |
1196 | 1204 |
1197 return { | 1205 return { |
1198 init: init, | 1206 init: init, |
1199 listen: listen | 1207 listen: listen |
1200 }; | 1208 }; |
1201 } | 1209 } |
1202 | 1210 |
1203 if (!window.localNTPUnitTest) { | 1211 if (!window.localNTPUnitTest) { |
1204 LocalNTP().listen(); | 1212 LocalNTP().listen(); |
1205 } | 1213 } |
OLD | NEW |