OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/history/core/browser/history_delete_directives_data_type_co
ntroller.h" | 5 #include "components/history/core/browser/history_delete_directives_data_type_co
ntroller.h" |
6 | 6 |
7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "components/sync/driver/sync_client.h" | 8 #include "components/sync/driver/sync_client.h" |
9 #include "components/sync/driver/sync_service.h" | 9 #include "components/sync/driver/sync_service.h" |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 sync_client_->GetSyncService()->AddObserver(this); | 36 sync_client_->GetSyncService()->AddObserver(this); |
37 return true; | 37 return true; |
38 } | 38 } |
39 | 39 |
40 void HistoryDeleteDirectivesDataTypeController::StopModels() { | 40 void HistoryDeleteDirectivesDataTypeController::StopModels() { |
41 DCHECK(CalledOnValidThread()); | 41 DCHECK(CalledOnValidThread()); |
42 if (sync_client_->GetSyncService()->HasObserver(this)) | 42 if (sync_client_->GetSyncService()->HasObserver(this)) |
43 sync_client_->GetSyncService()->RemoveObserver(this); | 43 sync_client_->GetSyncService()->RemoveObserver(this); |
44 } | 44 } |
45 | 45 |
46 void HistoryDeleteDirectivesDataTypeController::OnStateChanged() { | 46 void HistoryDeleteDirectivesDataTypeController::OnStateChanged( |
| 47 syncer::SyncService* sync) { |
47 DisableTypeIfNecessary(); | 48 DisableTypeIfNecessary(); |
48 } | 49 } |
49 | 50 |
50 bool HistoryDeleteDirectivesDataTypeController::DisableTypeIfNecessary() { | 51 bool HistoryDeleteDirectivesDataTypeController::DisableTypeIfNecessary() { |
51 DCHECK(CalledOnValidThread()); | 52 DCHECK(CalledOnValidThread()); |
52 if (!sync_client_->GetSyncService()->IsSyncActive()) | 53 if (!sync_client_->GetSyncService()->IsSyncActive()) |
53 return false; | 54 return false; |
54 | 55 |
55 if (ReadyForStart()) | 56 if (ReadyForStart()) |
56 return false; | 57 return false; |
57 | 58 |
58 if (sync_client_->GetSyncService()->HasObserver(this)) | 59 if (sync_client_->GetSyncService()->HasObserver(this)) |
59 sync_client_->GetSyncService()->RemoveObserver(this); | 60 sync_client_->GetSyncService()->RemoveObserver(this); |
60 syncer::SyncError error( | 61 syncer::SyncError error( |
61 FROM_HERE, | 62 FROM_HERE, |
62 syncer::SyncError::DATATYPE_POLICY_ERROR, | 63 syncer::SyncError::DATATYPE_POLICY_ERROR, |
63 "Delete directives not supported with encryption.", | 64 "Delete directives not supported with encryption.", |
64 type()); | 65 type()); |
65 CreateErrorHandler()->OnUnrecoverableError(error); | 66 CreateErrorHandler()->OnUnrecoverableError(error); |
66 return true; | 67 return true; |
67 } | 68 } |
68 | 69 |
69 } // namespace browser_sync | 70 } // namespace browser_sync |
OLD | NEW |