Chromium Code Reviews| 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, needed because the parsing is platform- | |
|
tschumann
2016/12/20 10:22:26
nit: Callbacks for JSON parsing to allow injecting
fhorschig
2016/12/20 10:30:32
Done.
| |
| 47 // dependent. | |
| 48 using SuccessCallback = | |
| 49 base::Callback<void(std::unique_ptr<base::Value> result)>; | |
| 50 using ErrorCallback = base::Callback<void(const std::string& error)>; | |
| 51 using ParseJSONCallback = | |
| 52 base::Callback<void(const std::string& raw_json_string, | |
| 53 const SuccessCallback& success_callback, | |
| 54 const ErrorCallback& error_callback)>; | |
| 55 | |
| 56 } // namespace ntp_snippets | |
| 57 | |
| 58 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_REQUEST_PARAMS_H_ | |
| OLD | NEW |