Commit 7d43ddcf authored by Kyle Milka's avatar Kyle Milka Committed by Commit Bot

[NTP] Rename SetCustomBackgroundURL(url) to ResetCustomBackgroundInfo

This method was only used for reseting the background.

Bug: None.
Change-Id: I64b35e1832cf739324230d1b4e5460a18d83d0bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1719831
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Reviewed-by: default avatarGayane Petrosyan <gayane@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685238}
parent 0e336676
......@@ -1751,7 +1751,7 @@ customize.initCustomBackgrounds = function(showErrorNotification) {
const restoreDefaultInteraction = function() {
editDialog.close();
customize.clearAttribution();
window.chrome.embeddedSearch.newTabPage.setBackgroundURL('');
window.chrome.embeddedSearch.newTabPage.resetBackgroundInfo();
};
$(customize.IDS.RESTORE_DEFAULT).onclick = (event) => {
if (!$(customize.IDS.RESTORE_DEFAULT)
......
......@@ -290,9 +290,9 @@ window.chrome.embeddedSearch.newTabPage.searchSuggestionSelected;
window.chrome.embeddedSearch.newTabPage.selectLocalBackgroundImage;
/**
* @param {string} background_url
* No params.
*/
window.chrome.embeddedSearch.newTabPage.setBackgroundURL;
window.chrome.embeddedSearch.newTabPage.resetBackgroundInfo;
/**
* @param {string} background_url
......
......@@ -435,8 +435,8 @@ void InstantService::SendNewTabPageURLToRenderer(
}
}
void InstantService::SetCustomBackgroundURL(const GURL& url) {
SetCustomBackgroundInfo(url, std::string(), std::string(), GURL(),
void InstantService::ResetCustomBackgroundInfo() {
SetCustomBackgroundInfo(GURL(), std::string(), std::string(), GURL(),
std::string());
}
......
......@@ -135,8 +135,8 @@ class InstantService : public KeyedService,
// Sends the current NTP URL to a renderer process.
void SendNewTabPageURLToRenderer(content::RenderProcessHost* rph);
// Invoked when a custom background is selected on the NTP.
void SetCustomBackgroundURL(const GURL& url);
// Invoked when the background is reset on the NTP.
void ResetCustomBackgroundInfo();
// Invoked when a custom background is configured on the NTP.
void SetCustomBackgroundInfo(const GURL& background_url,
......
......@@ -57,10 +57,11 @@ IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsTest,
TestInstantService test_instant_service(browser()->profile());
test_instant_service.get_instant_service()->AddValidBackdropUrlForTesting(
GURL("https://www.test.com/"));
EXPECT_TRUE(content::ExecuteScript(active_tab,
"window.chrome.embeddedSearch.newTabPage."
"setBackgroundURL('https://www.test.com/"
"')"));
EXPECT_TRUE(content::ExecuteScript(
active_tab,
"window.chrome.embeddedSearch.newTabPage."
"setBackgroundInfo('https://www.test.com/', '', '', '', '')"));
observer.WaitForThemeInfoUpdated("https://www.test.com/", "", "", "");
// Check that a URL with attributions can be set.
......@@ -75,7 +76,7 @@ IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsTest,
// Setting the background URL to an empty string should clear everything.
EXPECT_TRUE(content::ExecuteScript(
active_tab,
"window.chrome.embeddedSearch.newTabPage.setBackgroundURL('')"));
"window.chrome.embeddedSearch.newTabPage.resetBackgroundInfo()"));
observer.WaitForThemeInfoUpdated("", "", "", "");
}
......@@ -113,7 +114,7 @@ IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsTest, AttributionSetAndReset) {
// Reset custom background via the EmbeddedSearch API.
EXPECT_TRUE(content::ExecuteScript(active_tab,
"window.chrome.embeddedSearch.newTabPage."
"setBackgroundURL('')"));
"resetBackgroundInfo()"));
observer.WaitForThemeInfoUpdated("", "", "", "");
// Check that the custom background attribution was cleared.
......@@ -139,8 +140,8 @@ IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsTest,
EXPECT_TRUE(content::ExecuteScript(
active_tab,
"window.chrome.embeddedSearch.newTabPage."
"setBackgroundURL('chrome-search://local-ntp/background1.jpg"
"')"));
"setBackgroundInfo('chrome-search://local-ntp/background1.jpg"
"', '', '' ,'' ,'')"));
observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg",
"", "", "");
......@@ -158,7 +159,7 @@ IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsTest,
// Clear the custom background image via the EmbeddedSearch API.
EXPECT_TRUE(content::ExecuteScript(active_tab,
"window.chrome.embeddedSearch.newTabPage."
"setBackgroundURL('')"));
"resetBackgroundInfo()"));
observer.WaitForThemeInfoUpdated("", "", "", "");
// Check that the custom background was cleared.
......@@ -184,8 +185,8 @@ IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsTest,
ASSERT_TRUE(content::ExecuteScript(
active_tab,
"window.chrome.embeddedSearch.newTabPage."
"setBackgroundURL('chrome-search://local-ntp/background1.jpg"
"')"));
"setBackgroundInfo('chrome-search://local-ntp/background1.jpg"
"', '', '', '', '')"));
observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg",
"", "", "");
......@@ -344,8 +345,8 @@ IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsThemeTest,
ASSERT_TRUE(content::ExecuteScript(
active_tab,
"window.chrome.embeddedSearch.newTabPage."
"setBackgroundURL('chrome-search://local-ntp/background1.jpg"
"')"));
"setBackgroundInfo('chrome-search://local-ntp/background1.jpg"
"', '', '', '', '')"));
observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg",
"", "", "");
......@@ -408,8 +409,8 @@ IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsThemeTest,
ASSERT_TRUE(content::ExecuteScript(
active_tab,
"window.chrome.embeddedSearch.newTabPage."
"setBackgroundURL('chrome-search://local-ntp/background1.jpg"
"')"));
"setBackgroundInfo('chrome-search://local-ntp/background1.jpg"
"', '', '', '', '')"));
observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg",
"", "", "");
......@@ -478,8 +479,8 @@ IN_PROC_BROWSER_TEST_F(LocalNTPBackgroundsAndDarkModeTest,
ASSERT_TRUE(content::ExecuteScript(
active_tab,
"window.chrome.embeddedSearch.newTabPage."
"setBackgroundURL('chrome-search://local-ntp/background1.jpg"
"')"));
"setBackgroundInfo('chrome-search://local-ntp/background1.jpg"
"', '', '', '', '')"));
observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg",
"", "", "");
......@@ -538,8 +539,8 @@ IN_PROC_BROWSER_TEST_F(LocalNTPBackgroundsAndDarkModeTest,
ASSERT_TRUE(content::ExecuteScript(
active_tab,
"window.chrome.embeddedSearch.newTabPage."
"setBackgroundURL('chrome-search://local-ntp/background1.jpg"
"')"));
"setBackgroundInfo('chrome-search://local-ntp/background1.jpg',"
"'', '', '', '')"));
observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg",
"", "", "");
......
......@@ -54,7 +54,7 @@ void NtpBackgroundHandler::RegisterMessages() {
void NtpBackgroundHandler::HandleClearBackground(const base::ListValue* args) {
InstantService* instant_service =
InstantServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
instant_service->SetCustomBackgroundURL(GURL(""));
instant_service->ResetCustomBackgroundInfo();
}
void NtpBackgroundHandler::HandleGetBackgrounds(const base::ListValue* args) {
......
......@@ -731,7 +731,7 @@ class NewTabPageBindings : public gin::Wrappable<NewTabPageBindings> {
int tile_source,
int tile_type,
v8::Local<v8::Value> data_generation_time);
static void SetCustomBackgroundURL(const std::string& background_url);
static void ResetCustomBackgroundInfo();
static void SetCustomBackgroundInfo(const std::string& background_url,
const std::string& attribution_line_1,
const std::string& attribution_line_2,
......@@ -804,8 +804,8 @@ gin::ObjectTemplateBuilder NewTabPageBindings::GetObjectTemplateBuilder(
&NewTabPageBindings::LogMostVisitedImpression)
.SetMethod("logMostVisitedNavigation",
&NewTabPageBindings::LogMostVisitedNavigation)
.SetMethod("setBackgroundURL",
&NewTabPageBindings::SetCustomBackgroundURL)
.SetMethod("resetBackgroundInfo",
&NewTabPageBindings::ResetCustomBackgroundInfo)
.SetMethod("setBackgroundInfo",
&NewTabPageBindings::SetCustomBackgroundInfo)
.SetMethod("selectLocalBackgroundImage",
......@@ -1148,9 +1148,8 @@ void NewTabPageBindings::LogMostVisitedNavigation(
}
// static
void NewTabPageBindings::SetCustomBackgroundURL(
const std::string& background_url) {
SetCustomBackgroundInfo(background_url, std::string(), std::string(),
void NewTabPageBindings::ResetCustomBackgroundInfo() {
SetCustomBackgroundInfo(std::string(), std::string(), std::string(),
std::string(), std::string());
}
......
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