| 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 "chrome/browser/ui/app_list/search/app_search_provider.h" | 5 #include "chrome/browser/ui/app_list/search/app_search_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/ui/app_list/search/extension_app_result.h" | 24 #include "chrome/browser/ui/app_list/search/extension_app_result.h" |
| 25 #include "extensions/browser/extension_prefs.h" | 25 #include "extensions/browser/extension_prefs.h" |
| 26 #include "extensions/browser/extension_registry.h" | 26 #include "extensions/browser/extension_registry.h" |
| 27 #include "extensions/browser/extension_system.h" | 27 #include "extensions/browser/extension_system.h" |
| 28 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
| 29 #include "extensions/common/extension_set.h" | 29 #include "extensions/common/extension_set.h" |
| 30 #include "ui/app_list/app_list_item.h" | 30 #include "ui/app_list/app_list_item.h" |
| 31 #include "ui/app_list/app_list_model.h" | 31 #include "ui/app_list/app_list_model.h" |
| 32 #include "ui/app_list/search/tokenized_string.h" | 32 #include "ui/app_list/search/tokenized_string.h" |
| 33 #include "ui/app_list/search/tokenized_string_match.h" | 33 #include "ui/app_list/search/tokenized_string_match.h" |
| 34 | |
| 35 #if defined(OS_CHROMEOS) | |
| 36 #include "chrome/browser/chromeos/arc/arc_util.h" | 34 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 37 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 35 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 38 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 36 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 39 #include "chrome/browser/ui/app_list/search/arc_app_result.h" | 37 #include "chrome/browser/ui/app_list/search/arc_app_result.h" |
| 40 #endif | |
| 41 | 38 |
| 42 using extensions::ExtensionRegistry; | 39 using extensions::ExtensionRegistry; |
| 43 | 40 |
| 44 namespace { | 41 namespace { |
| 45 | 42 |
| 46 // The size of each step unlaunched apps should increase their relevance by. | 43 // The size of each step unlaunched apps should increase their relevance by. |
| 47 constexpr double kUnlaunchedAppRelevanceStepSize = 0.0001; | 44 constexpr double kUnlaunchedAppRelevanceStepSize = 0.0001; |
| 48 | 45 |
| 49 // The minimum capacity we reserve in the Apps container which will be filled | 46 // The minimum capacity we reserve in the Apps container which will be filled |
| 50 // with extensions and ARC apps, to avoid successive reallocation. | 47 // with extensions and ARC apps, to avoid successive reallocation. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 183 } |
| 187 } | 184 } |
| 188 | 185 |
| 189 ScopedObserver<extensions::ExtensionRegistry, | 186 ScopedObserver<extensions::ExtensionRegistry, |
| 190 extensions::ExtensionRegistryObserver> | 187 extensions::ExtensionRegistryObserver> |
| 191 extension_registry_observer_; | 188 extension_registry_observer_; |
| 192 | 189 |
| 193 DISALLOW_COPY_AND_ASSIGN(ExtensionDataSource); | 190 DISALLOW_COPY_AND_ASSIGN(ExtensionDataSource); |
| 194 }; | 191 }; |
| 195 | 192 |
| 196 #if defined(OS_CHROMEOS) | |
| 197 class ArcDataSource : public AppSearchProvider::DataSource, | 193 class ArcDataSource : public AppSearchProvider::DataSource, |
| 198 public ArcAppListPrefs::Observer { | 194 public ArcAppListPrefs::Observer { |
| 199 public: | 195 public: |
| 200 ArcDataSource(Profile* profile, AppSearchProvider* owner) | 196 ArcDataSource(Profile* profile, AppSearchProvider* owner) |
| 201 : AppSearchProvider::DataSource(profile, owner) { | 197 : AppSearchProvider::DataSource(profile, owner) { |
| 202 ArcAppListPrefs::Get(profile)->AddObserver(this); | 198 ArcAppListPrefs::Get(profile)->AddObserver(this); |
| 203 } | 199 } |
| 204 | 200 |
| 205 ~ArcDataSource() override { | 201 ~ArcDataSource() override { |
| 206 ArcAppListPrefs::Get(profile())->RemoveObserver(this); | 202 ArcAppListPrefs::Get(profile())->RemoveObserver(this); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 245 } |
| 250 | 246 |
| 251 void OnAppNameUpdated(const std::string& id, | 247 void OnAppNameUpdated(const std::string& id, |
| 252 const std::string& name) override { | 248 const std::string& name) override { |
| 253 owner()->RefreshAppsAndUpdateResults(false); | 249 owner()->RefreshAppsAndUpdateResults(false); |
| 254 } | 250 } |
| 255 | 251 |
| 256 private: | 252 private: |
| 257 DISALLOW_COPY_AND_ASSIGN(ArcDataSource); | 253 DISALLOW_COPY_AND_ASSIGN(ArcDataSource); |
| 258 }; | 254 }; |
| 259 #endif | |
| 260 | 255 |
| 261 } // namespace | 256 } // namespace |
| 262 | 257 |
| 263 AppSearchProvider::AppSearchProvider(Profile* profile, | 258 AppSearchProvider::AppSearchProvider(Profile* profile, |
| 264 AppListControllerDelegate* list_controller, | 259 AppListControllerDelegate* list_controller, |
| 265 std::unique_ptr<base::Clock> clock, | 260 std::unique_ptr<base::Clock> clock, |
| 266 AppListItemList* top_level_item_list) | 261 AppListItemList* top_level_item_list) |
| 267 : list_controller_(list_controller), | 262 : list_controller_(list_controller), |
| 268 top_level_item_list_(top_level_item_list), | 263 top_level_item_list_(top_level_item_list), |
| 269 clock_(std::move(clock)), | 264 clock_(std::move(clock)), |
| 270 update_results_factory_(this) { | 265 update_results_factory_(this) { |
| 271 data_sources_.emplace_back( | 266 data_sources_.emplace_back( |
| 272 base::MakeUnique<ExtensionDataSource>(profile, this)); | 267 base::MakeUnique<ExtensionDataSource>(profile, this)); |
| 273 #if defined(OS_CHROMEOS) | |
| 274 if (arc::IsArcAllowedForProfile(profile)) | 268 if (arc::IsArcAllowedForProfile(profile)) |
| 275 data_sources_.emplace_back(base::MakeUnique<ArcDataSource>(profile, this)); | 269 data_sources_.emplace_back(base::MakeUnique<ArcDataSource>(profile, this)); |
| 276 #endif | |
| 277 } | 270 } |
| 278 | 271 |
| 279 AppSearchProvider::~AppSearchProvider() {} | 272 AppSearchProvider::~AppSearchProvider() {} |
| 280 | 273 |
| 281 void AppSearchProvider::Start(bool /*is_voice_query*/, | 274 void AppSearchProvider::Start(bool /*is_voice_query*/, |
| 282 const base::string16& query) { | 275 const base::string16& query) { |
| 283 query_ = query; | 276 query_ = query; |
| 284 const bool show_recommendations = query.empty(); | 277 const bool show_recommendations = query.empty(); |
| 285 // Refresh list of apps to ensure we have the latest launch time information. | 278 // Refresh list of apps to ensure we have the latest launch time information. |
| 286 // This will also cause the results to update. | 279 // This will also cause the results to update. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } else { | 361 } else { |
| 369 if (!update_results_factory_.HasWeakPtrs()) { | 362 if (!update_results_factory_.HasWeakPtrs()) { |
| 370 base::ThreadTaskRunnerHandle::Get()->PostTask( | 363 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 371 FROM_HERE, base::Bind(&AppSearchProvider::UpdateResults, | 364 FROM_HERE, base::Bind(&AppSearchProvider::UpdateResults, |
| 372 update_results_factory_.GetWeakPtr())); | 365 update_results_factory_.GetWeakPtr())); |
| 373 } | 366 } |
| 374 } | 367 } |
| 375 } | 368 } |
| 376 | 369 |
| 377 } // namespace app_list | 370 } // namespace app_list |
| OLD | NEW |