| 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/physical_web_pages/physical_web_page_suggestio
ns_provider.h" | 5 #include "components/ntp_snippets/physical_web_pages/physical_web_page_suggestio
ns_provider.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "grit/components_strings.h" | 14 #include "grit/components_strings.h" |
| 15 #include "grit/components_strings.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
| 17 | 18 |
| 18 namespace ntp_snippets { | 19 namespace ntp_snippets { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 const size_t kMaxSuggestionsCount = 10; | 23 const size_t kMaxSuggestionsCount = 10; |
| 23 | 24 |
| 24 } // namespace | 25 } // namespace |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 67 } |
| 67 | 68 |
| 68 CategoryStatus PhysicalWebPageSuggestionsProvider::GetCategoryStatus( | 69 CategoryStatus PhysicalWebPageSuggestionsProvider::GetCategoryStatus( |
| 69 Category category) { | 70 Category category) { |
| 70 return category_status_; | 71 return category_status_; |
| 71 } | 72 } |
| 72 | 73 |
| 73 CategoryInfo PhysicalWebPageSuggestionsProvider::GetCategoryInfo( | 74 CategoryInfo PhysicalWebPageSuggestionsProvider::GetCategoryInfo( |
| 74 Category category) { | 75 Category category) { |
| 75 // TODO(vitaliii): Use the proper strings once they've been agreed on. | 76 // TODO(vitaliii): Use the proper strings once they've been agreed on. |
| 76 return CategoryInfo( | 77 return CategoryInfo(l10n_util::GetStringUTF16( |
| 77 base::ASCIIToUTF16("Physical web pages"), | 78 IDS_NTP_PHYSICAL_WEB_PAGE_SUGGESTIONS_SECTION_HEADER), |
| 78 ContentSuggestionsCardLayout::MINIMAL_CARD, | 79 ContentSuggestionsCardLayout::MINIMAL_CARD, |
| 79 /*has_more_action=*/false, | 80 /*has_more_action=*/false, |
| 80 /*has_reload_action=*/false, | 81 /*has_reload_action=*/false, |
| 81 /*has_view_all_action=*/false, | 82 /*has_view_all_action=*/false, |
| 82 /*show_if_empty=*/false, | 83 /*show_if_empty=*/false, |
| 83 l10n_util::GetStringUTF16(IDS_NTP_SUGGESTIONS_SECTION_EMPTY)); | 84 l10n_util::GetStringUTF16( |
| 85 IDS_NTP_PHYSICAL_WEB_PAGE_SUGGESTIONS_SECTION_EMPTY)); |
| 84 } | 86 } |
| 85 | 87 |
| 86 void PhysicalWebPageSuggestionsProvider::DismissSuggestion( | 88 void PhysicalWebPageSuggestionsProvider::DismissSuggestion( |
| 87 const ContentSuggestion::ID& suggestion_id) { | 89 const ContentSuggestion::ID& suggestion_id) { |
| 88 // TODO(vitaliii): Implement this and then | 90 // TODO(vitaliii): Implement this and then |
| 89 // ClearDismissedSuggestionsForDebugging. | 91 // ClearDismissedSuggestionsForDebugging. |
| 90 } | 92 } |
| 91 | 93 |
| 92 void PhysicalWebPageSuggestionsProvider::FetchSuggestionImage( | 94 void PhysicalWebPageSuggestionsProvider::FetchSuggestionImage( |
| 93 const ContentSuggestion::ID& suggestion_id, | 95 const ContentSuggestion::ID& suggestion_id, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 void PhysicalWebPageSuggestionsProvider::NotifyStatusChanged( | 144 void PhysicalWebPageSuggestionsProvider::NotifyStatusChanged( |
| 143 CategoryStatus new_status) { | 145 CategoryStatus new_status) { |
| 144 if (category_status_ == new_status) { | 146 if (category_status_ == new_status) { |
| 145 return; | 147 return; |
| 146 } | 148 } |
| 147 category_status_ = new_status; | 149 category_status_ = new_status; |
| 148 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); | 150 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); |
| 149 } | 151 } |
| 150 | 152 |
| 151 } // namespace ntp_snippets | 153 } // namespace ntp_snippets |
| OLD | NEW |