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 c861a1c963ed4ba3eedc309720e62e8b417164da..d709988abdd352e1008273263bb0b5b5a4eb68ed 100644 |
--- a/chrome/browser/ui/search/instant_controller.cc |
+++ b/chrome/browser/ui/search/instant_controller.cc |
@@ -274,11 +274,17 @@ 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 = GetInstantService(); |
+ instant_service->AddObserver(this); |
+ } |
} |
InstantController::~InstantController() { |
+ if (browser_) { |
+ InstantService* instant_service = GetInstantService(); |
+ instant_service->RemoveObserver(this); |
+ } |
} |
void InstantController::OnAutocompleteStart() { |
@@ -796,6 +802,21 @@ void InstantController::InstantPageLoadFailed(content::WebContents* contents) { |
} |
} |
+void InstantController::ThemeInfoChanged( |
+ const ThemeBackgroundInfo& theme_info) { |
+ if (!extended_enabled()) |
+ return; |
+ |
+ if (overlay_) |
+ overlay_->SendThemeBackgroundInfo(theme_info); |
+ |
+ if (ntp_) |
+ ntp_->SendThemeBackgroundInfo(theme_info); |
+ |
+ if (instant_tab_) |
+ instant_tab_->SendThemeBackgroundInfo(theme_info); |
+} |
+ |
content::WebContents* InstantController::GetOverlayContents() const { |
return overlay_ ? overlay_->contents() : NULL; |
} |
@@ -1084,18 +1105,6 @@ void InstantController::SetInstantEnabled(bool instant_enabled, |
instant_tab_->SetDisplayInstantResults(instant_enabled_); |
} |
-void InstantController::ThemeChanged(const ThemeBackgroundInfo& theme_info) { |
samarth
2013/06/19 22:37:15
Just undo this diff?
kmadhusu
2013/06/20 01:21:27
Done. I was trying to match the function declarati
|
- if (!extended_enabled()) |
- return; |
- |
- if (overlay_) |
- overlay_->SendThemeBackgroundInfo(theme_info); |
- if (ntp_) |
- ntp_->SendThemeBackgroundInfo(theme_info); |
- if (instant_tab_) |
- instant_tab_->SendThemeBackgroundInfo(theme_info); |
-} |
- |
void InstantController::SwappedOverlayContents() { |
model_.SetOverlayContents(GetOverlayContents()); |
} |
@@ -1124,8 +1133,7 @@ void InstantController::ReloadOverlayIfStale() { |
void InstantController::OverlayLoadCompletedMainFrame() { |
if (overlay_->supports_instant()) |
return; |
- InstantService* instant_service = |
- InstantServiceFactory::GetForProfile(browser_->profile()); |
+ InstantService* instant_service = GetInstantService(); |
content::WebContents* contents = overlay_->contents(); |
DCHECK(contents); |
if (instant_service->IsInstantProcess( |
@@ -1150,8 +1158,7 @@ void InstantController::ClearDebugEvents() { |
} |
void InstantController::UpdateMostVisitedItems() { |
- InstantService* instant_service = |
- InstantServiceFactory::GetForProfile(profile()); |
+ InstantService* instant_service = GetInstantService(); |
if (!instant_service) |
return; |
@@ -1184,8 +1191,7 @@ void InstantController::UpdateMostVisitedItems() { |
void InstantController::DeleteMostVisitedItem(const GURL& url) { |
DCHECK(!url.is_empty()); |
- InstantService* instant_service = |
- InstantServiceFactory::GetForProfile(profile()); |
+ InstantService* instant_service = GetInstantService(); |
if (!instant_service) |
return; |
@@ -1194,8 +1200,7 @@ void InstantController::DeleteMostVisitedItem(const GURL& url) { |
void InstantController::UndoMostVisitedDeletion(const GURL& url) { |
DCHECK(!url.is_empty()); |
- InstantService* instant_service = |
- InstantServiceFactory::GetForProfile(profile()); |
+ InstantService* instant_service = GetInstantService(); |
if (!instant_service) |
return; |
@@ -1203,8 +1208,7 @@ void InstantController::UndoMostVisitedDeletion(const GURL& url) { |
} |
void InstantController::UndoAllMostVisitedDeletions() { |
- InstantService* instant_service = |
- InstantServiceFactory::GetForProfile(profile()); |
+ InstantService* instant_service = GetInstantService(); |
if (!instant_service) |
return; |
@@ -1235,7 +1239,9 @@ void InstantController::InstantPageRenderViewCreated( |
return; |
// Update theme info so that the page picks it up. |
- browser_->UpdateThemeInfo(); |
+ InstantService* instant_service = GetInstantService(); |
+ if (instant_service) |
+ instant_service->UpdateThemeInfo(); |
// Ensure the searchbox API has the correct initial state. |
if (IsContentsFrom(overlay(), contents)) { |
@@ -1672,7 +1678,11 @@ void InstantController::ResetInstantTab() { |
void InstantController::UpdateInfoForInstantTab() { |
if (instant_tab_) { |
- browser_->UpdateThemeInfo(); |
+ // Update theme details. |
+ InstantService* instant_service = GetInstantService(); |
+ if (instant_service) |
+ instant_service->UpdateThemeInfo(); |
+ |
instant_tab_->SetDisplayInstantResults(instant_enabled_); |
instant_tab_->SetOmniboxBounds(omnibox_bounds_); |
instant_tab_->InitializeFonts(); |
@@ -1907,3 +1917,7 @@ bool InstantController::InStartup() const { |
// startup time. |
return !browser_->GetActiveWebContents(); |
} |
+ |
+InstantService* InstantController::GetInstantService() const { |
+ return InstantServiceFactory::GetForProfile(profile()); |
+} |