OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ntp_snippets/content_suggestions_service_factory.h" | 5 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 #include "content/public/browser/browser_context.h" | 54 #include "content/public/browser/browser_context.h" |
55 #include "content/public/browser/browser_thread.h" | 55 #include "content/public/browser/browser_thread.h" |
56 #include "content/public/browser/storage_partition.h" | 56 #include "content/public/browser/storage_partition.h" |
57 #include "google_apis/google_api_keys.h" | 57 #include "google_apis/google_api_keys.h" |
58 #include "net/url_request/url_request_context_getter.h" | 58 #include "net/url_request/url_request_context_getter.h" |
59 | 59 |
60 #if defined(OS_ANDROID) | 60 #if defined(OS_ANDROID) |
61 #include "chrome/browser/android/chrome_feature_list.h" | 61 #include "chrome/browser/android/chrome_feature_list.h" |
62 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" | 62 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" |
63 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 63 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
64 #include "chrome/browser/android/offline_pages/offline_page_suggestions_observer .h" | |
64 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" | 65 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" |
65 #include "chrome/browser/download/download_history.h" | 66 #include "chrome/browser/download/download_history.h" |
66 #include "chrome/browser/download/download_service.h" | 67 #include "chrome/browser/download/download_service.h" |
67 #include "chrome/browser/download/download_service_factory.h" | 68 #include "chrome/browser/download/download_service_factory.h" |
68 #include "chrome/browser/ntp_snippets/download_suggestions_provider.h" | 69 #include "chrome/browser/ntp_snippets/download_suggestions_provider.h" |
69 #include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider. h" | 70 #include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider. h" |
70 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio ns_provider.h" | 71 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio ns_provider.h" |
71 #include "components/offline_pages/core/background/request_coordinator.h" | 72 #include "components/offline_pages/core/background/request_coordinator.h" |
72 #include "components/offline_pages/core/offline_page_feature.h" | 73 #include "components/offline_pages/core/offline_page_feature.h" |
73 #include "components/offline_pages/core/offline_page_model.h" | 74 #include "components/offline_pages/core/offline_page_model.h" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 bool show_offline_page_downloads = | 356 bool show_offline_page_downloads = |
356 !IsChromeHomeEnabled() && | 357 !IsChromeHomeEnabled() && |
357 base::FeatureList::IsEnabled( | 358 base::FeatureList::IsEnabled( |
358 features::kOfflinePageDownloadSuggestionsFeature); | 359 features::kOfflinePageDownloadSuggestionsFeature); |
359 if (show_asset_downloads || show_offline_page_downloads) { | 360 if (show_asset_downloads || show_offline_page_downloads) { |
360 RegisterDownloadsProvider( | 361 RegisterDownloadsProvider( |
361 show_offline_page_downloads ? offline_page_model : nullptr, | 362 show_offline_page_downloads ? offline_page_model : nullptr, |
362 show_asset_downloads ? download_manager : nullptr, download_history, | 363 show_asset_downloads ? download_manager : nullptr, download_history, |
363 service, pref_service); | 364 service, pref_service); |
364 } | 365 } |
366 | |
367 if (offline_pages::IsPrefetchingOfflinePagesEnabled()) { | |
368 offline_pages::OfflinePageSuggestionsObserver:: | |
369 ObserveContentSuggestionsService(profile, offline_page_model, service); | |
carlosk
2017/04/11 17:31:36
How about renaming the Observer* method to MaybeOb
dewittj
2017/04/11 21:25:48
Done, though I don't think the Maybe is strictly n
| |
370 } | |
371 | |
365 #endif // OS_ANDROID | 372 #endif // OS_ANDROID |
366 | 373 |
367 // |bookmark_model| can be null in tests. | 374 // |bookmark_model| can be null in tests. |
368 if (base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature) && | 375 if (base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature) && |
369 bookmark_model && !IsChromeHomeEnabled()) { | 376 bookmark_model && !IsChromeHomeEnabled()) { |
370 RegisterBookmarkProvider(bookmark_model, service, pref_service); | 377 RegisterBookmarkProvider(bookmark_model, service, pref_service); |
371 } | 378 } |
372 | 379 |
373 #if defined(OS_ANDROID) | 380 #if defined(OS_ANDROID) |
374 if (IsPhysicalWebPageProviderEnabled()) { | 381 if (IsPhysicalWebPageProviderEnabled()) { |
(...skipping 12 matching lines...) Expand all Loading... | |
387 ntp_snippets::kForeignSessionsSuggestionsFeature)) { | 394 ntp_snippets::kForeignSessionsSuggestionsFeature)) { |
388 RegisterForeignSessionsProvider(sync_service, service, pref_service); | 395 RegisterForeignSessionsProvider(sync_service, service, pref_service); |
389 } | 396 } |
390 | 397 |
391 return service; | 398 return service; |
392 | 399 |
393 #else | 400 #else |
394 return nullptr; | 401 return nullptr; |
395 #endif // CONTENT_SUGGESTIONS_ENABLED | 402 #endif // CONTENT_SUGGESTIONS_ENABLED |
396 } | 403 } |
OLD | NEW |