| 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 "components/ntp_snippets/content_suggestions_service.h" | 5 #include "components/ntp_snippets/content_suggestions_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 !result.fallback_icon_style->is_default_background_color)) { | 238 !result.fallback_icon_style->is_default_background_color)) { |
| 239 // We cannot download from the server if there is some small icon in the | 239 // We cannot download from the server if there is some small icon in the |
| 240 // cache (resulting in non-default background color) or if we already did | 240 // cache (resulting in non-default background color) or if we already did |
| 241 // so. | 241 // so. |
| 242 callback.Run(gfx::Image()); | 242 callback.Run(gfx::Image()); |
| 243 RecordFaviconFetchResult(FaviconFetchResult::FAILURE); | 243 RecordFaviconFetchResult(FaviconFetchResult::FAILURE); |
| 244 return; | 244 return; |
| 245 } | 245 } |
| 246 | 246 |
| 247 // Try to fetch the favicon from a Google favicon server. | 247 // Try to fetch the favicon from a Google favicon server. |
| 248 // TODO(jkrcal): Currently used only for Articles for you which have public |
| 249 // URLs. Let the provider decide whether |publisher_url| may be private or |
| 250 // not. |
| 248 large_icon_service_ | 251 large_icon_service_ |
| 249 ->GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( | 252 ->GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( |
| 250 publisher_url, minimum_size_in_pixel, desired_size_in_pixel, | 253 publisher_url, minimum_size_in_pixel, desired_size_in_pixel, |
| 254 /*may_page_url_be_private=*/false, |
| 251 base::Bind( | 255 base::Bind( |
| 252 &ContentSuggestionsService::OnGetFaviconFromGoogleServerFinished, | 256 &ContentSuggestionsService::OnGetFaviconFromGoogleServerFinished, |
| 253 base::Unretained(this), publisher_url, minimum_size_in_pixel, | 257 base::Unretained(this), publisher_url, minimum_size_in_pixel, |
| 254 desired_size_in_pixel, callback)); | 258 desired_size_in_pixel, callback)); |
| 255 } | 259 } |
| 256 | 260 |
| 257 void ContentSuggestionsService::OnGetFaviconFromGoogleServerFinished( | 261 void ContentSuggestionsService::OnGetFaviconFromGoogleServerFinished( |
| 258 const GURL& publisher_url, | 262 const GURL& publisher_url, |
| 259 int minimum_size_in_pixel, | 263 int minimum_size_in_pixel, |
| 260 int desired_size_in_pixel, | 264 int desired_size_in_pixel, |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { | 683 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { |
| 680 base::ListValue list; | 684 base::ListValue list; |
| 681 for (const auto& category_provider_pair : dismissed_providers_by_category_) { | 685 for (const auto& category_provider_pair : dismissed_providers_by_category_) { |
| 682 list.AppendInteger(category_provider_pair.first.id()); | 686 list.AppendInteger(category_provider_pair.first.id()); |
| 683 } | 687 } |
| 684 | 688 |
| 685 pref_service_->Set(prefs::kDismissedCategories, list); | 689 pref_service_->Set(prefs::kDismissedCategories, list); |
| 686 } | 690 } |
| 687 | 691 |
| 688 } // namespace ntp_snippets | 692 } // namespace ntp_snippets |
| OLD | NEW |