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

Unified Diff: chrome/browser/resources/settings/search_settings.js

Issue 2153013003: MD Settings: Show/hide spinner when searching starts/ends. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/settings/settings_main/settings_main.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/settings/search_settings.js
diff --git a/chrome/browser/resources/settings/search_settings.js b/chrome/browser/resources/settings/search_settings.js
index 1b95ac9b25189d4548692ad0d896d7bc7551b1d6..c328fe89c081a90e986389b256e2bc03e3260196 100644
--- a/chrome/browser/resources/settings/search_settings.js
+++ b/chrome/browser/resources/settings/search_settings.js
@@ -127,7 +127,7 @@ cr.define('settings', function() {
function findAndHighlightMatches_(context, root) {
function doSearch(node) {
if (forceRenderNeeded_(context, node)) {
- SearchManager.getInstance().queue_.addRenderTask(
+ getSearchManager().queue_.addRenderTask(
new RenderTask(context, node));
return;
}
@@ -231,7 +231,7 @@ cr.define('settings', function() {
var renderedNode = parent.querySelector('#' + subpageTemplate.id);
// Register a SearchAndHighlightTask for the part of the DOM that was
// just rendered.
- SearchManager.getInstance().queue_.addSearchAndHighlightTask(
+ getSearchManager().queue_.addSearchAndHighlightTask(
new SearchAndHighlightTask(this.context, assert(renderedNode)));
resolve();
}.bind(this));
@@ -358,16 +358,18 @@ cr.define('settings', function() {
var task = this.popNextTask_();
if (!task) {
this.running_ = false;
+ getSearchManager().notifyCallback(false);
return;
}
+ this.running_ = true;
window.requestIdleCallback(function() {
function startNextTask() {
this.running_ = false;
this.consumePending_();
}
if (task.context.id ==
- SearchManager.getInstance().activeContext_.id) {
+ getSearchManager().activeContext_.id) {
task.exec().then(startNextTask.bind(this));
} else {
// Dropping this task without ever executing it, since a new search
@@ -389,6 +391,9 @@ cr.define('settings', function() {
/** @private {!SearchContext} */
this.activeContext_ = {id: 0, rawQuery: null, regExp: null};
+
+ /** @private {?function(boolean):void} */
+ this.callbackFn_ = null;
};
cr.addSingletonGetter(SearchManager);
@@ -397,6 +402,21 @@ cr.define('settings', function() {
SearchManager.prototype = {
/**
+ * Registers a callback function that will be called every time search
+ * starts/finishes.
+ * @param {?function(boolean):void} callbackFn
+ */
+ setCallback: function(callbackFn) {
+ this.callbackFn_ = callbackFn;
+ },
+
+ /** @param {boolean} isRunning */
+ notifyCallback: function(isRunning) {
+ if (this.callbackFn_)
+ this.callbackFn_(isRunning);
+ },
+
+ /**
* @param {string} text The text to search for.
* @param {!Node} page
*/
@@ -417,6 +437,7 @@ cr.define('settings', function() {
// Drop all previously scheduled tasks, since a new search was just
// issued.
this.queue_.reset();
+ this.notifyCallback(true);
}
this.queue_.addTopLevelSearchTask(
@@ -424,15 +445,12 @@ cr.define('settings', function() {
},
};
- /**
- * @param {string} text
- * @param {!Node} page
- */
- function search(text, page) {
- SearchManager.getInstance().search(text, page);
+ /** @return {!SearchManager} */
+ function getSearchManager() {
+ return SearchManager.getInstance();
}
return {
- search: search,
+ getSearchManager: getSearchManager,
};
});
« no previous file with comments | « no previous file | chrome/browser/resources/settings/settings_main/settings_main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698