Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: components/ntp_snippets/offline_pages/offline_page_suggestions_provider.cc

Issue 2184683002: Show content suggestions from all categories on the NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/offline_pages/offline_page_suggestions_provide r.h" 5 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide r.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 9
10 using offline_pages::MultipleOfflinePageItemResult; 10 using offline_pages::MultipleOfflinePageItemResult;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 90 }
91 91
92 void OfflinePageSuggestionsProvider::OnOfflinePagesLoaded( 92 void OfflinePageSuggestionsProvider::OnOfflinePagesLoaded(
93 const MultipleOfflinePageItemResult& result) { 93 const MultipleOfflinePageItemResult& result) {
94 NotifyStatusChanged(ContentSuggestionsCategoryStatus::AVAILABLE); 94 NotifyStatusChanged(ContentSuggestionsCategoryStatus::AVAILABLE);
95 if (!observer_) 95 if (!observer_)
96 return; 96 return;
97 97
98 std::vector<ContentSuggestion> suggestions; 98 std::vector<ContentSuggestion> suggestions;
99 for (const OfflinePageItem& item : result) { 99 for (const OfflinePageItem& item : result) {
100 // TODO(pke): Make sure the URL is actually opened as an offline URL.
101 // Currently, the browser opens the offline URL and then immediately
102 // redirects to the online URL if the device is online.
100 ContentSuggestion suggestion( 103 ContentSuggestion suggestion(
101 MakeUniqueID(ContentSuggestionsCategory::OFFLINE_PAGES, 104 MakeUniqueID(ContentSuggestionsCategory::OFFLINE_PAGES,
102 base::IntToString(item.offline_id)), 105 base::IntToString(item.offline_id)),
103 item.GetOfflineURL()); 106 item.GetOfflineURL());
104 107
105 // TODO(pke): Sort my most recently visited and only keep the top one of 108 // TODO(pke): Sort my most recently visited and only keep the top one of
106 // multiple entries for the same URL. 109 // multiple entries for the same URL.
107 // TODO(pke): Get more reasonable data from the OfflinePageModel here. 110 // TODO(pke): Get more reasonable data from the OfflinePageModel here.
108 suggestion.set_title(item.url.spec()); 111 suggestion.set_title(item.url.spec());
109 suggestion.set_snippet_text(std::string()); 112 suggestion.set_snippet_text(std::string());
(...skipping 12 matching lines...) Expand all
122 return; 125 return;
123 category_status_ = new_status; 126 category_status_ = new_status;
124 127
125 if (!observer_) 128 if (!observer_)
126 return; 129 return;
127 observer_->OnCategoryStatusChanged(ContentSuggestionsCategory::OFFLINE_PAGES, 130 observer_->OnCategoryStatusChanged(ContentSuggestionsCategory::OFFLINE_PAGES,
128 new_status); 131 new_status);
129 } 132 }
130 133
131 } // namespace ntp_snippets 134 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698