Commit fb37a775 authored by Kyle Milka's avatar Kyle Milka Committed by Commit Bot

[NTP] Only show custom background on Google NTP

Custom backgrounds should only be applied when Google is set
as the search provider. Adds ApplyGoogleNtpThemeElements to
set/unset the background as needed.

Bug: 851290
Change-Id: I2fa7ca1081df818b455df27d1496047b0a800765
Reviewed-on: https://chromium-review.googlesource.com/1112379Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570051}
parent 36818434
......@@ -146,11 +146,14 @@ void InstantService::UndoAllMostVisitedDeletions() {
}
}
void InstantService::UpdateThemeInfo(bool force_update) {
void InstantService::UpdateThemeInfo() {
// Initialize |theme_info_| if necessary.
if (!theme_info_ || force_update) {
if (!theme_info_) {
BuildThemeInfo();
}
ApplyGoogleNtpThemeElements();
NotifyAboutThemeInfo();
}
......@@ -175,7 +178,7 @@ void InstantService::SetCustomBackgroundURL(const GURL& url) {
pref_service_->SetString(prefs::kNTPCustomBackgroundURL, url.spec());
}
UpdateThemeInfo(true);
UpdateThemeInfo();
}
void InstantService::Shutdown() {
......@@ -359,12 +362,17 @@ void InstantService::BuildThemeInfo() {
theme_info_->has_attribution =
theme_provider.HasCustomImage(IDR_THEME_NTP_ATTRIBUTION);
}
}
void InstantService::ApplyGoogleNtpThemeElements() {
// User has set a custom background image.
GURL custom_background_url(
profile_->GetPrefs()->GetString(prefs::kNTPCustomBackgroundURL));
if (custom_background_url.is_valid()) {
if (custom_background_url.is_valid() &&
search::DefaultSearchProviderIsGoogle(profile_)) {
theme_info_->custom_background_url = custom_background_url;
} else {
theme_info_->custom_background_url = GURL::EmptyGURL();
}
}
......
......@@ -85,7 +85,7 @@ class InstantService : public KeyedService,
//
// TODO(kmadhusu): Invoking this from InstantController shouldn't be
// necessary. Investigate more and remove this from here.
void UpdateThemeInfo(bool force_update);
void UpdateThemeInfo();
// Invoked by the InstantController to update most visited items details for
// NTP.
......@@ -126,6 +126,8 @@ class InstantService : public KeyedService,
void BuildThemeInfo();
void ApplyGoogleNtpThemeElements();
Profile* const profile_;
// The process ids associated with Instant processes.
......
......@@ -93,7 +93,7 @@ void InstantController::UpdateInfoForInstantTab() {
InstantService* instant_service =
InstantServiceFactory::GetForProfile(profile_);
if (instant_service) {
instant_service->UpdateThemeInfo(false);
instant_service->UpdateThemeInfo();
instant_service->UpdateMostVisitedItemsInfo();
}
}
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