| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
| 6 #include "app/resource_bundle.h" | 6 #include "app/resource_bundle.h" |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // while Chrome was not running. | 156 // while Chrome was not running. |
| 157 registrar_.Add(this, NotificationType::EXTENSIONS_READY, | 157 registrar_.Add(this, NotificationType::EXTENSIONS_READY, |
| 158 Source<Profile>(profile)); | 158 Source<Profile>(profile)); |
| 159 | 159 |
| 160 // Listen for the application shutting down so we can decrement our KeepAlive | 160 // Listen for the application shutting down so we can decrement our KeepAlive |
| 161 // count. | 161 // count. |
| 162 registrar_.Add(this, NotificationType::APP_TERMINATING, | 162 registrar_.Add(this, NotificationType::APP_TERMINATING, |
| 163 NotificationService::AllSources()); | 163 NotificationService::AllSources()); |
| 164 | 164 |
| 165 // Listen for changes to the background mode preference. | 165 // Listen for changes to the background mode preference. |
| 166 profile_->GetPrefs()->AddPrefObserver(prefs::kBackgroundModeEnabled, this); | 166 pref_registrar_.Init(profile_->GetPrefs()); |
| 167 pref_registrar_.Add(prefs::kBackgroundModeEnabled, this); |
| 167 } | 168 } |
| 168 | 169 |
| 169 BackgroundModeManager::~BackgroundModeManager() { | 170 BackgroundModeManager::~BackgroundModeManager() { |
| 170 // We're going away, so exit background mode (does nothing if we aren't in | 171 // We're going away, so exit background mode (does nothing if we aren't in |
| 171 // background mode currently). This is primarily needed for unit tests, | 172 // background mode currently). This is primarily needed for unit tests, |
| 172 // because in an actual running system we'd get an APP_TERMINATING | 173 // because in an actual running system we'd get an APP_TERMINATING |
| 173 // notification before being destroyed. | 174 // notification before being destroyed. |
| 174 EndBackgroundMode(); | 175 EndBackgroundMode(); |
| 175 // Manually remove our pref observer so we don't get notified for prefs | |
| 176 // changes (have to do it manually because we can't use the registrar for | |
| 177 // prefs notifications). | |
| 178 profile_->GetPrefs()->RemovePrefObserver(prefs::kBackgroundModeEnabled, this); | |
| 179 } | 176 } |
| 180 | 177 |
| 181 bool BackgroundModeManager::IsBackgroundModeEnabled() { | 178 bool BackgroundModeManager::IsBackgroundModeEnabled() { |
| 182 return profile_->GetPrefs()->GetBoolean(prefs::kBackgroundModeEnabled); | 179 return profile_->GetPrefs()->GetBoolean(prefs::kBackgroundModeEnabled); |
| 183 } | 180 } |
| 184 | 181 |
| 185 bool BackgroundModeManager::IsLaunchOnStartupResetAllowed() { | 182 bool BackgroundModeManager::IsLaunchOnStartupResetAllowed() { |
| 186 return profile_->GetPrefs()->GetBoolean(prefs::kLaunchOnStartupResetAllowed); | 183 return profile_->GetPrefs()->GetBoolean(prefs::kLaunchOnStartupResetAllowed); |
| 187 } | 184 } |
| 188 | 185 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 browser = BrowserList::GetLastActive(); | 465 browser = BrowserList::GetLastActive(); |
| 469 } | 466 } |
| 470 return browser; | 467 return browser; |
| 471 } | 468 } |
| 472 | 469 |
| 473 // static | 470 // static |
| 474 void BackgroundModeManager::RegisterUserPrefs(PrefService* prefs) { | 471 void BackgroundModeManager::RegisterUserPrefs(PrefService* prefs) { |
| 475 prefs->RegisterBooleanPref(prefs::kBackgroundModeEnabled, true); | 472 prefs->RegisterBooleanPref(prefs::kBackgroundModeEnabled, true); |
| 476 prefs->RegisterBooleanPref(prefs::kLaunchOnStartupResetAllowed, false); | 473 prefs->RegisterBooleanPref(prefs::kLaunchOnStartupResetAllowed, false); |
| 477 } | 474 } |
| OLD | NEW |