Commit 0f55c487 authored by Hesen Zhang's avatar Hesen Zhang Committed by Commit Bot

[Update notification service]: add CreateFromFinch for config.

Bug: 1043237, 1013685
Change-Id: Ie089eef59d7fdd0ad0d5f4defff1abeac6a07aa6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008612
Commit-Queue: Hesen Zhang <hesen@chromium.org>
Auto-Submit: Hesen Zhang <hesen@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735153}
parent d266ae97
...@@ -53,8 +53,12 @@ constexpr double kDefaultThrottleIntervalOffset = 0.0; ...@@ -53,8 +53,12 @@ constexpr double kDefaultThrottleIntervalOffset = 0.0;
// Default update notification state. // Default update notification state.
constexpr bool kDefaultUpdateNotificationState = false; constexpr bool kDefaultUpdateNotificationState = false;
// TODO(hesen): Create a CreateFromFinch method (issue 1043237).
std::unique_ptr<UpdateNotificationConfig> UpdateNotificationConfig::Create() { std::unique_ptr<UpdateNotificationConfig> UpdateNotificationConfig::Create() {
return std::make_unique<UpdateNotificationConfig>();
}
std::unique_ptr<UpdateNotificationConfig>
UpdateNotificationConfig::CreateFromFinch() {
std::unique_ptr<UpdateNotificationConfig> config = std::unique_ptr<UpdateNotificationConfig> config =
std::make_unique<UpdateNotificationConfig>(); std::make_unique<UpdateNotificationConfig>();
......
...@@ -51,9 +51,12 @@ constexpr char kUpdateNotificationThrottleOffsetCoefficientParamName[] = ...@@ -51,9 +51,12 @@ constexpr char kUpdateNotificationThrottleOffsetCoefficientParamName[] =
"update_notification_throttle_co_offset"; "update_notification_throttle_co_offset";
struct UpdateNotificationConfig { struct UpdateNotificationConfig {
// Create a update notification config. // Create a default update notification config.
static std::unique_ptr<UpdateNotificationConfig> Create(); static std::unique_ptr<UpdateNotificationConfig> Create();
// Create an update notification config read from Finch.
static std::unique_ptr<UpdateNotificationConfig> CreateFromFinch();
UpdateNotificationConfig(); UpdateNotificationConfig();
~UpdateNotificationConfig(); ~UpdateNotificationConfig();
......
...@@ -37,7 +37,7 @@ TEST(UpdateNotificationConfigTest, FinchConfigTest) { ...@@ -37,7 +37,7 @@ TEST(UpdateNotificationConfigTest, FinchConfigTest) {
scoped_feature_list.InitAndEnableFeatureWithParameters( scoped_feature_list.InitAndEnableFeatureWithParameters(
chrome::android::kInlineUpdateFlow, parameters); chrome::android::kInlineUpdateFlow, parameters);
std::unique_ptr<UpdateNotificationConfig> config = std::unique_ptr<UpdateNotificationConfig> config =
UpdateNotificationConfig::Create(); UpdateNotificationConfig::CreateFromFinch();
EXPECT_TRUE(config->is_enabled); EXPECT_TRUE(config->is_enabled);
EXPECT_EQ(config->default_interval.InDays(), 7); EXPECT_EQ(config->default_interval.InDays(), 7);
EXPECT_EQ(config->deliver_window_morning.first.InHours(), 5); EXPECT_EQ(config->deliver_window_morning.first.InHours(), 5);
......
...@@ -41,7 +41,7 @@ KeyedService* UpdateNotificationServiceFactory::BuildServiceInstanceFor( ...@@ -41,7 +41,7 @@ KeyedService* UpdateNotificationServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const { content::BrowserContext* context) const {
auto* schedule_service = auto* schedule_service =
NotificationScheduleServiceFactory::GetForBrowserContext(context); NotificationScheduleServiceFactory::GetForBrowserContext(context);
auto config = updates::UpdateNotificationConfig::Create(); auto config = updates::UpdateNotificationConfig::CreateFromFinch();
auto bridge = auto bridge =
std::make_unique<updates::UpdateNotificationServiceBridgeAndroid>(); std::make_unique<updates::UpdateNotificationServiceBridgeAndroid>();
return static_cast<KeyedService*>(new updates::UpdateNotificationServiceImpl( return static_cast<KeyedService*>(new updates::UpdateNotificationServiceImpl(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment