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/builtin_provider.h"
18 #include "chrome/browser/autocomplete/history_quick_provider.h"
19 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h"
20 #include "chrome/browser/autocomplete/shortcuts_provider.h"
21 #include "chrome/browser/autocomplete/zero_suggest_provider.h"
22 #include "chrome/browser/chrome_notification_types.h"
23 #include "components/omnibox/bookmark_provider.h"
24 #include "components/omnibox/history_url_provider.h"
25 #include "components/omnibox/keyword_provider.h"
26 #include "components/omnibox/omnibox_field_trial.h"
27 #include "components/omnibox/search_provider.h"
28 #include "components/search_engines/template_url.h"
29 #include "components/search_engines/template_url_service.h"
30 #include "content/public/browser/notification_service.h"
31 #include "grit/components_strings.h"
32 #include "ui/base/l10n/l10n_util.h"
34 #if defined(ENABLE_EXTENSIONS)
35 #include "chrome/browser/autocomplete/keyword_extensions_delegate_impl.h"
40 // Converts the given match to a type (and possibly subtype) based on the AQS
41 // specification. For more details, see
42 // http://goto.google.com/binary-clients-logging.
43 void AutocompleteMatchToAssistedQuery(
44 const AutocompleteMatch::Type
& match
,
45 const AutocompleteProvider
* provider
,
48 // This type indicates a native chrome suggestion.
50 // Default value, indicating no subtype.
51 *subtype
= base::string16::npos
;
53 // If provider is TYPE_ZERO_SUGGEST, set the subtype accordingly.
54 // Type will be set in the switch statement below where we'll enter one of
55 // SEARCH_SUGGEST or NAVSUGGEST. This subtype indicates context-aware zero
58 (provider
->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST
) &&
59 (match
!= AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED
)) {
60 DCHECK((match
== AutocompleteMatchType::SEARCH_SUGGEST
) ||
61 (match
== AutocompleteMatchType::NAVSUGGEST
));
66 case AutocompleteMatchType::SEARCH_SUGGEST
: {
67 // Do not set subtype here; subtype may have been set above.
71 case AutocompleteMatchType::SEARCH_SUGGEST_ENTITY
: {
75 case AutocompleteMatchType::SEARCH_SUGGEST_TAIL
: {
79 case AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED
: {
83 case AutocompleteMatchType::SEARCH_SUGGEST_PROFILE
: {
87 case AutocompleteMatchType::NAVSUGGEST
: {
88 // Do not set subtype here; subtype may have been set above.
92 case AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED
: {
96 case AutocompleteMatchType::URL_WHAT_YOU_TYPED
: {
100 case AutocompleteMatchType::SEARCH_HISTORY
: {
104 case AutocompleteMatchType::HISTORY_URL
: {
108 case AutocompleteMatchType::HISTORY_TITLE
: {
112 case AutocompleteMatchType::HISTORY_BODY
: {
116 case AutocompleteMatchType::HISTORY_KEYWORD
: {
120 case AutocompleteMatchType::BOOKMARK_TITLE
: {
124 case AutocompleteMatchType::NAVSUGGEST_PERSONALIZED
: {
129 // This value indicates a native chrome suggestion with no named subtype
136 // Appends available autocompletion of the given type, subtype, and number to
137 // the existing available autocompletions string, encoding according to the
139 void AppendAvailableAutocompletion(size_t type
,
142 std::string
* autocompletions
) {
143 if (!autocompletions
->empty())
144 autocompletions
->append("j");
145 base::StringAppendF(autocompletions
, "%" PRIuS
, type
);
146 // Subtype is optional - base::string16::npos indicates no subtype.
147 if (subtype
!= base::string16::npos
)
148 base::StringAppendF(autocompletions
, "i%" PRIuS
, subtype
);
150 base::StringAppendF(autocompletions
, "l%d", count
);
153 // Returns whether the autocompletion is trivial enough that we consider it
154 // an autocompletion for which the omnibox autocompletion code did not add
156 bool IsTrivialAutocompletion(const AutocompleteMatch
& match
) {
157 return match
.type
== AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED
||
158 match
.type
== AutocompleteMatchType::URL_WHAT_YOU_TYPED
||
159 match
.type
== AutocompleteMatchType::SEARCH_OTHER_ENGINE
;
162 // Whether this autocomplete match type supports custom descriptions.
163 bool AutocompleteMatchHasCustomDescription(const AutocompleteMatch
& match
) {
164 return match
.type
== AutocompleteMatchType::SEARCH_SUGGEST_ENTITY
||
165 match
.type
== AutocompleteMatchType::SEARCH_SUGGEST_PROFILE
;
170 AutocompleteController::AutocompleteController(
172 TemplateURLService
* template_url_service
,
173 AutocompleteControllerDelegate
* delegate
,
175 : delegate_(delegate
),
176 provider_client_(new ChromeAutocompleteProviderClient(profile
)),
177 history_url_provider_(NULL
),
178 keyword_provider_(NULL
),
179 search_provider_(NULL
),
180 zero_suggest_provider_(NULL
),
181 stop_timer_duration_(OmniboxFieldTrial::StopTimerFieldTrialDuration()),
184 template_url_service_(template_url_service
) {
185 provider_types
&= ~OmniboxFieldTrial::GetDisabledProviderTypes();
186 if (provider_types
& AutocompleteProvider::TYPE_BOOKMARK
)
187 providers_
.push_back(new BookmarkProvider(provider_client_
.get()));
188 if (provider_types
& AutocompleteProvider::TYPE_BUILTIN
)
189 providers_
.push_back(new BuiltinProvider());
190 if (provider_types
& AutocompleteProvider::TYPE_HISTORY_QUICK
) {
191 providers_
.push_back(new HistoryQuickProvider(
192 provider_client_
.get(), profile
,
193 InMemoryURLIndexFactory::GetForProfile(profile
)));
195 if (provider_types
& AutocompleteProvider::TYPE_HISTORY_URL
) {
196 history_url_provider_
=
197 new HistoryURLProvider(provider_client_
.get(), this);
198 providers_
.push_back(history_url_provider_
);
200 // "Tab to search" can be used on all platforms other than Android.
201 #if !defined(OS_ANDROID)
202 if (provider_types
& AutocompleteProvider::TYPE_KEYWORD
) {
203 keyword_provider_
= new KeywordProvider(this, template_url_service
);
204 #if defined(ENABLE_EXTENSIONS)
205 keyword_provider_
->set_extensions_delegate(
206 scoped_ptr
<KeywordExtensionsDelegate
>(
207 new KeywordExtensionsDelegateImpl(profile
, keyword_provider_
)));
209 providers_
.push_back(keyword_provider_
);
212 if (provider_types
& AutocompleteProvider::TYPE_SEARCH
) {
214 new SearchProvider(provider_client_
.get(), this, template_url_service
);
215 providers_
.push_back(search_provider_
);
217 if (provider_types
& AutocompleteProvider::TYPE_SHORTCUTS
)
218 providers_
.push_back(new ShortcutsProvider(profile
));
219 if (provider_types
& AutocompleteProvider::TYPE_ZERO_SUGGEST
) {
220 zero_suggest_provider_
= ZeroSuggestProvider::Create(
221 provider_client_
.get(), this, template_url_service
, profile
);
222 if (zero_suggest_provider_
)
223 providers_
.push_back(zero_suggest_provider_
);
227 AutocompleteController::~AutocompleteController() {
228 // The providers may have tasks outstanding that hold refs to them. We need
229 // to ensure they won't call us back if they outlive us. (Practically,
230 // calling Stop() should also cancel those tasks and make it so that we hold
231 // the only refs.) We also don't want to bother notifying anyone of our
232 // result changes here, because the notification observer is in the midst of
233 // shutdown too, so we don't ask Stop() to clear |result_| (and notify).
234 result_
.Reset(); // Not really necessary.
238 void AutocompleteController::Start(const AutocompleteInput
& input
) {
239 const base::string16
old_input_text(input_
.text());
240 const bool old_want_asynchronous_matches
= input_
.want_asynchronous_matches();
243 // See if we can avoid rerunning autocomplete when the query hasn't changed
244 // much. When the user presses or releases the ctrl key, the desired_tld
245 // changes, and when the user finishes an IME composition, inline autocomplete
246 // may no longer be prevented. In both these cases the text itself hasn't
247 // changed since the last query, and some providers can do much less work (and
248 // get matches back more quickly). Taking advantage of this reduces flicker.
250 // NOTE: This comes after constructing |input_| above since that construction
251 // can change the text string (e.g. by stripping off a leading '?').
252 const bool minimal_changes
= (input_
.text() == old_input_text
) &&
253 (input_
.want_asynchronous_matches() == old_want_asynchronous_matches
);
255 expire_timer_
.Stop();
258 // Start the new query.
260 base::TimeTicks start_time
= base::TimeTicks::Now();
261 for (Providers::iterator
i(providers_
.begin()); i
!= providers_
.end(); ++i
) {
262 // TODO(mpearson): Remove timing code once bug 178705 is resolved.
263 base::TimeTicks provider_start_time
= base::TimeTicks::Now();
264 (*i
)->Start(input_
, minimal_changes
, false);
265 if (!input
.want_asynchronous_matches())
266 DCHECK((*i
)->done());
267 base::TimeTicks provider_end_time
= base::TimeTicks::Now();
268 std::string name
= std::string("Omnibox.ProviderTime.") + (*i
)->GetName();
269 base::HistogramBase
* counter
= base::Histogram::FactoryGet(
270 name
, 1, 5000, 20, base::Histogram::kUmaTargetedHistogramFlag
);
271 counter
->Add(static_cast<int>(
272 (provider_end_time
- provider_start_time
).InMilliseconds()));
274 if (input
.want_asynchronous_matches() && (input
.text().length() < 6)) {
275 base::TimeTicks end_time
= base::TimeTicks::Now();
276 std::string name
= "Omnibox.QueryTime." + base::IntToString(
277 input
.text().length());
278 base::HistogramBase
* counter
= base::Histogram::FactoryGet(
279 name
, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag
);
280 counter
->Add(static_cast<int>((end_time
- start_time
).InMilliseconds()));
284 // The second true forces saying the default match has changed.
285 // This triggers the edit model to update things such as the inline
286 // autocomplete state. In particular, if the user has typed a key
287 // since the last notification, and we're now re-running
288 // autocomplete, then we need to update the inline autocompletion
289 // even if the current match is for the same URL as the last run's
290 // default match. Likewise, the controller doesn't know what's
291 // happened in the edit since the last time it ran autocomplete.
292 // The user might have selected all the text and hit delete, then
293 // typed a new character. The selection and delete won't send any
294 // signals to the controller so it doesn't realize that anything was
295 // cleared or changed. Even if the default match hasn't changed, we
296 // need the edit model to update the display.
297 UpdateResult(false, true);
305 void AutocompleteController::Stop(bool clear_result
) {
306 StopHelper(clear_result
, false);
309 void AutocompleteController::OnOmniboxFocused(const AutocompleteInput
& input
) {
310 DCHECK(!in_start_
); // We should not be already running a query.
312 // Call Start() on all prefix-based providers with an INVALID
313 // AutocompleteInput to clear out cached |matches_|, which ensures that
314 // they aren't used with zero suggest.
315 for (Providers::iterator
i(providers_
.begin()); i
!= providers_
.end(); ++i
)
316 (*i
)->Start(input
, false, true);
318 UpdateResult(false, false);
321 void AutocompleteController::DeleteMatch(const AutocompleteMatch
& match
) {
322 DCHECK(match
.SupportsDeletion());
324 // Delete duplicate matches attached to the main match first.
325 for (ACMatches::const_iterator
it(match
.duplicate_matches
.begin());
326 it
!= match
.duplicate_matches
.end(); ++it
) {
328 it
->provider
->DeleteMatch(*it
);
332 match
.provider
->DeleteMatch(match
);
334 OnProviderUpdate(true);
336 // If we're not done, we might attempt to redisplay the deleted match. Make
337 // sure we aren't displaying it by removing any old entries.
338 ExpireCopiedEntries();
341 void AutocompleteController::ExpireCopiedEntries() {
342 // The first true makes UpdateResult() clear out the results and
343 // regenerate them, thus ensuring that no results from the previous
344 // result set remain.
345 UpdateResult(true, false);
348 void AutocompleteController::OnProviderUpdate(bool updated_matches
) {
350 // Multiple providers may provide synchronous results, so we only update the
351 // results if we're not in Start().
352 if (!in_start_
&& (updated_matches
|| done_
))
353 UpdateResult(false, false);
356 void AutocompleteController::AddProvidersInfo(
357 ProvidersInfo
* provider_info
) const {
358 provider_info
->clear();
359 for (Providers::const_iterator
i(providers_
.begin()); i
!= providers_
.end();
361 // Add per-provider info, if any.
362 (*i
)->AddProviderInfo(provider_info
);
364 // This is also a good place to put code to add info that you want to
365 // add for every provider.
369 void AutocompleteController::ResetSession() {
370 for (Providers::const_iterator
i(providers_
.begin()); i
!= providers_
.end();
372 (*i
)->ResetSession();
375 void AutocompleteController::UpdateMatchDestinationURLWithQueryFormulationTime(
376 base::TimeDelta query_formulation_time
,
377 AutocompleteMatch
* match
) const {
378 if (!match
->search_terms_args
.get() ||
379 match
->search_terms_args
->assisted_query_stats
.empty())
382 // Append the query formulation time (time from when the user first typed a
383 // character into the omnibox to when the user selected a query) and whether
384 // a field trial has triggered to the AQS parameter.
385 TemplateURLRef::SearchTermsArgs
search_terms_args(*match
->search_terms_args
);
386 search_terms_args
.assisted_query_stats
+= base::StringPrintf(
387 ".%" PRId64
"j%dj%d",
388 query_formulation_time
.InMilliseconds(),
390 search_provider_
->field_trial_triggered_in_session()) ||
391 (zero_suggest_provider_
&&
392 zero_suggest_provider_
->field_trial_triggered_in_session()),
393 input_
.current_page_classification());
394 UpdateMatchDestinationURL(search_terms_args
, match
);
397 void AutocompleteController::UpdateMatchDestinationURL(
398 const TemplateURLRef::SearchTermsArgs
& search_terms_args
,
399 AutocompleteMatch
* match
) const {
400 TemplateURL
* template_url
= match
->GetTemplateURL(
401 template_url_service_
, false);
405 match
->destination_url
= GURL(template_url
->url_ref().ReplaceSearchTerms(
406 search_terms_args
, template_url_service_
->search_terms_data()));
409 void AutocompleteController::UpdateResult(
410 bool regenerate_result
,
411 bool force_notify_default_match_changed
) {
412 const bool last_default_was_valid
= result_
.default_match() != result_
.end();
413 // The following three variables are only set and used if
414 // |last_default_was_valid|.
415 base::string16 last_default_fill_into_edit
, last_default_keyword
,
416 last_default_associated_keyword
;
417 if (last_default_was_valid
) {
418 last_default_fill_into_edit
= result_
.default_match()->fill_into_edit
;
419 last_default_keyword
= result_
.default_match()->keyword
;
420 if (result_
.default_match()->associated_keyword
!= NULL
)
421 last_default_associated_keyword
=
422 result_
.default_match()->associated_keyword
->keyword
;
425 if (regenerate_result
)
428 AutocompleteResult last_result
;
429 last_result
.Swap(&result_
);
431 for (Providers::const_iterator
i(providers_
.begin());
432 i
!= providers_
.end(); ++i
)
433 result_
.AppendMatches(input_
, (*i
)->matches());
435 // Sort the matches and trim to a small number of "best" matches.
436 result_
.SortAndCull(input_
, template_url_service_
);
438 // Need to validate before invoking CopyOldMatches as the old matches are not
439 // valid against the current input.
445 // This conditional needs to match the conditional in Start that invokes
447 result_
.CopyOldMatches(input_
, last_result
, template_url_service_
);
450 UpdateKeywordDescriptions(&result_
);
451 UpdateAssociatedKeywords(&result_
);
452 UpdateAssistedQueryStats(&result_
);
453 if (search_provider_
)
454 search_provider_
->RegisterDisplayedAnswers(result_
);
456 const bool default_is_valid
= result_
.default_match() != result_
.end();
457 base::string16 default_associated_keyword
;
458 if (default_is_valid
&&
459 (result_
.default_match()->associated_keyword
!= NULL
)) {
460 default_associated_keyword
=
461 result_
.default_match()->associated_keyword
->keyword
;
463 // We've gotten async results. Send notification that the default match
464 // updated if fill_into_edit, associated_keyword, or keyword differ. (The
465 // second can change if we've just started Chrome and the keyword database
466 // finishes loading while processing this request. The third can change
467 // if we swapped from interpreting the input as a search--which gets
468 // labeled with the default search provider's keyword--to a URL.)
469 // We don't check the URL as that may change for the default match
470 // even though the fill into edit hasn't changed (see SearchProvider
471 // for one case of this).
472 const bool notify_default_match
=
473 (last_default_was_valid
!= default_is_valid
) ||
474 (last_default_was_valid
&&
475 ((result_
.default_match()->fill_into_edit
!=
476 last_default_fill_into_edit
) ||
477 (default_associated_keyword
!= last_default_associated_keyword
) ||
478 (result_
.default_match()->keyword
!= last_default_keyword
)));
479 if (notify_default_match
)
480 last_time_default_match_changed_
= base::TimeTicks::Now();
482 NotifyChanged(force_notify_default_match_changed
|| notify_default_match
);
485 void AutocompleteController::UpdateAssociatedKeywords(
486 AutocompleteResult
* result
) {
487 if (!keyword_provider_
)
490 // Determine if the user's input is an exact keyword match.
491 base::string16 exact_keyword
= keyword_provider_
->GetKeywordForText(
492 TemplateURLService::CleanUserInputKeyword(input_
.text()));
494 std::set
<base::string16
> keywords
;
495 for (ACMatches::iterator
match(result
->begin()); match
!= result
->end();
497 base::string16
keyword(
498 match
->GetSubstitutingExplicitlyInvokedKeyword(template_url_service_
));
499 if (!keyword
.empty()) {
500 keywords
.insert(keyword
);
504 // When the user has typed an exact keyword, we want tab-to-search on the
505 // default match to select that keyword, even if the match
506 // inline-autocompletes to a different keyword. (This prevents inline
507 // autocompletions from blocking a user's attempts to use an explicitly-set
508 // keyword of their own creation.) So use |exact_keyword| if it's
510 if (!exact_keyword
.empty() && !keywords
.count(exact_keyword
)) {
511 keywords
.insert(exact_keyword
);
512 match
->associated_keyword
.reset(new AutocompleteMatch(
513 keyword_provider_
->CreateVerbatimMatch(exact_keyword
,
514 exact_keyword
, input_
)));
518 // Otherwise, set a match's associated keyword based on the match's
519 // fill_into_edit, which should take inline autocompletions into account.
520 keyword
= keyword_provider_
->GetKeywordForText(match
->fill_into_edit
);
522 // Only add the keyword if the match does not have a duplicate keyword with
523 // a more relevant match.
524 if (!keyword
.empty() && !keywords
.count(keyword
)) {
525 keywords
.insert(keyword
);
526 match
->associated_keyword
.reset(new AutocompleteMatch(
527 keyword_provider_
->CreateVerbatimMatch(match
->fill_into_edit
,
530 match
->associated_keyword
.reset();
535 void AutocompleteController::UpdateKeywordDescriptions(
536 AutocompleteResult
* result
) {
537 base::string16 last_keyword
;
538 for (AutocompleteResult::iterator
i(result
->begin()); i
!= result
->end();
540 if (AutocompleteMatch::IsSearchType(i
->type
)) {
541 if (AutocompleteMatchHasCustomDescription(*i
))
543 i
->description
.clear();
544 i
->description_class
.clear();
545 DCHECK(!i
->keyword
.empty());
546 if (i
->keyword
!= last_keyword
) {
547 const TemplateURL
* template_url
=
548 i
->GetTemplateURL(template_url_service_
, false);
550 // For extension keywords, just make the description the extension
551 // name -- don't assume that the normal search keyword description is
553 i
->description
= template_url
->AdjustedShortNameForLocaleDirection();
554 if (template_url
->GetType() != TemplateURL::OMNIBOX_API_EXTENSION
) {
555 i
->description
= l10n_util::GetStringFUTF16(
556 IDS_AUTOCOMPLETE_SEARCH_DESCRIPTION
, i
->description
);
558 i
->description_class
.push_back(
559 ACMatchClassification(0, ACMatchClassification::DIM
));
561 last_keyword
= i
->keyword
;
564 last_keyword
.clear();
569 void AutocompleteController::UpdateAssistedQueryStats(
570 AutocompleteResult
* result
) {
574 // Build the impressions string (the AQS part after ".").
575 std::string autocompletions
;
577 size_t last_type
= base::string16::npos
;
578 size_t last_subtype
= base::string16::npos
;
579 for (ACMatches::iterator
match(result
->begin()); match
!= result
->end();
581 size_t type
= base::string16::npos
;
582 size_t subtype
= base::string16::npos
;
583 AutocompleteMatchToAssistedQuery(
584 match
->type
, match
->provider
, &type
, &subtype
);
585 if (last_type
!= base::string16::npos
&&
586 (type
!= last_type
|| subtype
!= last_subtype
)) {
587 AppendAvailableAutocompletion(
588 last_type
, last_subtype
, count
, &autocompletions
);
594 last_subtype
= subtype
;
596 AppendAvailableAutocompletion(
597 last_type
, last_subtype
, count
, &autocompletions
);
598 // Go over all matches and set AQS if the match supports it.
599 for (size_t index
= 0; index
< result
->size(); ++index
) {
600 AutocompleteMatch
* match
= result
->match_at(index
);
601 const TemplateURL
* template_url
=
602 match
->GetTemplateURL(template_url_service_
, false);
603 if (!template_url
|| !match
->search_terms_args
.get())
605 std::string selected_index
;
606 // Prevent trivial suggestions from getting credit for being selected.
607 if (!IsTrivialAutocompletion(*match
))
608 selected_index
= base::StringPrintf("%" PRIuS
, index
);
609 match
->search_terms_args
->assisted_query_stats
=
610 base::StringPrintf("chrome.%s.%s",
611 selected_index
.c_str(),
612 autocompletions
.c_str());
613 match
->destination_url
= GURL(template_url
->url_ref().ReplaceSearchTerms(
614 *match
->search_terms_args
, template_url_service_
->search_terms_data()));
618 void AutocompleteController::NotifyChanged(bool notify_default_match
) {
620 delegate_
->OnResultChanged(notify_default_match
);
622 content::NotificationService::current()->Notify(
623 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY
,
624 content::Source
<AutocompleteController
>(this),
625 content::NotificationService::NoDetails());
629 void AutocompleteController::CheckIfDone() {
630 for (Providers::const_iterator
i(providers_
.begin()); i
!= providers_
.end();
640 void AutocompleteController::StartExpireTimer() {
641 // Amount of time (in ms) between when the user stops typing and
642 // when we remove any copied entries. We do this from the time the
643 // user stopped typing as some providers (such as SearchProvider)
644 // wait for the user to stop typing before they initiate a query.
645 const int kExpireTimeMS
= 500;
647 if (result_
.HasCopiedMatches())
648 expire_timer_
.Start(FROM_HERE
,
649 base::TimeDelta::FromMilliseconds(kExpireTimeMS
),
650 this, &AutocompleteController::ExpireCopiedEntries
);
653 void AutocompleteController::StartStopTimer() {
654 stop_timer_
.Start(FROM_HERE
,
655 stop_timer_duration_
,
656 base::Bind(&AutocompleteController::StopHelper
,
657 base::Unretained(this),
661 void AutocompleteController::StopHelper(bool clear_result
,
662 bool due_to_user_inactivity
) {
663 for (Providers::const_iterator
i(providers_
.begin()); i
!= providers_
.end();
665 (*i
)->Stop(clear_result
, due_to_user_inactivity
);
668 expire_timer_
.Stop();
671 if (clear_result
&& !result_
.empty()) {
673 // NOTE: We pass in false since we're trying to only clear the popup, not
674 // touch the edit... this is all a mess and should be cleaned up :(
675 NotifyChanged(false);