Chromium Code Reviews| 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/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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "components/ntp_snippets/pref_names.h" | 16 #include "components/ntp_snippets/pref_names.h" |
| 17 #include "components/offline_pages/client_namespace_constants.h" | 17 #include "components/offline_pages/client_namespace_constants.h" |
| 18 #include "components/offline_pages/client_policy_controller.h" | |
| 18 #include "components/prefs/pref_registry_simple.h" | 19 #include "components/prefs/pref_registry_simple.h" |
| 19 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
| 20 #include "grit/components_strings.h" | 21 #include "grit/components_strings.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
| 23 | 24 |
| 24 using offline_pages::MultipleOfflinePageItemResult; | 25 using offline_pages::MultipleOfflinePageItemResult; |
| 25 using offline_pages::OfflinePageModel; | 26 using offline_pages::OfflinePageModel; |
| 26 using offline_pages::OfflinePageItem; | 27 using offline_pages::OfflinePageItem; |
| 27 | 28 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 38 } | 39 } |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 bool IsRecentTab(const offline_pages::ClientId& client_id) { | 42 bool IsRecentTab(const offline_pages::ClientId& client_id) { |
| 42 return client_id.name_space == offline_pages::kLastNNamespace; | 43 return client_id.name_space == offline_pages::kLastNNamespace; |
| 43 } | 44 } |
| 44 | 45 |
| 45 bool IsDownload(const offline_pages::ClientId& client_id) { | 46 bool IsDownload(const offline_pages::ClientId& client_id) { |
| 46 // TODO(pke): Use kDownloadNamespace once the OfflinePageModel uses that. | 47 // TODO(pke): Use kDownloadNamespace once the OfflinePageModel uses that. |
| 47 // The current logic is taken from DownloadUIAdapter::IsVisibleInUI. | 48 // The current logic is taken from DownloadUIAdapter::IsVisibleInUI. |
| 48 return client_id.name_space == offline_pages::kAsyncNamespace && | 49 return offline_pages::ClientPolicyController().IsSupportedByDownload( |
|
fgorski
2016/09/19 22:18:54
Does the comment/todo still make sense here? Could
chili
2016/09/20 00:02:33
Done.
| |
| 50 client_id.name_space) && | |
| 49 base::IsValidGUID(client_id.id); | 51 base::IsValidGUID(client_id.id); |
| 50 } | 52 } |
| 51 | 53 |
| 52 } // namespace | 54 } // namespace |
| 53 | 55 |
| 54 OfflinePageSuggestionsProvider::OfflinePageSuggestionsProvider( | 56 OfflinePageSuggestionsProvider::OfflinePageSuggestionsProvider( |
| 55 bool recent_tabs_enabled, | 57 bool recent_tabs_enabled, |
| 56 bool downloads_enabled, | 58 bool downloads_enabled, |
| 57 bool download_manager_ui_enabled, | 59 bool download_manager_ui_enabled, |
| 58 ContentSuggestionsProvider::Observer* observer, | 60 ContentSuggestionsProvider::Observer* observer, |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 void OfflinePageSuggestionsProvider::StoreDismissedIDsToPrefs( | 387 void OfflinePageSuggestionsProvider::StoreDismissedIDsToPrefs( |
| 386 Category category, | 388 Category category, |
| 387 const std::set<std::string>& dismissed_ids) { | 389 const std::set<std::string>& dismissed_ids) { |
| 388 base::ListValue list; | 390 base::ListValue list; |
| 389 for (const std::string& dismissed_id : dismissed_ids) | 391 for (const std::string& dismissed_id : dismissed_ids) |
| 390 list.AppendString(dismissed_id); | 392 list.AppendString(dismissed_id); |
| 391 pref_service_->Set(GetDismissedPref(category), list); | 393 pref_service_->Set(GetDismissedPref(category), list); |
| 392 } | 394 } |
| 393 | 395 |
| 394 } // namespace ntp_snippets | 396 } // namespace ntp_snippets |
| OLD | NEW |