| Index: chrome/browser/sync/sessions/session_data_type_controller.cc
|
| diff --git a/chrome/browser/sync/sessions/session_data_type_controller.cc b/chrome/browser/sync/sessions/session_data_type_controller.cc
|
| index 24930ad44f27ad0ac597b05c419ff48861781972..fcf6dc7dbc47456ebf66f2e4292ae5301a89745e 100644
|
| --- a/chrome/browser/sync/sessions/session_data_type_controller.cc
|
| +++ b/chrome/browser/sync/sessions/session_data_type_controller.cc
|
| @@ -4,11 +4,13 @@
|
|
|
| #include "chrome/browser/sync/sessions/session_data_type_controller.h"
|
|
|
| +#include "base/prefs/pref_service.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
|
| #include "chrome/browser/sync/glue/synced_window_delegate.h"
|
| #include "chrome/browser/sync/sessions/synced_window_delegates_getter.h"
|
| +#include "chrome/common/pref_names.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/notification_details.h"
|
| #include "content/public/browser/notification_service.h"
|
| @@ -34,12 +36,17 @@ SessionDataTypeController::SessionDataTypeController(
|
| waiting_on_session_restore_(false),
|
| waiting_on_local_device_info_(false) {
|
| DCHECK(local_device_);
|
| + pref_registrar_.Init(profile->GetPrefs());
|
| + pref_registrar_.Add(
|
| + prefs::kSavingBrowserHistoryDisabled,
|
| + base::Bind(&SessionDataTypeController::OnSavingBrowserHistoryPrefChanged,
|
| + base::Unretained(this)));
|
| }
|
|
|
| SessionDataTypeController::~SessionDataTypeController() {}
|
|
|
| bool SessionDataTypeController::StartModels() {
|
| - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| std::set<browser_sync::SyncedWindowDelegate*> window =
|
| synced_window_getter_->GetSyncedWindowDelegates();
|
| for (std::set<browser_sync::SyncedWindowDelegate*>::const_iterator i =
|
| @@ -68,6 +75,12 @@ void SessionDataTypeController::StopModels() {
|
| notification_registrar_.RemoveAll();
|
| }
|
|
|
| +bool SessionDataTypeController::ReadyForStart() const {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + return !profile_->GetPrefs()->GetBoolean(
|
| + prefs::kSavingBrowserHistoryDisabled);
|
| +}
|
| +
|
| bool SessionDataTypeController::IsWaiting() {
|
| return waiting_on_session_restore_ || waiting_on_local_device_info_;
|
| }
|
| @@ -82,7 +95,7 @@ void SessionDataTypeController::Observe(
|
| int type,
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) {
|
| - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| DCHECK_EQ(chrome::NOTIFICATION_SESSION_RESTORE_COMPLETE, type);
|
| DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
|
| notification_registrar_.RemoveAll();
|
| @@ -99,4 +112,21 @@ void SessionDataTypeController::OnLocalDeviceInfoInitialized() {
|
| MaybeCompleteLoading();
|
| }
|
|
|
| +void SessionDataTypeController::OnSavingBrowserHistoryPrefChanged() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + if (profile_->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled)) {
|
| + // If history and tabs persistence is turned off then generate an
|
| + // unrecoverable error. SESSIONS won't be a registered type on the next
|
| + // Chrome restart.
|
| + if (state() != NOT_RUNNING && state() != STOPPING) {
|
| + syncer::SyncError error(
|
| + FROM_HERE,
|
| + syncer::SyncError::DATATYPE_POLICY_ERROR,
|
| + "History and tab saving is now disabled by policy.",
|
| + syncer::SESSIONS);
|
| + OnSingleDataTypeUnrecoverableError(error);
|
| + }
|
| + }
|
| +}
|
| +
|
| } // namespace browser_sync
|
|
|