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