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

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: Moved build dependencies to OS!=iOS 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 /**
651 * Shows a notification explaining that there are other forms of browsing
652 * history present on the server.
653 * @param {boolean} hasSyncedResults Whether there are synced results.
654 * @param {boolean} includeOtherFormsOfBrowsingHistory Whether to include
655 * a sentence about the existence of other forms of browsing history.
656 */
657 HistoryModel.prototype.showNotification = function(
Dan Beam 2016/03/31 01:05:43 this belongs on the view instead
msramek 2016/03/31 19:20:01 Done. I originally put it here, since I extracted
658 hasSyncedResults, includeOtherFormsOfBrowsingHistory) {
659 var message = '';
660
661 if (loadTimeData.getBoolean('isUserSignedIn')) {
662 message = '<div>' + loadTimeData.getString(
663 hasSyncedResults ? 'hasSyncedResults' : 'noSyncedResults') + '</div>';
664 }
665
666 if (includeOtherFormsOfBrowsingHistory) {
667 message += '<div>' + loadTimeData.getString('otherFormsOfBrowsingHistory') +
668 '</div>';
669 }
670
671 if (message != '')
Dan Beam 2016/03/31 01:05:43 if (message)
msramek 2016/03/31 19:20:01 Done.
672 this.view_.showNotification(message);
673 };
674
675 /**
657 * @return {number} The number of visits in the model. 676 * @return {number} The number of visits in the model.
658 */ 677 */
659 HistoryModel.prototype.getSize = function() { 678 HistoryModel.prototype.getSize = function() {
660 return this.visits_.length; 679 return this.visits_.length;
661 }; 680 };
662 681
663 /** 682 /**
664 * Get a list of visits between specified index positions. 683 * Get a list of visits between specified index positions.
665 * @param {number} start The start index. 684 * @param {number} start The start index.
666 * @param {number} end The end index. 685 * @param {number} end The end index.
(...skipping 600 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 if ((bar.getBoundingClientRect().top >=
1281 $('editing-controls').getBoundingClientRect().bottom) { 1301 $('editing-controls').getBoundingClientRect().bottom) ||
1282 bar.classList.add('alone'); 1302 bar.childElementCount > 1) {
1303 container.classList.add('overflow');
1283 } else { 1304 } else {
1284 bar.classList.remove('alone'); 1305 container.classList.remove('overflow');
Dan Beam 2016/03/31 01:05:43 var shouldOverflow = ...; $('container').classList
msramek 2016/03/31 19:20:01 Done.
1285 } 1306 }
1286 }; 1307 };
1287 1308
1288 /** 1309 /**
1289 * @param {!Element} el An element to look for. 1310 * @param {!Element} el An element to look for.
1290 * @return {boolean} Whether |el| is in |this.focusGrid_|. 1311 * @return {boolean} Whether |el| is in |this.focusGrid_|.
1291 */ 1312 */
1292 HistoryView.prototype.isInFocusGrid = function(el) { 1313 HistoryView.prototype.isInFocusGrid = function(el) {
1293 return this.focusGrid_.getRowIndexForTarget(el) != -1; 1314 return this.focusGrid_.getRowIndexForTarget(el) != -1;
1294 }; 1315 };
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
2339 /** 2360 /**
2340 * Our history system calls this function with results from searches. 2361 * Our history system calls this function with results from searches.
2341 * @param {HistoryQuery} info An object containing information about the query. 2362 * @param {HistoryQuery} info An object containing information about the query.
2342 * @param {Array<HistoryEntry>} results A list of results. 2363 * @param {Array<HistoryEntry>} results A list of results.
2343 */ 2364 */
2344 function historyResult(info, results) { 2365 function historyResult(info, results) {
2345 historyModel.addResults(info, results); 2366 historyModel.addResults(info, results);
2346 } 2367 }
2347 2368
2348 /** 2369 /**
2370 * Called by the history backend after receiving results and after discovering
2371 * the existence of other forms of browsing history.
2372 * @param {boolean} hasSyncedResults Whether there are synced results.
2373 * @param {boolean} includeOtherFormsOfBrowsingHistory Whether to include
2374 * a sentence about the existence of other forms of browsing history.
2375 */
2376 function showNotification(
2377 hasSyncedResults, includeOtherFormsOfBrowsingHistory) {
2378 historyModel.showNotification(
Dan Beam 2016/03/31 01:05:43 historyView.showNotification
msramek 2016/03/31 19:20:01 Done. As mentioned above, let's rename it to showW
2379 hasSyncedResults, includeOtherFormsOfBrowsingHistory);
2380 }
2381
2382 /**
2349 * Called by the history backend when history removal is successful. 2383 * Called by the history backend when history removal is successful.
2350 */ 2384 */
2351 function deleteComplete() { 2385 function deleteComplete() {
2352 historyModel.deleteComplete(); 2386 historyModel.deleteComplete();
2353 } 2387 }
2354 2388
2355 /** 2389 /**
2356 * Called by the history backend when history removal is unsuccessful. 2390 * Called by the history backend when history removal is unsuccessful.
2357 */ 2391 */
2358 function deleteFailed() { 2392 function deleteFailed() {
(...skipping 11 matching lines...) Expand all
2370 historyView.reload(); 2404 historyView.reload();
2371 } 2405 }
2372 2406
2373 // Add handlers to HTML elements. 2407 // Add handlers to HTML elements.
2374 document.addEventListener('DOMContentLoaded', load); 2408 document.addEventListener('DOMContentLoaded', load);
2375 2409
2376 // This event lets us enable and disable menu items before the menu is shown. 2410 // This event lets us enable and disable menu items before the menu is shown.
2377 document.addEventListener('canExecute', function(e) { 2411 document.addEventListener('canExecute', function(e) {
2378 e.canExecute = true; 2412 e.canExecute = true;
2379 }); 2413 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698