Commit 724ded4a authored by Kyle Milka's avatar Kyle Milka Committed by Commit Bot

[NTP] Delete local bg image copy when an update arrives from Sync

Incoming updates from Sync override the local image, so the copy should
be deleted.

Bug: 990099
Change-Id: Ia3d2aaecca8ae97d0f2a46a0d00fbb5374a7a4b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1731783
Commit-Queue: Gayane Petrosyan <gayane@chromium.org>
Reviewed-by: default avatarGayane Petrosyan <gayane@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683838}
parent 96a39fdf
...@@ -419,6 +419,7 @@ void InstantService::UpdateThemeInfo() { ...@@ -419,6 +419,7 @@ void InstantService::UpdateThemeInfo() {
void InstantService::UpdateBackgroundFromSync() { void InstantService::UpdateBackgroundFromSync() {
// Any incoming change to synced background data should clear the local image. // Any incoming change to synced background data should clear the local image.
pref_service_->SetBoolean(prefs::kNtpCustomBackgroundLocalToDevice, false); pref_service_->SetBoolean(prefs::kNtpCustomBackgroundLocalToDevice, false);
RemoveLocalBackgroundImageCopy();
UpdateThemeInfo(); UpdateThemeInfo();
} }
......
...@@ -454,7 +454,7 @@ TEST_F(InstantServiceTest, SetLocalImage) { ...@@ -454,7 +454,7 @@ TEST_F(InstantServiceTest, SetLocalImage) {
EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet());
} }
TEST_F(InstantServiceTest, SyncPrefOverridesLocalImage) { TEST_F(InstantServiceTest, SyncPrefOverridesAndRemovesLocalImage) {
ASSERT_FALSE(instant_service_->IsCustomBackgroundSet()); ASSERT_FALSE(instant_service_->IsCustomBackgroundSet());
const GURL kUrl("https://www.foo.com/"); const GURL kUrl("https://www.foo.com/");
...@@ -472,6 +472,7 @@ TEST_F(InstantServiceTest, SyncPrefOverridesLocalImage) { ...@@ -472,6 +472,7 @@ TEST_F(InstantServiceTest, SyncPrefOverridesLocalImage) {
EXPECT_TRUE( EXPECT_TRUE(
pref_service->GetBoolean(prefs::kNtpCustomBackgroundLocalToDevice)); pref_service->GetBoolean(prefs::kNtpCustomBackgroundLocalToDevice));
EXPECT_TRUE(base::PathExists(path));
// Update theme info via Sync. // Update theme info via Sync.
pref_service->SetUserPref( pref_service->SetUserPref(
...@@ -483,6 +484,7 @@ TEST_F(InstantServiceTest, SyncPrefOverridesLocalImage) { ...@@ -483,6 +484,7 @@ TEST_F(InstantServiceTest, SyncPrefOverridesLocalImage) {
EXPECT_EQ(kUrl, theme_info->custom_background_url); EXPECT_EQ(kUrl, theme_info->custom_background_url);
EXPECT_FALSE( EXPECT_FALSE(
pref_service->GetBoolean(prefs::kNtpCustomBackgroundLocalToDevice)); pref_service->GetBoolean(prefs::kNtpCustomBackgroundLocalToDevice));
EXPECT_FALSE(base::PathExists(path));
EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet());
} }
......
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