| 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..dcf70ff0f297094626066ba7e9f9bd2c8789cd5e 100644
|
| --- a/chrome/browser/resources/settings/search_settings.js
|
| +++ b/chrome/browser/resources/settings/search_settings.js
|
| @@ -358,9 +358,11 @@ 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;
|
| @@ -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,
|
| };
|
| });
|
|
|