1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/autocomplete/autocomplete_controller.h"
10 #include "base/format_macros.h"
11 #include "base/logging.h"
12 #include "base/metrics/histogram.h"
13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h"
15 #include "base/time/time.h"
16 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h"
17 #include "chrome/browser/autocomplete/bookmark_provider.h"
18 #include "chrome/browser/autocomplete/builtin_provider.h"
19 #include "chrome/browser/autocomplete/history_quick_provider.h"
20 #include "chrome/browser/autocomplete/history_url_provider.h"
21 #include "chrome/browser/autocomplete/search_provider.h"
22 #include "chrome/browser/autocomplete/shortcuts_provider.h"
23 #include "chrome/browser/autocomplete/zero_suggest_provider.h"
24 #include "chrome/browser/chrome_notification_types.h"
25 #include "components/omnibox/keyword_provider.h"
26 #include "components/omnibox/omnibox_field_trial.h"
27 #include "components/search_engines/template_url.h"
28 #include "components/search_engines/template_url_service.h"
29 #include "content/public/browser/notification_service.h"
30 #include "grit/components_strings.h"
31 #include "ui/base/l10n/l10n_util.h"
33 #if defined(ENABLE_EXTENSIONS)
34 #include "chrome/browser/autocomplete/keyword_extensions_delegate_impl.h"
39 // Converts the given match to a type (and possibly subtype) based on the AQS
40 // specification. For more details, see
41 // http://goto.google.com/binary-clients-logging.
42 void AutocompleteMatchToAssistedQuery(
43 const AutocompleteMatch::Type
& match
,
44 const AutocompleteProvider
* provider
,
47 // This type indicates a native chrome suggestion.
49 // Default value, indicating no subtype.
50 *subtype
= base::string16::npos
;
52 // If provider is TYPE_ZERO_SUGGEST, set the subtype accordingly.
53 // Type will be set in the switch statement below where we'll enter one of
54 // SEARCH_SUGGEST or NAVSUGGEST. This subtype indicates context-aware zero
57 (provider
->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST
) &&
58 (match
!= AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED
)) {
59 DCHECK((match
== AutocompleteMatchType::SEARCH_SUGGEST
) ||
60 (match
== AutocompleteMatchType::NAVSUGGEST
));
65 case AutocompleteMatchType::SEARCH_SUGGEST
: {
66 // Do not set subtype here; subtype may have been set above.
70 case AutocompleteMatchType::SEARCH_SUGGEST_ENTITY
: {
74 case AutocompleteMatchType::SEARCH_SUGGEST_INFINITE
: {
78 case AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED
: {
82 case AutocompleteMatchType::SEARCH_SUGGEST_PROFILE
: {
86 case AutocompleteMatchType::SEARCH_SUGGEST_ANSWER
: {
90 case AutocompleteMatchType::NAVSUGGEST
: {
91 // Do not set subtype here; subtype may have been set above.
95 case AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED
: {
99 case AutocompleteMatchType::URL_WHAT_YOU_TYPED
: {
103 case AutocompleteMatchType::SEARCH_HISTORY
: {
107 case AutocompleteMatchType::HISTORY_URL
: {
111 case AutocompleteMatchType::HISTORY_TITLE
: {
115 case AutocompleteMatchType::HISTORY_BODY
: {
119 case AutocompleteMatchType::HISTORY_KEYWORD
: {
123 case AutocompleteMatchType::BOOKMARK_TITLE
: {
127 case AutocompleteMatchType::NAVSUGGEST_PERSONALIZED
: {
132 // This value indicates a native chrome suggestion with no named subtype
139 // Appends available autocompletion of the given type, subtype, and number to
140 // the existing available autocompletions string, encoding according to the
142 void AppendAvailableAutocompletion(size_t type
,
145 std::string
* autocompletions
) {
146 if (!autocompletions
->empty())
147 autocompletions
->append("j");
148 base::StringAppendF(autocompletions
, "%" PRIuS
, type
);
149 // Subtype is optional - base::string16::npos indicates no subtype.
150 if (subtype
!= base::string16::npos
)
151 base::StringAppendF(autocompletions
, "i%" PRIuS
, subtype
);
153 base::StringAppendF(autocompletions
, "l%d", count
);
156 // Returns whether the autocompletion is trivial enough that we consider it
157 // an autocompletion for which the omnibox autocompletion code did not add
159 bool IsTrivialAutocompletion(const AutocompleteMatch
& match
) {
160 return match
.type
== AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED
||
161 match
.type
== AutocompleteMatchType::URL_WHAT_YOU_TYPED
||
162 match
.type
== AutocompleteMatchType::SEARCH_OTHER_ENGINE
;
165 // Whether this autocomplete match type supports custom descriptions.
166 bool AutocompleteMatchHasCustomDescription(const AutocompleteMatch
& match
) {
167 return match
.type
== AutocompleteMatchType::SEARCH_SUGGEST_ENTITY
||
168 match
.type
== AutocompleteMatchType::SEARCH_SUGGEST_PROFILE
;
173 AutocompleteController::AutocompleteController(
175 TemplateURLService
* template_url_service
,
176 AutocompleteControllerDelegate
* delegate
,
178 : delegate_(delegate
),
179 history_url_provider_(NULL
),
180 keyword_provider_(NULL
),
181 search_provider_(NULL
),
182 zero_suggest_provider_(NULL
),
183 stop_timer_duration_(OmniboxFieldTrial::StopTimerFieldTrialDuration()),
186 template_url_service_(template_url_service
) {
187 provider_types
&= ~OmniboxFieldTrial::GetDisabledProviderTypes();
188 if (provider_types
& AutocompleteProvider::TYPE_BOOKMARK
)
189 providers_
.push_back(new BookmarkProvider(profile
));
190 if (provider_types
& AutocompleteProvider::TYPE_BUILTIN
)
191 providers_
.push_back(new BuiltinProvider());
192 if (provider_types
& AutocompleteProvider::TYPE_HISTORY_QUICK
)
193 providers_
.push_back(new HistoryQuickProvider(profile
));
194 if (provider_types
& AutocompleteProvider::TYPE_HISTORY_URL
) {
195 history_url_provider_
= new HistoryURLProvider(this, profile
);
196 providers_
.push_back(history_url_provider_
);
198 // "Tab to search" can be used on all platforms other than Android.
199 #if !defined(OS_ANDROID)
200 if (provider_types
& AutocompleteProvider::TYPE_KEYWORD
) {
201 keyword_provider_
= new KeywordProvider(this, template_url_service
);
202 #if defined(ENABLE_EXTENSIONS)
203 keyword_provider_
->set_extensions_delegate(
204 scoped_ptr
<KeywordExtensionsDelegate
>(
205 new KeywordExtensionsDelegateImpl(profile
, keyword_provider_
)));
207 providers_
.push_back(keyword_provider_
);
210 if (provider_types
& AutocompleteProvider::TYPE_SEARCH
) {
211 search_provider_
= new SearchProvider(this, template_url_service
, profile
);
212 providers_
.push_back(search_provider_
);
214 if (provider_types
& AutocompleteProvider::TYPE_SHORTCUTS
)
215 providers_
.push_back(new ShortcutsProvider(profile
));
216 if (provider_types
& AutocompleteProvider::TYPE_ZERO_SUGGEST
) {
217 zero_suggest_provider_
= ZeroSuggestProvider::Create(
218 this, template_url_service
, profile
);
219 if (zero_suggest_provider_
)
220 providers_
.push_back(zero_suggest_provider_
);
224 AutocompleteController::~AutocompleteController() {
225 // The providers may have tasks outstanding that hold refs to them. We need
226 // to ensure they won't call us back if they outlive us. (Practically,
227 // calling Stop() should also cancel those tasks and make it so that we hold
228 // the only refs.) We also don't want to bother notifying anyone of our
229 // result changes here, because the notification observer is in the midst of
230 // shutdown too, so we don't ask Stop() to clear |result_| (and notify).
231 result_
.Reset(); // Not really necessary.
235 void AutocompleteController::Start(const AutocompleteInput
& input
) {
236 const base::string16
old_input_text(input_
.text());
237 const bool old_want_asynchronous_matches
= input_
.want_asynchronous_matches();
240 // See if we can avoid rerunning autocomplete when the query hasn't changed
241 // much. When the user presses or releases the ctrl key, the desired_tld
242 // changes, and when the user finishes an IME composition, inline autocomplete
243 // may no longer be prevented. In both these cases the text itself hasn't
244 // changed since the last query, and some providers can do much less work (and
245 // get matches back more quickly). Taking advantage of this reduces flicker.
247 // NOTE: This comes after constructing |input_| above since that construction
248 // can change the text string (e.g. by stripping off a leading '?').
249 const bool minimal_changes
= (input_
.text() == old_input_text
) &&
250 (input_
.want_asynchronous_matches() == old_want_asynchronous_matches
);
252 expire_timer_
.Stop();
255 // Start the new query.
257 base::TimeTicks start_time
= base::TimeTicks::Now();
258 for (Providers::iterator
i(providers_
.begin()); i
!= providers_
.end(); ++i
) {
259 // TODO(mpearson): Remove timing code once bugs 178705 / 237703 / 168933
261 base::TimeTicks provider_start_time
= base::TimeTicks::Now();
263 // Call Start() on ZeroSuggestProvider with an INVALID AutocompleteInput
264 // to clear out zero-suggest |matches_|.
265 if (*i
== zero_suggest_provider_
)
266 (*i
)->Start(AutocompleteInput(), minimal_changes
);
268 (*i
)->Start(input_
, minimal_changes
);
270 if (!input
.want_asynchronous_matches())
271 DCHECK((*i
)->done());
272 base::TimeTicks provider_end_time
= base::TimeTicks::Now();
273 std::string name
= std::string("Omnibox.ProviderTime.") + (*i
)->GetName();
274 base::HistogramBase
* counter
= base::Histogram::FactoryGet(
275 name
, 1, 5000, 20, base::Histogram::kUmaTargetedHistogramFlag
);
276 counter
->Add(static_cast<int>(
277 (provider_end_time
- provider_start_time
).InMilliseconds()));
279 if (input
.want_asynchronous_matches() && (input
.text().length() < 6)) {
280 base::TimeTicks end_time
= base::TimeTicks::Now();
281 std::string name
= "Omnibox.QueryTime." + base::IntToString(
282 input
.text().length());
283 base::HistogramBase
* counter
= base::Histogram::FactoryGet(
284 name
, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag
);
285 counter
->Add(static_cast<int>((end_time
- start_time
).InMilliseconds()));
289 // The second true forces saying the default match has changed.
290 // This triggers the edit model to update things such as the inline
291 // autocomplete state. In particular, if the user has typed a key
292 // since the last notification, and we're now re-running
293 // autocomplete, then we need to update the inline autocompletion
294 // even if the current match is for the same URL as the last run's
295 // default match. Likewise, the controller doesn't know what's
296 // happened in the edit since the last time it ran autocomplete.
297 // The user might have selected all the text and hit delete, then
298 // typed a new character. The selection and delete won't send any
299 // signals to the controller so it doesn't realize that anything was
300 // cleared or changed. Even if the default match hasn't changed, we
301 // need the edit model to update the display.
302 UpdateResult(false, true);
310 void AutocompleteController::Stop(bool clear_result
) {
311 for (Providers::const_iterator
i(providers_
.begin()); i
!= providers_
.end();
313 (*i
)->Stop(clear_result
);
316 expire_timer_
.Stop();
319 if (clear_result
&& !result_
.empty()) {
321 // NOTE: We pass in false since we're trying to only clear the popup, not
322 // touch the edit... this is all a mess and should be cleaned up :(
323 NotifyChanged(false);
327 void AutocompleteController::StartZeroSuggest(const AutocompleteInput
& input
) {
328 if (zero_suggest_provider_
== NULL
)
331 DCHECK(!in_start_
); // We should not be already running a query.
333 // Call Start() on all prefix-based providers with an INVALID
334 // AutocompleteInput to clear out cached |matches_|, which ensures that
335 // they aren't used with zero suggest.
336 for (Providers::iterator
i(providers_
.begin()); i
!= providers_
.end(); ++i
) {
337 if (*i
== zero_suggest_provider_
)
338 (*i
)->Start(input
, false);
340 (*i
)->Start(AutocompleteInput(), false);
343 if (!zero_suggest_provider_
->matches().empty())
344 UpdateResult(false, false);
347 void AutocompleteController::DeleteMatch(const AutocompleteMatch
& match
) {
348 DCHECK(match
.SupportsDeletion());
350 // Delete duplicate matches attached to the main match first.
351 for (ACMatches::const_iterator
it(match
.duplicate_matches
.begin());
352 it
!= match
.duplicate_matches
.end(); ++it
) {
354 it
->provider
->DeleteMatch(*it
);
358 match
.provider
->DeleteMatch(match
);
360 OnProviderUpdate(true);
362 // If we're not done, we might attempt to redisplay the deleted match. Make
363 // sure we aren't displaying it by removing any old entries.
364 ExpireCopiedEntries();
367 void AutocompleteController::ExpireCopiedEntries() {
368 // The first true makes UpdateResult() clear out the results and
369 // regenerate them, thus ensuring that no results from the previous
370 // result set remain.
371 UpdateResult(true, false);
374 void AutocompleteController::OnProviderUpdate(bool updated_matches
) {
376 // Multiple providers may provide synchronous results, so we only update the
377 // results if we're not in Start().
378 if (!in_start_
&& (updated_matches
|| done_
))
379 UpdateResult(false, false);
382 void AutocompleteController::AddProvidersInfo(
383 ProvidersInfo
* provider_info
) const {
384 provider_info
->clear();
385 for (Providers::const_iterator
i(providers_
.begin()); i
!= providers_
.end();
387 // Add per-provider info, if any.
388 (*i
)->AddProviderInfo(provider_info
);
390 // This is also a good place to put code to add info that you want to
391 // add for every provider.
395 void AutocompleteController::ResetSession() {
396 for (Providers::const_iterator
i(providers_
.begin()); i
!= providers_
.end();
398 (*i
)->ResetSession();
401 void AutocompleteController::UpdateMatchDestinationURLWithQueryFormulationTime(
402 base::TimeDelta query_formulation_time
,
403 AutocompleteMatch
* match
) const {
404 if (!match
->search_terms_args
.get() ||
405 match
->search_terms_args
->assisted_query_stats
.empty())
408 // Append the query formulation time (time from when the user first typed a
409 // character into the omnibox to when the user selected a query) and whether
410 // a field trial has triggered to the AQS parameter.
411 TemplateURLRef::SearchTermsArgs
search_terms_args(*match
->search_terms_args
);
412 search_terms_args
.assisted_query_stats
+= base::StringPrintf(
413 ".%" PRId64
"j%dj%d",
414 query_formulation_time
.InMilliseconds(),
416 search_provider_
->field_trial_triggered_in_session()) ||
417 (zero_suggest_provider_
&&
418 zero_suggest_provider_
->field_trial_triggered_in_session()),
419 input_
.current_page_classification());
420 UpdateMatchDestinationURL(search_terms_args
, match
);
423 void AutocompleteController::UpdateMatchDestinationURL(
424 const TemplateURLRef::SearchTermsArgs
& search_terms_args
,
425 AutocompleteMatch
* match
) const {
426 TemplateURL
* template_url
= match
->GetTemplateURL(
427 template_url_service_
, false);
431 match
->destination_url
= GURL(template_url
->url_ref().ReplaceSearchTerms(
432 search_terms_args
, template_url_service_
->search_terms_data()));
435 void AutocompleteController::UpdateResult(
436 bool regenerate_result
,
437 bool force_notify_default_match_changed
) {
438 const bool last_default_was_valid
= result_
.default_match() != result_
.end();
439 // The following three variables are only set and used if
440 // |last_default_was_valid|.
441 base::string16 last_default_fill_into_edit
, last_default_keyword
,
442 last_default_associated_keyword
;
443 if (last_default_was_valid
) {
444 last_default_fill_into_edit
= result_
.default_match()->fill_into_edit
;
445 last_default_keyword
= result_
.default_match()->keyword
;
446 if (result_
.default_match()->associated_keyword
!= NULL
)
447 last_default_associated_keyword
=
448 result_
.default_match()->associated_keyword
->keyword
;
451 if (regenerate_result
)
454 AutocompleteResult last_result
;
455 last_result
.Swap(&result_
);
457 for (Providers::const_iterator
i(providers_
.begin());
458 i
!= providers_
.end(); ++i
)
459 result_
.AppendMatches((*i
)->matches());
461 // Sort the matches and trim to a small number of "best" matches.
462 result_
.SortAndCull(input_
, template_url_service_
);
464 // Need to validate before invoking CopyOldMatches as the old matches are not
465 // valid against the current input.
471 // This conditional needs to match the conditional in Start that invokes
473 result_
.CopyOldMatches(input_
, last_result
, template_url_service_
);
476 UpdateKeywordDescriptions(&result_
);
477 UpdateAssociatedKeywords(&result_
);
478 UpdateAssistedQueryStats(&result_
);
479 if (search_provider_
)
480 search_provider_
->RegisterDisplayedAnswers(result_
);
482 const bool default_is_valid
= result_
.default_match() != result_
.end();
483 base::string16 default_associated_keyword
;
484 if (default_is_valid
&&
485 (result_
.default_match()->associated_keyword
!= NULL
)) {
486 default_associated_keyword
=
487 result_
.default_match()->associated_keyword
->keyword
;
489 // We've gotten async results. Send notification that the default match
490 // updated if fill_into_edit, associated_keyword, or keyword differ. (The
491 // second can change if we've just started Chrome and the keyword database
492 // finishes loading while processing this request. The third can change
493 // if we swapped from interpreting the input as a search--which gets
494 // labeled with the default search provider's keyword--to a URL.)
495 // We don't check the URL as that may change for the default match
496 // even though the fill into edit hasn't changed (see SearchProvider
497 // for one case of this).
498 const bool notify_default_match
=
499 (last_default_was_valid
!= default_is_valid
) ||
500 (last_default_was_valid
&&
501 ((result_
.default_match()->fill_into_edit
!=
502 last_default_fill_into_edit
) ||
503 (default_associated_keyword
!= last_default_associated_keyword
) ||
504 (result_
.default_match()->keyword
!= last_default_keyword
)));
505 if (notify_default_match
)
506 last_time_default_match_changed_
= base::TimeTicks::Now();
508 NotifyChanged(force_notify_default_match_changed
|| notify_default_match
);
511 void AutocompleteController::UpdateAssociatedKeywords(
512 AutocompleteResult
* result
) {
513 if (!keyword_provider_
)
516 // Determine if the user's input is an exact keyword match.
517 base::string16 exact_keyword
= keyword_provider_
->GetKeywordForText(
518 TemplateURLService::CleanUserInputKeyword(input_
.text()));
520 std::set
<base::string16
> keywords
;
521 for (ACMatches::iterator
match(result
->begin()); match
!= result
->end();
523 base::string16
keyword(
524 match
->GetSubstitutingExplicitlyInvokedKeyword(template_url_service_
));
525 if (!keyword
.empty()) {
526 keywords
.insert(keyword
);
530 // When the user has typed an exact keyword, we want tab-to-search on the
531 // default match to select that keyword, even if the match
532 // inline-autocompletes to a different keyword. (This prevents inline
533 // autocompletions from blocking a user's attempts to use an explicitly-set
534 // keyword of their own creation.) So use |exact_keyword| if it's
536 if (!exact_keyword
.empty() && !keywords
.count(exact_keyword
)) {
537 keywords
.insert(exact_keyword
);
538 match
->associated_keyword
.reset(new AutocompleteMatch(
539 keyword_provider_
->CreateVerbatimMatch(exact_keyword
,
540 exact_keyword
, input_
)));
544 // Otherwise, set a match's associated keyword based on the match's
545 // fill_into_edit, which should take inline autocompletions into account.
546 keyword
= keyword_provider_
->GetKeywordForText(match
->fill_into_edit
);
548 // Only add the keyword if the match does not have a duplicate keyword with
549 // a more relevant match.
550 if (!keyword
.empty() && !keywords
.count(keyword
)) {
551 keywords
.insert(keyword
);
552 match
->associated_keyword
.reset(new AutocompleteMatch(
553 keyword_provider_
->CreateVerbatimMatch(match
->fill_into_edit
,
556 match
->associated_keyword
.reset();
561 void AutocompleteController::UpdateKeywordDescriptions(
562 AutocompleteResult
* result
) {
563 base::string16 last_keyword
;
564 for (AutocompleteResult::iterator
i(result
->begin()); i
!= result
->end();
566 if (AutocompleteMatch::IsSearchType(i
->type
)) {
567 if (AutocompleteMatchHasCustomDescription(*i
))
569 i
->description
.clear();
570 i
->description_class
.clear();
571 DCHECK(!i
->keyword
.empty());
572 if (i
->keyword
!= last_keyword
) {
573 const TemplateURL
* template_url
=
574 i
->GetTemplateURL(template_url_service_
, false);
576 // For extension keywords, just make the description the extension
577 // name -- don't assume that the normal search keyword description is
579 i
->description
= template_url
->AdjustedShortNameForLocaleDirection();
580 if (template_url
->GetType() != TemplateURL::OMNIBOX_API_EXTENSION
) {
581 i
->description
= l10n_util::GetStringFUTF16(
582 IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION
, i
->description
);
584 i
->description_class
.push_back(
585 ACMatchClassification(0, ACMatchClassification::DIM
));
587 last_keyword
= i
->keyword
;
590 last_keyword
.clear();
595 void AutocompleteController::UpdateAssistedQueryStats(
596 AutocompleteResult
* result
) {
600 // Build the impressions string (the AQS part after ".").
601 std::string autocompletions
;
603 size_t last_type
= base::string16::npos
;
604 size_t last_subtype
= base::string16::npos
;
605 for (ACMatches::iterator
match(result
->begin()); match
!= result
->end();
607 size_t type
= base::string16::npos
;
608 size_t subtype
= base::string16::npos
;
609 AutocompleteMatchToAssistedQuery(
610 match
->type
, match
->provider
, &type
, &subtype
);
611 if (last_type
!= base::string16::npos
&&
612 (type
!= last_type
|| subtype
!= last_subtype
)) {
613 AppendAvailableAutocompletion(
614 last_type
, last_subtype
, count
, &autocompletions
);
620 last_subtype
= subtype
;
622 AppendAvailableAutocompletion(
623 last_type
, last_subtype
, count
, &autocompletions
);
624 // Go over all matches and set AQS if the match supports it.
625 for (size_t index
= 0; index
< result
->size(); ++index
) {
626 AutocompleteMatch
* match
= result
->match_at(index
);
627 const TemplateURL
* template_url
=
628 match
->GetTemplateURL(template_url_service_
, false);
629 if (!template_url
|| !match
->search_terms_args
.get())
631 std::string selected_index
;
632 // Prevent trivial suggestions from getting credit for being selected.
633 if (!IsTrivialAutocompletion(*match
))
634 selected_index
= base::StringPrintf("%" PRIuS
, index
);
635 match
->search_terms_args
->assisted_query_stats
=
636 base::StringPrintf("chrome.%s.%s",
637 selected_index
.c_str(),
638 autocompletions
.c_str());
639 match
->destination_url
= GURL(template_url
->url_ref().ReplaceSearchTerms(
640 *match
->search_terms_args
, template_url_service_
->search_terms_data()));
644 void AutocompleteController::NotifyChanged(bool notify_default_match
) {
646 delegate_
->OnResultChanged(notify_default_match
);
648 content::NotificationService::current()->Notify(
649 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY
,
650 content::Source
<AutocompleteController
>(this),
651 content::NotificationService::NoDetails());
655 void AutocompleteController::CheckIfDone() {
656 for (Providers::const_iterator
i(providers_
.begin()); i
!= providers_
.end();
666 void AutocompleteController::StartExpireTimer() {
667 // Amount of time (in ms) between when the user stops typing and
668 // when we remove any copied entries. We do this from the time the
669 // user stopped typing as some providers (such as SearchProvider)
670 // wait for the user to stop typing before they initiate a query.
671 const int kExpireTimeMS
= 500;
673 if (result_
.HasCopiedMatches())
674 expire_timer_
.Start(FROM_HERE
,
675 base::TimeDelta::FromMilliseconds(kExpireTimeMS
),
676 this, &AutocompleteController::ExpireCopiedEntries
);
679 void AutocompleteController::StartStopTimer() {
680 stop_timer_
.Start(FROM_HERE
,
681 stop_timer_duration_
,
682 base::Bind(&AutocompleteController::Stop
,
683 base::Unretained(this),