Commit fd9ae3c1 authored by yawano's avatar yawano Committed by Commit bot

Change queryId of launcherSearchProvider API to integer.

BUG=487505
TEST=GYP_GENERATORS=ninja tools/gyp/gyp --depth . ui/file_manager/file_manager/background/js/compiled_resources.gyp && ninja -C out/Default

Review URL: https://codereview.chromium.org/1140873002

Cr-Commit-Position: refs/heads/master@{#329806}
parent b937d6c4
......@@ -54,13 +54,12 @@ void Service::OnQueryStarted(app_list::LauncherSearchProvider* provider,
for (const ExtensionId extension_id : extension_ids) {
// Convert query_id_ to string here since queryId is defined as string in
// javascript side API while we use uint32 internally to generate it.
// TODO(yawano): Consider if we can change it to integer at javascript side.
event_router->DispatchEventToExtension(
extension_id,
make_scoped_ptr(new extensions::Event(
api_launcher_search_provider::OnQueryStarted::kEventName,
api_launcher_search_provider::OnQueryStarted::Create(
std::to_string(query_id_), query, max_result))));
query_id_, query, max_result))));
}
}
......@@ -77,8 +76,7 @@ void Service::OnQueryEnded() {
extension_id,
make_scoped_ptr(new extensions::Event(
api_launcher_search_provider::OnQueryEnded::kEventName,
api_launcher_search_provider::OnQueryEnded::Create(
std::to_string(query_id_)))));
api_launcher_search_provider::OnQueryEnded::Create(query_id_))));
}
is_query_running_ = false;
......@@ -100,12 +98,12 @@ void Service::OnOpenResult(const ExtensionId& extension_id,
void Service::SetSearchResults(
const extensions::Extension* extension,
scoped_ptr<ErrorReporter> error_reporter,
const std::string& query_id,
const int query_id,
const std::vector<linked_ptr<
extensions::api::launcher_search_provider::SearchResult>>& results) {
// If query is not running or query_id is different from current query id,
// discard the results.
if (!is_query_running_ || query_id != std::to_string(query_id_))
if (!is_query_running_ || query_id != query_id_)
return;
// If |extension| is not in the listener extensions list, ignore it.
......
......@@ -53,7 +53,7 @@ class Service : public KeyedService {
void SetSearchResults(
const extensions::Extension* extension,
scoped_ptr<ErrorReporter> error_reporter,
const std::string& query_id,
const int query_id,
const std::vector<linked_ptr<
extensions::api::launcher_search_provider::SearchResult>>& results);
......@@ -67,7 +67,7 @@ class Service : public KeyedService {
Profile* const profile_;
extensions::ExtensionRegistry* extension_registry_;
app_list::LauncherSearchProvider* provider_;
uint32 query_id_;
int query_id_;
bool is_query_running_;
DISALLOW_COPY_AND_ASSIGN(Service);
......
......@@ -24,19 +24,19 @@ namespace launcherSearchProvider {
// guranteed that all provided results are shown to a user. The search
// results will be sorted by relevance, with ties broken by the order of the
// results in this list (highest priority first).
static void setSearchResults(DOMString queryId, SearchResult[] results);
static void setSearchResults(long queryId, SearchResult[] results);
};
interface Events {
// Called when a user typed a query. maxResult is the maximum number of
// results the extension should provide.
static void onQueryStarted(DOMString queryId,
static void onQueryStarted(long queryId,
DOMString query,
long maxResult);
// Called when query of |queryId| is ended. After this call,
// setSearchResults no longer accept the results for queryId.
static void onQueryEnded(DOMString queryId);
static void onQueryEnded(long queryId);
// Called when a user clicks a search result which is provided by
// setSearchResults.
......
......@@ -10,7 +10,7 @@
chrome.launcherSearchProvider = {};
/**
* @param {string} queryId
* @param {number} queryId
* @param {Array<{itemId:string, title:string, iconUrl:?string,
* relevance:number}>} results
*/
......
......@@ -14,7 +14,7 @@ function LauncherSearch() {
/**
* Active query id. This value is set null when there is no active query.
* @private {?string}
* @private {?number}
*/
this.queryId_ = null;
......@@ -25,12 +25,12 @@ function LauncherSearch() {
this.enabled_ = false;
/**
* @private {function(string, string, number)}
* @private {function(number, string, number)}
*/
this.onQueryStartedBound_ = this.onQueryStarted_.bind(this);
/**
* @private {function(string)}
* @private {function(number)}
*/
this.onQueryEndedBound_ = this.onQueryEnded_.bind(this);
......@@ -98,7 +98,7 @@ LauncherSearch.prototype.initializeEventListeners_ = function(isDriveEnabled) {
/**
* Handles onQueryStarted event.
* @param {string} queryId
* @param {number} queryId
* @param {string} query
* @param {number} limit
*/
......@@ -141,7 +141,7 @@ LauncherSearch.prototype.onQueryStarted_ = function(queryId, query, limit) {
/**
* Handles onQueryEnded event.
* @param {string} queryId
* @param {number} queryId
*/
LauncherSearch.prototype.onQueryEnded_ = function(queryId) {
this.queryId_ = null;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment