| 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/download_suggestions_provider.h" | 5 #include "chrome/browser/ntp_snippets/download_suggestions_provider.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 DownloadSuggestionsProvider* CreateProvider(bool show_assets, | 278 DownloadSuggestionsProvider* CreateProvider(bool show_assets, |
| 279 bool show_offline_pages) { | 279 bool show_offline_pages) { |
| 280 DCHECK(!provider_); | 280 DCHECK(!provider_); |
| 281 DCHECK(show_assets || show_offline_pages); | 281 DCHECK(show_assets || show_offline_pages); |
| 282 | 282 |
| 283 // TODO(crbug.com/681766): Extract DownloadHistory interface and move | 283 // TODO(crbug.com/681766): Extract DownloadHistory interface and move |
| 284 // implementation into DownloadHistoryImpl. Then mock it. | 284 // implementation into DownloadHistoryImpl. Then mock it. |
| 285 provider_ = base::MakeUnique<DownloadSuggestionsProvider>( | 285 provider_ = base::MakeUnique<DownloadSuggestionsProvider>( |
| 286 &observer_, show_offline_pages ? &offline_pages_model_ : nullptr, | 286 &observer_, show_offline_pages ? &offline_pages_model_ : nullptr, |
| 287 show_assets ? &downloads_manager_ : nullptr, &download_history_, | 287 show_assets ? &downloads_manager_ : nullptr, &download_history_, |
| 288 pref_service(), | 288 pref_service()); |
| 289 /*download_manager_ui_enabled=*/false); | |
| 290 return provider_.get(); | 289 return provider_.get(); |
| 291 } | 290 } |
| 292 | 291 |
| 293 void DestroyProvider() { provider_.reset(); } | 292 void DestroyProvider() { provider_.reset(); } |
| 294 | 293 |
| 295 Category downloads_category() { | 294 Category downloads_category() { |
| 296 return Category::FromKnownCategory( | 295 return Category::FromKnownCategory( |
| 297 ntp_snippets::KnownCategories::DOWNLOADS); | 296 ntp_snippets::KnownCategories::DOWNLOADS); |
| 298 } | 297 } |
| 299 | 298 |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 | 1008 |
| 1010 EXPECT_CALL(*observer(), OnNewSuggestions(_, _, _)); | 1009 EXPECT_CALL(*observer(), OnNewSuggestions(_, _, _)); |
| 1011 | 1010 |
| 1012 downloads_manager()->mutable_items()->clear(); | 1011 downloads_manager()->mutable_items()->clear(); |
| 1013 FireHistoryQueryComplete(); | 1012 FireHistoryQueryComplete(); |
| 1014 | 1013 |
| 1015 *(downloads_manager()->mutable_items()) = CreateDummyAssetDownloads({1}); | 1014 *(downloads_manager()->mutable_items()) = CreateDummyAssetDownloads({1}); |
| 1016 // Once the manager has been loaded, the ids should be pruned. | 1015 // Once the manager has been loaded, the ids should be pruned. |
| 1017 EXPECT_THAT(GetDismissedSuggestions(), IsEmpty()); | 1016 EXPECT_THAT(GetDismissedSuggestions(), IsEmpty()); |
| 1018 } | 1017 } |
| OLD | NEW |