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

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

Issue 2171693002: [MD History] Force history results to be processed in order. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_menu_up
Patch Set: missed one Created 4 years, 4 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 | chrome/test/data/webui/md_history/md_history_browsertest.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // Send the history query immediately. This allows the query to process during 5 // Send the history query immediately. This allows the query to process during
6 // the initial page startup. 6 // the initial page startup.
7 chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]); 7 chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]);
8 chrome.send('getForeignSessions'); 8 chrome.send('getForeignSessions');
9 9
10 /** @type {Promise} */
11 var upgradePromise = null;
12
10 /** 13 /**
11 * @param {HTMLElement} element 14 * @return {!Promise} Resolves once the history-app has been fully upgraded.
12 * @return {!Promise} Resolves once a Polymer element has been fully upgraded.
13 */ 15 */
14 function waitForUpgrade(element) { 16 function waitForAppUpgrade() {
15 return new Promise(function(resolve, reject) { 17 if (!upgradePromise) {
16 if (window.Polymer && Polymer.isInstance && Polymer.isInstance(element)) 18 upgradePromise = new Promise(function(resolve, reject) {
17 resolve(); 19 if (window.Polymer && Polymer.isInstance &&
18 else 20 Polymer.isInstance($('history-app'))) {
19 $('bundle').addEventListener('load', resolve); 21 resolve();
20 }); 22 } else {
23 $('bundle').addEventListener('load', resolve);
24 }
25 });
26 }
27 return upgradePromise;
21 } 28 }
22 29
23 // Chrome Callbacks------------------------------------------------------------- 30 // Chrome Callbacks-------------------------------------------------------------
24 31
25 /** 32 /**
26 * Our history system calls this function with results from searches. 33 * Our history system calls this function with results from searches.
27 * @param {HistoryQuery} info An object containing information about the query. 34 * @param {HistoryQuery} info An object containing information about the query.
28 * @param {!Array<HistoryEntry>} results A list of results. 35 * @param {!Array<HistoryEntry>} results A list of results.
29 */ 36 */
30 function historyResult(info, results) { 37 function historyResult(info, results) {
31 var appElem = $('history-app'); 38 waitForAppUpgrade().then(function() {
32 waitForUpgrade(appElem).then(function() { 39 /** @type {HistoryAppElement} */($('history-app'))
33 /** @type {HistoryAppElement} */(appElem).historyResult(info, results); 40 .historyResult(info, results);
34 // TODO(tsergeant): Showing everything as soon as the list is ready is not 41 // TODO(tsergeant): Showing everything as soon as the list is ready is not
35 // ideal, as the sidebar can still pop in after. Fix this to show everything 42 // ideal, as the sidebar can still pop in after. Fix this to show everything
36 // at once. 43 // at once.
37 document.body.classList.remove('loading'); 44 document.body.classList.remove('loading');
38 }); 45 });
39 } 46 }
40 47
41 /** 48 /**
42 * Called by the history backend after receiving results and after discovering 49 * Called by the history backend after receiving results and after discovering
43 * the existence of other forms of browsing history. 50 * the existence of other forms of browsing history.
44 * @param {boolean} hasSyncedResults Whether there are synced results. 51 * @param {boolean} hasSyncedResults Whether there are synced results.
45 * @param {boolean} includeOtherFormsOfBrowsingHistory Whether to include 52 * @param {boolean} includeOtherFormsOfBrowsingHistory Whether to include
46 * a sentence about the existence of other forms of browsing history. 53 * a sentence about the existence of other forms of browsing history.
47 */ 54 */
48 function showNotification( 55 function showNotification(
49 hasSyncedResults, includeOtherFormsOfBrowsingHistory) { 56 hasSyncedResults, includeOtherFormsOfBrowsingHistory) {
50 // TODO(msramek): |hasSyncedResults| was used in the old WebUI to show 57 // TODO(msramek): |hasSyncedResults| was used in the old WebUI to show
51 // the message about other signed-in devices. This message does not exist 58 // the message about other signed-in devices. This message does not exist
52 // in the MD history anymore, so the parameter is not needed. Remove it 59 // in the MD history anymore, so the parameter is not needed. Remove it
53 // when WebUI is removed and this becomes the only client of 60 // when WebUI is removed and this becomes the only client of
54 // BrowsingHistoryHandler. 61 // BrowsingHistoryHandler.
55 var appElem = $('history-app'); 62 waitForAppUpgrade().then(function() {
56 waitForUpgrade(appElem).then(function() { 63 /** @type {HistoryAppElement} */($('history-app'))
57 /** @type {HistoryAppElement} */(appElem)
58 .getSideBar().showFooter = includeOtherFormsOfBrowsingHistory; 64 .getSideBar().showFooter = includeOtherFormsOfBrowsingHistory;
59 }); 65 });
60 } 66 }
61 67
62 /** 68 /**
63 * Receives the synced history data. An empty list means that either there are 69 * Receives the synced history data. An empty list means that either there are
64 * no foreign sessions, or tab sync is disabled for this profile. 70 * no foreign sessions, or tab sync is disabled for this profile.
65 * |isTabSyncEnabled| makes it possible to distinguish between the cases. 71 * |isTabSyncEnabled| makes it possible to distinguish between the cases.
66 * 72 *
67 * @param {!Array<!ForeignSession>} sessionList Array of objects describing the 73 * @param {!Array<!ForeignSession>} sessionList Array of objects describing the
68 * sessions from other devices. 74 * sessions from other devices.
69 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? 75 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile?
70 */ 76 */
71 function setForeignSessions(sessionList, isTabSyncEnabled) { 77 function setForeignSessions(sessionList, isTabSyncEnabled) {
72 var appElem = $('history-app'); 78 waitForAppUpgrade().then(function() {
73 waitForUpgrade(appElem).then(function() { 79 /** @type {HistoryAppElement} */($('history-app'))
74 /** @type {HistoryAppElement} */(appElem)
75 .setForeignSessions(sessionList, isTabSyncEnabled); 80 .setForeignSessions(sessionList, isTabSyncEnabled);
76 }); 81 });
77 } 82 }
78 83
79 /** 84 /**
80 * Called when the history is deleted by someone else. 85 * Called when the history is deleted by someone else.
81 */ 86 */
82 function historyDeleted() { 87 function historyDeleted() {
83 } 88 }
84 89
85 /** 90 /**
86 * Called by the history backend after user's sign in state changes. 91 * Called by the history backend after user's sign in state changes.
87 * @param {boolean} isUserSignedIn Whether user is signed in or not now. 92 * @param {boolean} isUserSignedIn Whether user is signed in or not now.
88 */ 93 */
89 function updateSignInState(isUserSignedIn) { 94 function updateSignInState(isUserSignedIn) {
90 var appElem = $('history-app'); 95 waitForAppUpgrade().then(function() {
91 waitForUpgrade(appElem).then(function() { 96 /** @type {HistoryAppElement} */($('history-app'))
92 /** @type {HistoryAppElement} */(appElem)
93 .updateSignInState(isUserSignedIn); 97 .updateSignInState(isUserSignedIn);
94 }); 98 });
95 } 99 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/md_history/md_history_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698