| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "grit/components_strings.h" | 17 #include "grit/components_strings.h" |
| 18 #include "grit/components_strings.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
| 20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 21 | 22 |
| 22 using base::DictionaryValue; | 23 using base::DictionaryValue; |
| 23 using base::ListValue; | 24 using base::ListValue; |
| 24 using base::Value; | 25 using base::Value; |
| 25 | 26 |
| 26 namespace ntp_snippets { | 27 namespace ntp_snippets { |
| 27 | 28 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 50 physical_web_data_source_->UnregisterListener(this); | 51 physical_web_data_source_->UnregisterListener(this); |
| 51 } | 52 } |
| 52 | 53 |
| 53 CategoryStatus PhysicalWebPageSuggestionsProvider::GetCategoryStatus( | 54 CategoryStatus PhysicalWebPageSuggestionsProvider::GetCategoryStatus( |
| 54 Category category) { | 55 Category category) { |
| 55 return category_status_; | 56 return category_status_; |
| 56 } | 57 } |
| 57 | 58 |
| 58 CategoryInfo PhysicalWebPageSuggestionsProvider::GetCategoryInfo( | 59 CategoryInfo PhysicalWebPageSuggestionsProvider::GetCategoryInfo( |
| 59 Category category) { | 60 Category category) { |
| 60 // TODO(vitaliii): Use the proper string once it has been agreed on. | |
| 61 // TODO(vitaliii): Use a translateable string. (crbug.com/667764) | |
| 62 // TODO(vitaliii): Implement More action. (crbug.com/667759) | 61 // TODO(vitaliii): Implement More action. (crbug.com/667759) |
| 63 return CategoryInfo( | 62 return CategoryInfo(l10n_util::GetStringUTF16( |
| 64 base::ASCIIToUTF16("Physical web pages"), | 63 IDS_NTP_PHYSICAL_WEB_PAGE_SUGGESTIONS_SECTION_HEADER), |
| 65 ContentSuggestionsCardLayout::FULL_CARD, | 64 ContentSuggestionsCardLayout::FULL_CARD, |
| 66 /*has_more_action=*/false, | 65 /*has_more_action=*/false, |
| 67 /*has_reload_action=*/false, | 66 /*has_reload_action=*/false, |
| 68 /*has_view_all_action=*/false, | 67 /*has_view_all_action=*/false, |
| 69 /*show_if_empty=*/false, | 68 /*show_if_empty=*/false, |
| 70 l10n_util::GetStringUTF16(IDS_NTP_SUGGESTIONS_SECTION_EMPTY)); | 69 l10n_util::GetStringUTF16( |
| 70 IDS_NTP_PHYSICAL_WEB_PAGE_SUGGESTIONS_SECTION_EMPTY)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void PhysicalWebPageSuggestionsProvider::DismissSuggestion( | 73 void PhysicalWebPageSuggestionsProvider::DismissSuggestion( |
| 74 const ContentSuggestion::ID& suggestion_id) { | 74 const ContentSuggestion::ID& suggestion_id) { |
| 75 // TODO(vitaliii): Implement this and then | 75 // TODO(vitaliii): Implement this and then |
| 76 // ClearDismissedSuggestionsForDebugging. (crbug.com/667766) | 76 // ClearDismissedSuggestionsForDebugging. (crbug.com/667766) |
| 77 } | 77 } |
| 78 | 78 |
| 79 void PhysicalWebPageSuggestionsProvider::FetchSuggestionImage( | 79 void PhysicalWebPageSuggestionsProvider::FetchSuggestionImage( |
| 80 const ContentSuggestion::ID& suggestion_id, | 80 const ContentSuggestion::ID& suggestion_id, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 FetchPhysicalWebPages(); | 215 FetchPhysicalWebPages(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void PhysicalWebPageSuggestionsProvider::OnDistanceChanged( | 218 void PhysicalWebPageSuggestionsProvider::OnDistanceChanged( |
| 219 const std::string& url, | 219 const std::string& url, |
| 220 double distance_estimate) { | 220 double distance_estimate) { |
| 221 FetchPhysicalWebPages(); | 221 FetchPhysicalWebPages(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace ntp_snippets | 224 } // namespace ntp_snippets |
| OLD | NEW |