Commit 22ec8175 authored by Kyle Milka's avatar Kyle Milka Committed by Commit Bot

[NTP] Hide theme attribution when custom background is set

If a custom background is set clear the theme attribution url.

Bug: 908798
Change-Id: I2c612fa2fffaff04925a1f8d04d6b5962b0ccc4c
Reviewed-on: https://chromium-review.googlesource.com/c/1354007Reviewed-by: default avatarRamya Nagarajan <ramyan@chromium.org>
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611905}
parent e895e2e6
...@@ -486,4 +486,61 @@ IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsThemeTest, ...@@ -486,4 +486,61 @@ IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsThemeTest,
&result)); &result));
ASSERT_TRUE(result); ASSERT_TRUE(result);
} }
IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsThemeTest,
CustomBackgroundOverridesThemeAttribution) {
content::WebContents* active_tab =
local_ntp_test_utils::OpenNewTab(browser(), GURL("about:blank"));
TestThemeInfoObserver observer(
InstantServiceFactory::GetForProfile(profile()));
local_ntp_test_utils::NavigateToNTPAndWaitUntilLoaded(browser());
// Switch to waiting for the theme to get applied.
observer.SwitchCheck();
ASSERT_NO_FATAL_FAILURE(
InstallThemeAndVerify("theme_with_attribution", "attribution theme"));
observer.WaitForThemeApplied(true);
EXPECT_FALSE(observer.IsUsingDefaultTheme());
bool result = false;
ASSERT_TRUE(instant_test_utils::GetBoolFromJS(
active_tab,
"window.chrome.embeddedSearch.newTabPage.themeBackgroundInfo."
"attributionUrl !== ''",
&result));
EXPECT_TRUE(result);
// Set a custom background image via the EmbeddedSearch API.
observer.SwitchCheck();
InstantService* instant_service =
InstantServiceFactory::GetForProfile(profile());
instant_service->AddValidBackdropUrlForTesting(
GURL("chrome-search://local-ntp/background1.jpg"));
ASSERT_TRUE(content::ExecuteScript(
active_tab,
"window.chrome.embeddedSearch.newTabPage."
"setBackgroundURL('chrome-search://local-ntp/background1.jpg"
"')"));
observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg",
"", "", "");
// Check that the custom background element has the correct attribution with
// the scrim applied.
ASSERT_TRUE(instant_test_utils::GetBoolFromJS(
active_tab,
"$('custom-bg').style.backgroundImage === 'linear-gradient(rgba(0, 0, 0, "
"0), rgba(0, 0, 0, 0.3)), "
"url(\"chrome-search://local-ntp/background1.jpg\")'",
&result));
EXPECT_TRUE(result);
// Applying a custom background still counts as using the default theme.
EXPECT_FALSE(observer.IsUsingDefaultTheme());
ASSERT_TRUE(instant_test_utils::GetBoolFromJS(
active_tab,
"window.chrome.embeddedSearch.newTabPage.themeBackgroundInfo."
"attributionUrl === ''",
&result));
EXPECT_TRUE(result);
}
} // namespace } // namespace
...@@ -355,6 +355,9 @@ v8::Local<v8::Object> GenerateThemeBackgroundInfo( ...@@ -355,6 +355,9 @@ v8::Local<v8::Object> GenerateThemeBackgroundInfo(
theme_info.custom_background_attribution_line_1); theme_info.custom_background_attribution_line_1);
builder.Set("attribution2", builder.Set("attribution2",
theme_info.custom_background_attribution_line_2); theme_info.custom_background_attribution_line_2);
// Clear the theme attribution url, as it shouldn't be shown when
// a custom background is set.
builder.Set("attributionUrl", std::string());
} }
return builder.Build(); return builder.Build();
......
{
"name": "attribution theme",
"manifest_version": 2,
"theme": {
"colors": {
"frame": [ 158, 210, 242 ],
"ntp_link": [ 14, 107, 164 ],
"ntp_section": [ 213, 233, 245 ],
"toolbar": [ 187, 221, 247 ]
},
"images": {
"theme_frame": "images/theme_frame_snow.png",
"theme_ntp_background": "images/theme_ntp_background.png",
"theme_toolbar": "images/theme_toolbar_snow.png",
"theme_ntp_attribution": "images/theme_ntp_background.png"
},
"tints": {
"buttons": [ 0.6, 0.66, 0.6 ],
"frame_inactive": [ -1.0, -1.0, 0.6 ]
}
},
"version": "1.4"
}
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