OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_REQUEST_PARAMS_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_REQUEST_PARAMS_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <set> |
| 10 #include <string> |
| 11 |
| 12 #include "base/callback.h" |
| 13 #include "base/optional.h" |
| 14 #include "base/values.h" |
| 15 #include "components/ntp_snippets/category.h" |
| 16 |
| 17 namespace ntp_snippets { |
| 18 |
| 19 // Enumeration listing all possible variants of dealing with personalization. |
| 20 enum class Personalization { kPersonal, kNonPersonal, kBoth }; |
| 21 |
| 22 // Contains all parameters for fetching NTPSnippets. |
| 23 struct NTPSnippetsRequestParams { |
| 24 NTPSnippetsRequestParams(); |
| 25 NTPSnippetsRequestParams(const NTPSnippetsRequestParams&); |
| 26 ~NTPSnippetsRequestParams(); |
| 27 |
| 28 // BCP 47 language code specifying the user's UI language. |
| 29 std::string language_code; |
| 30 |
| 31 // A set of suggestion IDs that should not be returned again. |
| 32 std::set<std::string> excluded_ids; |
| 33 |
| 34 // Maximum number of snippets to fetch. |
| 35 int count_to_fetch = 0; |
| 36 |
| 37 // Whether this is an interactive request, i.e. triggered by an explicit |
| 38 // user action. Typically, non-interactive requests are subject to a daily |
| 39 // quota. |
| 40 bool interactive_request = false; |
| 41 |
| 42 // If set, only return results for this category. |
| 43 base::Optional<Category> exclusive_category; |
| 44 }; |
| 45 |
| 46 // Callbacks for JSON parsing to allow injecting platform-dependent code. |
| 47 using SuccessCallback = |
| 48 base::Callback<void(std::unique_ptr<base::Value> result)>; |
| 49 using ErrorCallback = base::Callback<void(const std::string& error)>; |
| 50 using ParseJSONCallback = |
| 51 base::Callback<void(const std::string& raw_json_string, |
| 52 const SuccessCallback& success_callback, |
| 53 const ErrorCallback& error_callback)>; |
| 54 |
| 55 } // namespace ntp_snippets |
| 56 |
| 57 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_REQUEST_PARAMS_H_ |
OLD | NEW |