| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "grit/components_strings.h" |
| 13 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
| 13 | 15 |
| 14 namespace ntp_snippets { | 16 namespace ntp_snippets { |
| 15 | 17 |
| 16 namespace { | 18 namespace { |
| 17 | 19 |
| 18 const size_t kMaxSuggestionsCount = 10; | 20 const size_t kMaxSuggestionsCount = 10; |
| 19 | 21 |
| 20 } // namespace | 22 } // namespace |
| 21 | 23 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 std::move(suggestions)); | 61 std::move(suggestions)); |
| 60 } | 62 } |
| 61 | 63 |
| 62 CategoryStatus PhysicalWebPageSuggestionsProvider::GetCategoryStatus( | 64 CategoryStatus PhysicalWebPageSuggestionsProvider::GetCategoryStatus( |
| 63 Category category) { | 65 Category category) { |
| 64 return category_status_; | 66 return category_status_; |
| 65 } | 67 } |
| 66 | 68 |
| 67 CategoryInfo PhysicalWebPageSuggestionsProvider::GetCategoryInfo( | 69 CategoryInfo PhysicalWebPageSuggestionsProvider::GetCategoryInfo( |
| 68 Category category) { | 70 Category category) { |
| 69 // TODO(vitaliii): Use a proper string once it's been agreed on. | 71 // TODO(vitaliii): Use the proper strings once they've been agreed on. |
| 70 return CategoryInfo(base::ASCIIToUTF16("Physical web pages"), | 72 return CategoryInfo( |
| 71 ContentSuggestionsCardLayout::MINIMAL_CARD, | 73 base::ASCIIToUTF16("Physical web pages"), |
| 72 /* has_more_button */ true, | 74 ContentSuggestionsCardLayout::MINIMAL_CARD, |
| 73 /* show_if_empty */ false); | 75 /* has_more_button */ true, |
| 76 /* show_if_empty */ false, |
| 77 l10n_util::GetStringUTF16(IDS_NTP_SUGGESTIONS_SECTION_EMPTY)); |
| 74 } | 78 } |
| 75 | 79 |
| 76 void PhysicalWebPageSuggestionsProvider::DismissSuggestion( | 80 void PhysicalWebPageSuggestionsProvider::DismissSuggestion( |
| 77 const ContentSuggestion::ID& suggestion_id) { | 81 const ContentSuggestion::ID& suggestion_id) { |
| 78 // TODO(vitaliii): Implement this and then | 82 // TODO(vitaliii): Implement this and then |
| 79 // ClearDismissedSuggestionsForDebugging. | 83 // ClearDismissedSuggestionsForDebugging. |
| 80 } | 84 } |
| 81 | 85 |
| 82 void PhysicalWebPageSuggestionsProvider::FetchSuggestionImage( | 86 void PhysicalWebPageSuggestionsProvider::FetchSuggestionImage( |
| 83 const ContentSuggestion::ID& suggestion_id, | 87 const ContentSuggestion::ID& suggestion_id, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 120 |
| 117 // Updates the |category_status_| and notifies the |observer_|, if necessary. | 121 // Updates the |category_status_| and notifies the |observer_|, if necessary. |
| 118 void PhysicalWebPageSuggestionsProvider::NotifyStatusChanged( | 122 void PhysicalWebPageSuggestionsProvider::NotifyStatusChanged( |
| 119 CategoryStatus new_status) { | 123 CategoryStatus new_status) { |
| 120 if (category_status_ == new_status) return; | 124 if (category_status_ == new_status) return; |
| 121 category_status_ = new_status; | 125 category_status_ = new_status; |
| 122 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); | 126 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); |
| 123 } | 127 } |
| 124 | 128 |
| 125 } // namespace ntp_snippets | 129 } // namespace ntp_snippets |
| OLD | NEW |