| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/feature_list.h" | 11 #include "base/feature_list.h" |
| 11 #include "base/guid.h" | 12 #include "base/guid.h" |
| 12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 const ContentSuggestion::ID& suggestion_id, | 156 const ContentSuggestion::ID& suggestion_id, |
| 156 const ImageFetchedCallback& callback) { | 157 const ImageFetchedCallback& callback) { |
| 157 // TODO(vitaliii): Fetch proper thumbnail from OfflinePageModel once it is | 158 // TODO(vitaliii): Fetch proper thumbnail from OfflinePageModel once it is |
| 158 // available there. | 159 // available there. |
| 159 // TODO(vitaliii): Provide site's favicon for assets downloads. See | 160 // TODO(vitaliii): Provide site's favicon for assets downloads. See |
| 160 // crbug.com/631447. | 161 // crbug.com/631447. |
| 161 base::ThreadTaskRunnerHandle::Get()->PostTask( | 162 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 162 FROM_HERE, base::Bind(callback, gfx::Image())); | 163 FROM_HERE, base::Bind(callback, gfx::Image())); |
| 163 } | 164 } |
| 164 | 165 |
| 166 void DownloadSuggestionsProvider::Fetch( |
| 167 const ntp_snippets::Category& category, |
| 168 const std::set<std::string>& known_suggestion_ids, |
| 169 FetchingCallback callback) { |
| 170 NOTREACHED(); |
| 171 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 172 FROM_HERE, |
| 173 base::Bind(callback, base::Passed(std::vector<ContentSuggestion>()))); |
| 174 } |
| 175 |
| 165 void DownloadSuggestionsProvider::ClearHistory( | 176 void DownloadSuggestionsProvider::ClearHistory( |
| 166 base::Time begin, | 177 base::Time begin, |
| 167 base::Time end, | 178 base::Time end, |
| 168 const base::Callback<bool(const GURL& url)>& filter) { | 179 const base::Callback<bool(const GURL& url)>& filter) { |
| 169 cached_offline_page_downloads_.clear(); | 180 cached_offline_page_downloads_.clear(); |
| 170 cached_asset_downloads_.clear(); | 181 cached_asset_downloads_.clear(); |
| 171 // This will trigger an asynchronous re-fetch. | 182 // This will trigger an asynchronous re-fetch. |
| 172 ClearDismissedSuggestionsForDebugging(provided_category_); | 183 ClearDismissedSuggestionsForDebugging(provided_category_); |
| 173 } | 184 } |
| 174 | 185 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 631 |
| 621 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { | 632 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { |
| 622 DCHECK_NE(download_manager_, nullptr); | 633 DCHECK_NE(download_manager_, nullptr); |
| 623 | 634 |
| 624 std::vector<DownloadItem*> all_downloads; | 635 std::vector<DownloadItem*> all_downloads; |
| 625 download_manager_->GetAllDownloads(&all_downloads); | 636 download_manager_->GetAllDownloads(&all_downloads); |
| 626 | 637 |
| 627 for (DownloadItem* item : all_downloads) | 638 for (DownloadItem* item : all_downloads) |
| 628 item->RemoveObserver(this); | 639 item->RemoveObserver(this); |
| 629 } | 640 } |
| OLD | NEW |