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

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

Issue 1838333004: Add a notice about other forms of browsing history to the History WebUI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@desktop-ui-after-rebase
Patch Set: Rebase. Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <include src="../uber/uber_utils.js"> 5 <include src="../uber/uber_utils.js">
6 <include src="history_focus_manager.js"> 6 <include src="history_focus_manager.js">
7 7
8 /////////////////////////////////////////////////////////////////////////////// 8 ///////////////////////////////////////////////////////////////////////////////
9 // Globals: 9 // Globals:
10 /** @const */ var RESULTS_PER_PAGE = 150; 10 /** @const */ var RESULTS_PER_PAGE = 150;
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 var lastVisit = this.visits_.slice(-1)[0]; 637 var lastVisit = this.visits_.slice(-1)[0];
638 var lastDay = lastVisit ? lastVisit.dateRelativeDay : null; 638 var lastDay = lastVisit ? lastVisit.dateRelativeDay : null;
639 639
640 for (var i = 0, result; result = results[i]; i++) { 640 for (var i = 0, result; result = results[i]; i++) {
641 var thisDay = result.dateRelativeDay; 641 var thisDay = result.dateRelativeDay;
642 var isSameDay = lastDay == thisDay; 642 var isSameDay = lastDay == thisDay;
643 this.visits_.push(new Visit(result, isSameDay, this)); 643 this.visits_.push(new Visit(result, isSameDay, this));
644 lastDay = thisDay; 644 lastDay = thisDay;
645 } 645 }
646 646
647 if (loadTimeData.getBoolean('isUserSignedIn')) {
648 var message = loadTimeData.getString(
649 info.hasSyncedResults ? 'hasSyncedResults' : 'noSyncedResults');
650 this.view_.showNotification(message);
651 }
652
653 this.updateSearch_(); 647 this.updateSearch_();
654 }; 648 };
655 649
656 /** 650 /**
657 * @return {number} The number of visits in the model. 651 * @return {number} The number of visits in the model.
658 */ 652 */
659 HistoryModel.prototype.getSize = function() { 653 HistoryModel.prototype.getSize = function() {
660 return this.visits_.length; 654 return this.visits_.length;
661 }; 655 };
662 656
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 1154
1161 // Make sure that any links in the HTML are targeting the top level. 1155 // Make sure that any links in the HTML are targeting the top level.
1162 var links = bar.querySelectorAll('a'); 1156 var links = bar.querySelectorAll('a');
1163 for (var i = 0; i < links.length; i++) 1157 for (var i = 0; i < links.length; i++)
1164 links[i].target = '_top'; 1158 links[i].target = '_top';
1165 1159
1166 this.positionNotificationBar(); 1160 this.positionNotificationBar();
1167 }; 1161 };
1168 1162
1169 /** 1163 /**
1164 * Shows a notification about whether there are any synced results, and whether
1165 * there are other forms of browsing history on the server.
1166 * @param {boolean} hasSyncedResults Whether there are synced results.
1167 * @param {boolean} includeOtherFormsOfBrowsingHistory Whether to include
1168 * a sentence about the existence of other forms of browsing history.
1169 */
1170 HistoryView.prototype.showWebHistoryNotification = function(
1171 hasSyncedResults, includeOtherFormsOfBrowsingHistory) {
1172 var message = '';
1173
1174 if (loadTimeData.getBoolean('isUserSignedIn')) {
1175 message += '<span>' + loadTimeData.getString(
1176 hasSyncedResults ? 'hasSyncedResults' : 'noSyncedResults') + '</span>';
1177 }
1178
1179 if (includeOtherFormsOfBrowsingHistory) {
1180 message += ' ' /* A whitespace to separate <span>s. */ + '<span>' +
1181 loadTimeData.getString('otherFormsOfBrowsingHistory') + '</span>';
1182 }
1183
1184 if (message)
1185 this.showNotification(message);
1186 };
1187
1188 /**
1170 * @param {Visit} visit The visit about to be removed from this view. 1189 * @param {Visit} visit The visit about to be removed from this view.
1171 */ 1190 */
1172 HistoryView.prototype.onBeforeRemove = function(visit) { 1191 HistoryView.prototype.onBeforeRemove = function(visit) {
1173 assert(this.currentVisits_.indexOf(visit) >= 0); 1192 assert(this.currentVisits_.indexOf(visit) >= 0);
1174 1193
1175 var rowIndex = this.focusGrid_.getRowIndexForTarget(document.activeElement); 1194 var rowIndex = this.focusGrid_.getRowIndexForTarget(document.activeElement);
1176 if (rowIndex == -1) 1195 if (rowIndex == -1)
1177 return; 1196 return;
1178 1197
1179 var rowToFocus = this.focusGrid_.rows[rowIndex + 1] || 1198 var rowToFocus = this.focusGrid_.rows[rowIndex + 1] ||
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 this.clear_(); 1286 this.clear_();
1268 this.onModelReady(true); // Shows "No entries" message. 1287 this.onModelReady(true); // Shows "No entries" message.
1269 } 1288 }
1270 }; 1289 };
1271 1290
1272 /** 1291 /**
1273 * Adjusts the position of the notification bar based on the size of the page. 1292 * Adjusts the position of the notification bar based on the size of the page.
1274 */ 1293 */
1275 HistoryView.prototype.positionNotificationBar = function() { 1294 HistoryView.prototype.positionNotificationBar = function() {
1276 var bar = $('notification-bar'); 1295 var bar = $('notification-bar');
1296 var container = $('top-container');
1277 1297
1278 // If the bar does not fit beside the editing controls, put it into the 1298 // If the bar does not fit beside the editing controls, or if it contains
1279 // overflow state. 1299 // more than one message, put it into the overflow state.
1280 if (bar.getBoundingClientRect().top >= 1300 var shouldOverflow =
1281 $('editing-controls').getBoundingClientRect().bottom) { 1301 (bar.getBoundingClientRect().top >=
1282 bar.classList.add('alone'); 1302 $('editing-controls').getBoundingClientRect().bottom) ||
1283 } else { 1303 bar.childElementCount > 1;
1284 bar.classList.remove('alone'); 1304 container.classList.toggle('overflow', shouldOverflow);
1285 }
1286 }; 1305 };
1287 1306
1288 /** 1307 /**
1289 * @param {!Element} el An element to look for. 1308 * @param {!Element} el An element to look for.
1290 * @return {boolean} Whether |el| is in |this.focusGrid_|. 1309 * @return {boolean} Whether |el| is in |this.focusGrid_|.
1291 */ 1310 */
1292 HistoryView.prototype.isInFocusGrid = function(el) { 1311 HistoryView.prototype.isInFocusGrid = function(el) {
1293 return this.focusGrid_.getRowIndexForTarget(el) != -1; 1312 return this.focusGrid_.getRowIndexForTarget(el) != -1;
1294 }; 1313 };
1295 1314
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
2339 /** 2358 /**
2340 * Our history system calls this function with results from searches. 2359 * Our history system calls this function with results from searches.
2341 * @param {HistoryQuery} info An object containing information about the query. 2360 * @param {HistoryQuery} info An object containing information about the query.
2342 * @param {Array<HistoryEntry>} results A list of results. 2361 * @param {Array<HistoryEntry>} results A list of results.
2343 */ 2362 */
2344 function historyResult(info, results) { 2363 function historyResult(info, results) {
2345 historyModel.addResults(info, results); 2364 historyModel.addResults(info, results);
2346 } 2365 }
2347 2366
2348 /** 2367 /**
2368 * Called by the history backend after receiving results and after discovering
2369 * the existence of other forms of browsing history.
2370 * @param {boolean} hasSyncedResults Whether there are synced results.
2371 * @param {boolean} includeOtherFormsOfBrowsingHistory Whether to include
2372 * a sentence about the existence of other forms of browsing history.
2373 */
2374 function showNotification(
2375 hasSyncedResults, includeOtherFormsOfBrowsingHistory) {
2376 historyView.showWebHistoryNotification(
2377 hasSyncedResults, includeOtherFormsOfBrowsingHistory);
2378 }
2379
2380 /**
2349 * Called by the history backend when history removal is successful. 2381 * Called by the history backend when history removal is successful.
2350 */ 2382 */
2351 function deleteComplete() { 2383 function deleteComplete() {
2352 historyModel.deleteComplete(); 2384 historyModel.deleteComplete();
2353 } 2385 }
2354 2386
2355 /** 2387 /**
2356 * Called by the history backend when history removal is unsuccessful. 2388 * Called by the history backend when history removal is unsuccessful.
2357 */ 2389 */
2358 function deleteFailed() { 2390 function deleteFailed() {
(...skipping 11 matching lines...) Expand all
2370 historyView.reload(); 2402 historyView.reload();
2371 } 2403 }
2372 2404
2373 // Add handlers to HTML elements. 2405 // Add handlers to HTML elements.
2374 document.addEventListener('DOMContentLoaded', load); 2406 document.addEventListener('DOMContentLoaded', load);
2375 2407
2376 // This event lets us enable and disable menu items before the menu is shown. 2408 // This event lets us enable and disable menu items before the menu is shown.
2377 document.addEventListener('canExecute', function(e) { 2409 document.addEventListener('canExecute', function(e) {
2378 e.canExecute = true; 2410 e.canExecute = true;
2379 }); 2411 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/history/history.css ('k') | chrome/browser/resources/history/history_mobile.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698