1 // Copyright 2019 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 CHROME_BROWSER_UPDATES_UPDATE_NOTIFICATION_CONFIG_H_ 6 #define CHROME_BROWSER_UPDATES_UPDATE_NOTIFICATION_CONFIG_H_ 7 8 #include <memory> 9 #include <string> 10 #include <utility> 11 12 #include "base/macros.h" 13 #include "base/time/time.h" 14 15 namespace updates { 16 17 // Some of these are also existing in Java side, please refer: 18 // src/chrome/android/java/src/org/ 19 // chromium/chrome/browser/omaha/UpdateConfigs.java 20 21 // Configure the update notification enable/disable switch. 22 constexpr char kUpdateNotificationStateParamName[] = 23 "update_notification_state"; 24 25 // Configure the initial schedule interval update notification in days. 26 constexpr char kUpdateNotificationInitIntervalParamName[] = 27 "update_notification_init_interval_days"; 28 29 // Configure the maximum schedule interval update notification in days. 30 constexpr char kUpdateNotificationMaxIntervalParamName[] = 31 "update_notification_max_interval_days"; 32 33 // Configure the start of deliver window in the morning. 34 constexpr char kUpdateNotificationDeliverWindowMorningStartParamName[] = 35 "update_notification_deliver_window_morning_start"; 36 37 // Configure the end of deliver window in the morning. 38 constexpr char kUpdateNotificationDeliverWindowMorningEndParamName[] = 39 "update_notification_deliver_window_morning_end"; 40 41 // Configure the start of deliver window in the evening. 42 constexpr char kUpdateNotificationDeliverWindowEveningStartParamName[] = 43 "update_notification_deliver_window_evening_start"; 44 45 // Configure the end of deliver window in the evening. 46 constexpr char kUpdateNotificationDeliverWindowEveningEndParamName[] = 47 "update_notification_deliver_window_evening_end"; 48 49 struct UpdateNotificationConfig { 50 // Create a default update notification config. 51 static std::unique_ptr<UpdateNotificationConfig> Create(); 52 53 // Create an update notification config read from Finch. 54 static std::unique_ptr<UpdateNotificationConfig> CreateFromFinch(); 55 56 UpdateNotificationConfig(); 57 ~UpdateNotificationConfig(); 58 59 // Flag to tell whether update notification is enabled or not. 60 bool is_enabled; 61 62 // Default interval to schedule next update notification. 63 base::TimeDelta init_interval; 64 65 // Maximum interval to schedule next update notification. 66 base::TimeDelta max_interval; 67 68 // Deliver window pair [start, end] in the morning. 69 std::pair<base::TimeDelta, base::TimeDelta> deliver_window_morning; 70 71 // Deliver window pair [start, end] in the evening. 72 std::pair<base::TimeDelta, base::TimeDelta> deliver_window_evening; 73 }; 74 75 } // namespace updates 76 77 #endif // CHROME_BROWSER_UPDATES_UPDATE_NOTIFICATION_CONFIG_H_ 78