Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/browser/autocomplete/base_search_provider.cc

Issue 158223002: Part 5 of search provider refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Co-locate overrides Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autocomplete/base_search_provider.h" 5 #include "chrome/browser/autocomplete/base_search_provider.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 24 matching lines...) Expand all
35 AutocompleteProvider::Type type) 35 AutocompleteProvider::Type type)
36 : AutocompleteProvider(listener, profile, type), 36 : AutocompleteProvider(listener, profile, type),
37 field_trial_triggered_(false), 37 field_trial_triggered_(false),
38 field_trial_triggered_in_session_(false) {} 38 field_trial_triggered_in_session_(false) {}
39 39
40 // static 40 // static
41 bool BaseSearchProvider::ShouldPrefetch(const AutocompleteMatch& match) { 41 bool BaseSearchProvider::ShouldPrefetch(const AutocompleteMatch& match) {
42 return match.GetAdditionalInfo(kShouldPrefetchKey) == kTrue; 42 return match.GetAdditionalInfo(kShouldPrefetchKey) == kTrue;
43 } 43 }
44 44
45 void BaseSearchProvider::Stop(bool clear_cached_results) {
46 StopSuggest();
47 done_ = true;
48
49 if (clear_cached_results)
50 ClearAllResults();
51 }
52
45 void BaseSearchProvider::AddProviderInfo(ProvidersInfo* provider_info) const { 53 void BaseSearchProvider::AddProviderInfo(ProvidersInfo* provider_info) const {
46 provider_info->push_back(metrics::OmniboxEventProto_ProviderInfo()); 54 provider_info->push_back(metrics::OmniboxEventProto_ProviderInfo());
47 metrics::OmniboxEventProto_ProviderInfo& new_entry = provider_info->back(); 55 metrics::OmniboxEventProto_ProviderInfo& new_entry = provider_info->back();
48 new_entry.set_provider(AsOmniboxEventProviderType()); 56 new_entry.set_provider(AsOmniboxEventProviderType());
49 new_entry.set_provider_done(done_); 57 new_entry.set_provider_done(done_);
50 std::vector<uint32> field_trial_hashes; 58 std::vector<uint32> field_trial_hashes;
51 OmniboxFieldTrial::GetActiveSuggestFieldTrialHashes(&field_trial_hashes); 59 OmniboxFieldTrial::GetActiveSuggestFieldTrialHashes(&field_trial_hashes);
52 for (size_t i = 0; i < field_trial_hashes.size(); ++i) { 60 for (size_t i = 0; i < field_trial_hashes.size(); ++i) {
53 if (field_trial_triggered_) 61 if (field_trial_triggered_)
54 new_entry.mutable_field_trial_triggered()->Add(field_trial_hashes[i]); 62 new_entry.mutable_field_trial_triggered()->Add(field_trial_hashes[i]);
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 // setting the prefetch bit on a match of even higher relevance won't 498 // setting the prefetch bit on a match of even higher relevance won't
491 // violate this assumption. 499 // violate this assumption.
492 should_prefetch |= ShouldPrefetch(i.first->second); 500 should_prefetch |= ShouldPrefetch(i.first->second);
493 i.first->second.RecordAdditionalInfo(kShouldPrefetchKey, 501 i.first->second.RecordAdditionalInfo(kShouldPrefetchKey,
494 should_prefetch ? kTrue : kFalse); 502 should_prefetch ? kTrue : kFalse);
495 if (should_prefetch) 503 if (should_prefetch)
496 i.first->second.RecordAdditionalInfo(kSuggestMetadataKey, metadata); 504 i.first->second.RecordAdditionalInfo(kSuggestMetadataKey, metadata);
497 } 505 }
498 } 506 }
499 } 507 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698