Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1223)

Unified Diff: chrome/browser/ui/search/instant_controller.cc

Issue 16413002: Moved theme related state from BrowserInstantController to InstantService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 fe1cc1bd45c2eada466250960fd566e6f61aa770..f5ddd10aceb7d4206deb9ad913b15e3f9fd0c795 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() {
@@ -1084,7 +1090,8 @@ void InstantController::SetInstantEnabled(bool instant_enabled,
instant_tab_->SetDisplayInstantResults(instant_enabled_);
}
-void InstantController::ThemeChanged(const ThemeBackgroundInfo& theme_info) {
+void InstantController::ThemeInfoChanged(
+ const ThemeBackgroundInfo& theme_info) {
if (!extended_enabled())
return;
@@ -1124,8 +1131,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 +1156,7 @@ void InstantController::ClearDebugEvents() {
}
void InstantController::UpdateMostVisitedItems() {
- InstantService* instant_service =
- InstantServiceFactory::GetForProfile(profile());
+ InstantService* instant_service = GetInstantService();
if (!instant_service)
return;
@@ -1184,8 +1189,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 +1198,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 +1206,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 +1237,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)) {
@@ -1683,7 +1687,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();
@@ -1918,3 +1926,7 @@ bool InstantController::InStartup() const {
// startup time.
return !browser_->GetActiveWebContents();
}
+
+InstantService* InstantController::GetInstantService() const {
+ return InstantServiceFactory::GetForProfile(profile());
+}

Powered by Google App Engine
This is Rietveld 408576698