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

[NTP] Remove SetCustomBackgroundURL from the embeddedSearchAPI

SetCustomBackgroundURL is equivalent to calling
SetCustomBackgroundURLWithAttributions with empty attributions. Remove
the separate API and instead just pass in empty attributions when
SetCustomBackgroundURL is called.

Bug: 961908

Change-Id: I52389d85219fdd03008717979f142cffe5ff1e62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1607431Reviewed-by: default avatarEmily Stark <estark@chromium.org>
Reviewed-by: default avatarGayane Petrosyan <gayane@chromium.org>
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661982}
parent 86931732
......@@ -179,7 +179,7 @@ TEST_F(InstantServiceTest, SetCustomBackgroundURL) {
const GURL kUrl("https://www.foo.com");
instant_service_->AddValidBackdropUrlForTesting(kUrl);
instant_service_->SetCustomBackgroundURL(kUrl);
instant_service_->SetCustomBackgroundURLWithAttributions(kUrl, std::string(), std::string(), GURL());
ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo();
EXPECT_EQ(kUrl, theme_info->custom_background_url);
......@@ -196,7 +196,7 @@ TEST_F(InstantServiceTest, SetCustomBackgroundURLInvalidURL) {
ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo();
EXPECT_EQ(kValidUrl.spec(), theme_info->custom_background_url.spec());
instant_service_->SetCustomBackgroundURL(kInvalidUrl);
instant_service_->SetCustomBackgroundURLWithAttributions(kInvalidUrl, std::string(), std::string(), GURL());
theme_info = instant_service_->GetInitializedThemeInfo();
EXPECT_EQ(std::string(), theme_info->custom_background_url.spec());
......
......@@ -332,13 +332,6 @@ void SearchIPCRouter::PasteAndOpenDropdown(int page_seq_no,
delegate_->PasteIntoOmnibox(text);
}
void SearchIPCRouter::SetCustomBackgroundURL(const GURL& url) {
if (!policy_->ShouldProcessSetCustomBackgroundURL())
return;
delegate_->OnSetCustomBackgroundURL(url);
}
void SearchIPCRouter::SetCustomBackgroundURLWithAttributions(
const GURL& background_url,
const std::string& attribution_line_1,
......
......@@ -104,9 +104,6 @@ class SearchIPCRouter : public content::WebContentsObserver,
// if the |text| is empty) into the omnibox.
virtual void PasteIntoOmnibox(const base::string16& text) = 0;
// Called when a custom background is selected on the NTP.
virtual void OnSetCustomBackgroundURL(const GURL& url) = 0;
// Called when a custom background with attributions is selected on the NTP.
// background_url: Url of the background image.
// attribution_line_1: First attribution line for the image.
......@@ -169,7 +166,6 @@ class SearchIPCRouter : public content::WebContentsObserver,
virtual bool ShouldSendOmniboxFocusChanged() = 0;
virtual bool ShouldSendMostVisitedItems() = 0;
virtual bool ShouldSendThemeBackgroundInfo() = 0;
virtual bool ShouldProcessSetCustomBackgroundURL() = 0;
virtual bool ShouldProcessSetCustomBackgroundURLWithAttributions() = 0;
virtual bool ShouldProcessSelectLocalBackgroundImage() = 0;
virtual bool ShouldProcessBlocklistSearchSuggestion() = 0;
......@@ -257,7 +253,6 @@ class SearchIPCRouter : public content::WebContentsObserver,
const ntp_tiles::NTPTileImpression& impression) override;
void PasteAndOpenDropdown(int page_seq_no,
const base::string16& text) override;
void SetCustomBackgroundURL(const GURL& url) override;
void SetCustomBackgroundURLWithAttributions(
const GURL& background_url,
const std::string& attribution_line_1,
......
......@@ -99,10 +99,6 @@ bool SearchIPCRouterPolicyImpl::ShouldProcessSelectLocalBackgroundImage() {
return !is_incognito_ && search::IsInstantNTP(web_contents_);
}
bool SearchIPCRouterPolicyImpl::ShouldProcessSetCustomBackgroundURL() {
return !is_incognito_ && search::IsInstantNTP(web_contents_);
}
bool SearchIPCRouterPolicyImpl::
ShouldProcessSetCustomBackgroundURLWithAttributions() {
return !is_incognito_ && search::IsInstantNTP(web_contents_);
......
......@@ -45,7 +45,6 @@ class SearchIPCRouterPolicyImpl : public SearchIPCRouter::Policy {
bool ShouldSendOmniboxFocusChanged() override;
bool ShouldSendMostVisitedItems() override;
bool ShouldSendThemeBackgroundInfo() override;
bool ShouldProcessSetCustomBackgroundURL() override;
bool ShouldProcessSetCustomBackgroundURLWithAttributions() override;
bool ShouldProcessSelectLocalBackgroundImage() override;
bool ShouldProcessBlocklistSearchSuggestion() override;
......
......@@ -812,32 +812,6 @@ TEST_F(SearchIPCRouterTest, DoNotSendThemeBackgroundInfoMsg) {
GetSearchIPCRouter().SendThemeBackgroundInfo(ThemeBackgroundInfo());
}
TEST_F(SearchIPCRouterTest, ProcessSetCustomBackgroundURLMsg) {
NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
SetupMockDelegateAndPolicy();
MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
GURL bg_url("www.foo.com");
EXPECT_CALL(*mock_delegate(), OnSetCustomBackgroundURL(bg_url)).Times(1);
EXPECT_CALL(*policy, ShouldProcessSetCustomBackgroundURL())
.Times(1)
.WillOnce(Return(true));
GetSearchIPCRouter().SetCustomBackgroundURL(bg_url);
}
TEST_F(SearchIPCRouterTest, IgnoreSetCustomBackgroundURLMsg) {
NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
SetupMockDelegateAndPolicy();
MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
GURL bg_url("www.foo.com");
EXPECT_CALL(*mock_delegate(), OnSetCustomBackgroundURL(bg_url)).Times(0);
EXPECT_CALL(*policy, ShouldProcessSetCustomBackgroundURL())
.Times(1)
.WillOnce(Return(false));
GetSearchIPCRouter().SetCustomBackgroundURL(bg_url);
}
TEST_F(SearchIPCRouterTest, ProcessSetCustomBackgroundURLWithAttributionsMsg) {
NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
SetupMockDelegateAndPolicy();
......
......@@ -378,11 +378,6 @@ void SearchTabHelper::PasteIntoOmnibox(const base::string16& text) {
omnibox_view->OnAfterPossibleChange(true);
}
void SearchTabHelper::OnSetCustomBackgroundURL(const GURL& url) {
if (instant_service_)
instant_service_->SetCustomBackgroundURL(url);
}
void SearchTabHelper::OnSetCustomBackgroundURLWithAttributions(
const GURL& background_url,
const std::string& attribution_line_1,
......
......@@ -109,7 +109,6 @@ class SearchTabHelper : public content::WebContentsObserver,
void OnLogMostVisitedNavigation(
const ntp_tiles::NTPTileImpression& impression) override;
void PasteIntoOmnibox(const base::string16& text) override;
void OnSetCustomBackgroundURL(const GURL& url) override;
void OnSetCustomBackgroundURLWithAttributions(
const GURL& background_url,
const std::string& attribution_line_1,
......
......@@ -103,7 +103,6 @@ interface EmbeddedSearch {
mojo_base.mojom.String16 text_to_be_pasted);
// Updates the NTP custom background preferences.
SetCustomBackgroundURL(url.mojom.Url url);
SetCustomBackgroundURLWithAttributions(url.mojom.Url background_url,
string attribution_line_1,
string attribution_line_2,
......
......@@ -364,10 +364,6 @@ std::string SearchBox::FixupAndValidateUrl(const std::string& url) const {
return internal::FixupAndValidateUrl(url);
}
void SearchBox::SetCustomBackgroundURL(const GURL& background_url) {
embedded_search_service_->SetCustomBackgroundURL(background_url);
}
void SearchBox::SetCustomBackgroundURLWithAttributions(
const GURL& background_url,
const std::string& attribution_line_1,
......
......@@ -140,7 +140,6 @@ class SearchBox : public content::RenderFrameObserver,
// Updates the NTP custom background preferences, sometimes this includes
// image attributions.
void SetCustomBackgroundURL(const GURL& background_url);
void SetCustomBackgroundURLWithAttributions(
const GURL& background_url,
const std::string& attribution_line_1,
......
......@@ -1025,7 +1025,7 @@ void NewTabPageBindings::SetCustomBackgroundURL(
const std::string& background_url) {
SearchBox* search_box = GetSearchBoxForCurrentContext();
GURL url(background_url);
search_box->SetCustomBackgroundURL(url);
search_box->SetCustomBackgroundURLWithAttributions(url, std::string(), std::string(), GURL());
}
// static
......
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