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