Index: chrome/browser/ui/search/instant_controller.cc |
diff --git a/chrome/browser/ui/search/instant_controller.cc b/chrome/browser/ui/search/instant_controller.cc |
index d01af5d992390385c60bd3bfa0da63f82dd122ff..4f9eefb7833d574644c8e2a6beb50d634859329c 100644 |
--- a/chrome/browser/ui/search/instant_controller.cc |
+++ b/chrome/browser/ui/search/instant_controller.cc |
@@ -269,11 +269,19 @@ InstantController::InstantController(BrowserInstantController* browser, |
// InstantService sets up profile-level facilities such as the ThemeSource for |
// the NTP. |
// However, in some tests, browser_ may be null. |
- if (browser_) |
- InstantServiceFactory::GetForProfile(browser_->profile()); |
+ if (browser_) { |
+ InstantService* instant_service = |
+ InstantServiceFactory::GetForProfile(browser_->profile()); |
+ instant_service->AddObserver(this); |
+ } |
} |
InstantController::~InstantController() { |
+ if (browser_) { |
+ InstantService* instant_service = |
+ InstantServiceFactory::GetForProfile(browser_->profile()); |
+ instant_service->RemoveObserver(this); |
+ } |
} |
void InstantController::OnAutocompleteStart() { |
@@ -1079,16 +1087,28 @@ void InstantController::SetInstantEnabled(bool instant_enabled, |
instant_tab_->SetDisplayInstantResults(instant_enabled_); |
} |
-void InstantController::ThemeChanged(const ThemeBackgroundInfo& theme_info) { |
- if (!extended_enabled()) |
+void InstantController::ThemeInfoChanged( |
+ const ThemeBackgroundInfo& theme_info) { |
+ if (!extended_enabled() || !search_mode_.is_ntp()) |
samarth
2013/06/19 00:14:36
Don't check for search_mode_ here. We'd want to up
kmadhusu
2013/06/19 02:27:24
Done.
|
return; |
- if (overlay_) |
+ if (overlay_ && GetOverlayContents() && |
+ SearchTabHelper::FromWebContents(overlay_->contents())-> |
+ UpdateLastKnownThemeBackgroundInfo(theme_info)) { |
overlay_->SendThemeBackgroundInfo(theme_info); |
- if (ntp_) |
+ } |
+ |
+ if (ntp_ && ntp_->contents() && |
+ SearchTabHelper::FromWebContents(ntp_->contents())-> |
+ UpdateLastKnownThemeBackgroundInfo(theme_info)) { |
ntp_->SendThemeBackgroundInfo(theme_info); |
- if (instant_tab_) |
+ } |
+ |
+ if (instant_tab_ && instant_tab_->contents() && |
+ SearchTabHelper::FromWebContents(instant_tab_->contents())-> |
+ UpdateLastKnownThemeBackgroundInfo(theme_info)) { |
instant_tab_->SendThemeBackgroundInfo(theme_info); |
+ } |
} |
void InstantController::SwappedOverlayContents() { |
@@ -1177,6 +1197,13 @@ void InstantController::UpdateMostVisitedItems() { |
content::NotificationService::NoDetails()); |
} |
+void InstantController::UpdateThemeInfo() { |
samarth
2013/06/19 00:14:36
If UpdateThemeInfo doesn't need to be called from
kmadhusu
2013/06/19 02:27:24
Done.
|
+ InstantService* instant_service = |
+ InstantServiceFactory::GetForProfile(profile()); |
+ if (instant_service) |
+ instant_service->UpdateThemeInfo(); |
+} |
+ |
void InstantController::DeleteMostVisitedItem(const GURL& url) { |
DCHECK(!url.is_empty()); |
InstantService* instant_service = |
@@ -1230,7 +1257,7 @@ void InstantController::InstantPageRenderViewCreated( |
return; |
// Update theme info so that the page picks it up. |
- browser_->UpdateThemeInfo(); |
+ UpdateThemeInfo(); |
// Ensure the searchbox API has the correct initial state. |
if (IsContentsFrom(overlay(), contents)) { |
@@ -1663,7 +1690,7 @@ void InstantController::ResetInstantTab() { |
void InstantController::UpdateInfoForInstantTab() { |
if (instant_tab_) { |
- browser_->UpdateThemeInfo(); |
+ UpdateThemeInfo(); |
instant_tab_->SetDisplayInstantResults(instant_enabled_); |
instant_tab_->SetOmniboxBounds(omnibox_bounds_); |
instant_tab_->InitializeFonts(); |