Index: chrome/browser/ui/browser_instant_controller.cc |
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc |
index 582ae88a9009ee2429c033d94ebfc861278d625f..b87b26d6017523534ed6c8a2845cf572399bb93e 100644 |
--- a/chrome/browser/ui/browser_instant_controller.cc |
+++ b/chrome/browser/ui/browser_instant_controller.cc |
@@ -28,13 +28,6 @@ |
#include "ui/gfx/color_utils.h" |
#include "ui/gfx/sys_color_change_listener.h" |
-namespace { |
-const char* GetInstantPrefName(Profile* profile) { |
- return chrome::search::IsInstantExtendedAPIEnabled(profile) ? |
- prefs::kInstantExtendedEnabled : prefs::kInstantEnabled; |
-} |
-} |
- |
namespace chrome { |
//////////////////////////////////////////////////////////////////////////////// |
@@ -46,15 +39,15 @@ BrowserInstantController::BrowserInstantController(Browser* browser) |
chrome::search::IsInstantExtendedAPIEnabled(profile())), |
instant_unload_handler_(browser), |
initialized_theme_info_(false) { |
- profile_pref_registrar_.Init(profile()->GetPrefs()); |
- profile_pref_registrar_.Add( |
- GetInstantPrefName(profile()), |
- base::Bind(&BrowserInstantController::ResetInstant, |
- base::Unretained(this))); |
- profile_pref_registrar_.Add( |
- prefs::kSearchSuggestEnabled, |
- base::Bind(&BrowserInstantController::ResetInstant, |
- base::Unretained(this))); |
+ PrefService* prefs = profile()->GetPrefs(); |
+ |
+ profile_pref_registrar_.Init(prefs); |
+ base::Closure reset_instant = base::Bind( |
+ &BrowserInstantController::ResetInstant, |
+ base::Unretained(this)); |
+ profile_pref_registrar_.Add(prefs::kInstantEnabled, reset_instant); |
+ profile_pref_registrar_.Add(prefs::kInstantExtendedEnabled, reset_instant); |
+ profile_pref_registrar_.Add(prefs::kSearchSuggestEnabled, reset_instant); |
ResetInstant(); |
browser_->search_model()->AddObserver(this); |
@@ -71,14 +64,26 @@ BrowserInstantController::~BrowserInstantController() { |
} |
bool BrowserInstantController::IsInstantEnabled(Profile* profile) { |
- return profile && !profile->IsOffTheRecord() && profile->GetPrefs() && |
- profile->GetPrefs()->GetBoolean(GetInstantPrefName(profile)); |
+ if (!profile || profile->IsOffTheRecord()) |
+ return false; |
+ |
+ PrefService* prefs = profile->GetPrefs(); |
+ if (!prefs) |
+ return false; |
+ |
+ if (!chrome::search::IsInstantExtendedAPIEnabled(profile) || |
+ (search::GetInstantExtendedDefaultSetting() == |
+ search::INSTANT_USE_EXISTING && |
+ prefs->FindPreference( |
+ prefs::kInstantExtendedEnabled)->IsDefaultValue())) { |
+ return prefs->GetBoolean(prefs::kInstantEnabled); |
+ } else { |
+ return prefs->GetBoolean(prefs::kInstantExtendedEnabled); |
+ } |
} |
void BrowserInstantController::RegisterUserPrefs( |
- PrefService* prefs, |
PrefRegistrySyncable* registry) { |
- // TODO(joi): Get rid of the need for PrefService param above. |
registry->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, false, |
PrefRegistrySyncable::SYNCABLE_PREF); |
registry->RegisterBooleanPref(prefs::kInstantEnabled, false, |
@@ -89,9 +94,10 @@ void BrowserInstantController::RegisterUserPrefs( |
case search::INSTANT_DEFAULT_ON: |
instant_extended_default = true; |
break; |
+ // In the INSTANT_USE_EXISTING case, the kInstantExtendedEnabled |
+ // preference, if it still has a default value, is set to the |
+ // value of kInstantEnabled in the constructor of this class. |
case search::INSTANT_USE_EXISTING: |
- instant_extended_default = prefs->GetBoolean(prefs::kInstantEnabled); |
- break; |
case search::INSTANT_DEFAULT_OFF: |
instant_extended_default = false; |
break; |