| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/app_list/search/mixer.h" | 5 #include "ui/app_list/search/mixer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/command_line.h" |
| 13 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 15 #include "ui/app_list/app_list_switches.h" |
| 14 #include "ui/app_list/search_provider.h" | 16 #include "ui/app_list/search_provider.h" |
| 15 #include "ui/app_list/search_result.h" | 17 #include "ui/app_list/search_result.h" |
| 16 | 18 |
| 17 namespace app_list { | 19 namespace app_list { |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 // Maximum number of results to show. Ignored if the AppListMixer field trial is | 23 // Maximum number of results to show. Ignored if the AppListMixer field trial is |
| 22 // "Blended". | 24 // "Blended". |
| 23 const size_t kMaxResults = 6; | 25 const size_t kMaxResults = 6; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 36 target->set_title(source.title()); | 38 target->set_title(source.title()); |
| 37 target->set_title_tags(source.title_tags()); | 39 target->set_title_tags(source.title_tags()); |
| 38 target->set_details(source.details()); | 40 target->set_details(source.details()); |
| 39 target->set_details_tags(source.details_tags()); | 41 target->set_details_tags(source.details_tags()); |
| 40 } | 42 } |
| 41 | 43 |
| 42 // Returns true if the "AppListMixer" trial is set to "Blended". This is an | 44 // Returns true if the "AppListMixer" trial is set to "Blended". This is an |
| 43 // experiment on the new Mixer logic that allows results from different groups | 45 // experiment on the new Mixer logic that allows results from different groups |
| 44 // to be blended together, rather than stratified. | 46 // to be blended together, rather than stratified. |
| 45 bool IsBlendedMixerTrialEnabled() { | 47 bool IsBlendedMixerTrialEnabled() { |
| 48 // Note: It's important to query the field trial state first, to ensure that |
| 49 // UMA reports the correct group. |
| 46 const std::string group_name = | 50 const std::string group_name = |
| 47 base::FieldTrialList::FindFullName(kAppListMixerFieldTrialName); | 51 base::FieldTrialList::FindFullName(kAppListMixerFieldTrialName); |
| 52 |
| 53 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 54 switches::kDisableNewAppListMixer)) { |
| 55 return false; |
| 56 } |
| 57 |
| 58 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 59 switches::kEnableNewAppListMixer)) { |
| 60 return true; |
| 61 } |
| 62 |
| 48 return group_name == kAppListMixerFieldTrialEnabled; | 63 return group_name == kAppListMixerFieldTrialEnabled; |
| 49 } | 64 } |
| 50 | 65 |
| 51 } // namespace | 66 } // namespace |
| 52 | 67 |
| 53 Mixer::SortData::SortData() : result(NULL), score(0.0) { | 68 Mixer::SortData::SortData() : result(NULL), score(0.0) { |
| 54 } | 69 } |
| 55 | 70 |
| 56 Mixer::SortData::SortData(SearchResult* result, double score) | 71 Mixer::SortData::SortData(SearchResult* result, double score) |
| 57 : result(result), score(score) { | 72 : result(result), score(score) { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 results->swap(final); | 331 results->swap(final); |
| 317 } | 332 } |
| 318 | 333 |
| 319 void Mixer::FetchResults(bool is_voice_query, | 334 void Mixer::FetchResults(bool is_voice_query, |
| 320 const KnownResults& known_results) { | 335 const KnownResults& known_results) { |
| 321 for (auto* group : groups_) | 336 for (auto* group : groups_) |
| 322 group->FetchResults(is_voice_query, known_results); | 337 group->FetchResults(is_voice_query, known_results); |
| 323 } | 338 } |
| 324 | 339 |
| 325 } // namespace app_list | 340 } // namespace app_list |
| OLD | NEW |