OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/external_pref_loader.h" | 5 #include "chrome/browser/extensions/external_pref_loader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 if ((options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC) && | 120 if ((options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC) && |
121 (profile_ && profile_->IsSyncAllowed())) { | 121 (profile_ && profile_->IsSyncAllowed())) { |
122 if (!PostLoadIfPrioritySyncReady()) { | 122 if (!PostLoadIfPrioritySyncReady()) { |
123 DCHECK(profile_); | 123 DCHECK(profile_); |
124 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); | 124 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
125 DCHECK(prefs); | 125 DCHECK(prefs); |
126 syncable_pref_observer_.Add(prefs); | 126 syncable_pref_observer_.Add(prefs); |
127 ProfileSyncService* service = | 127 ProfileSyncService* service = |
128 ProfileSyncServiceFactory::GetForProfile(profile_); | 128 ProfileSyncServiceFactory::GetForProfile(profile_); |
129 DCHECK(service); | 129 DCHECK(service); |
130 if (service->IsSyncEnabledAndLoggedIn() && | 130 if (service->CanSyncStart() && |
131 (service->HasSyncSetupCompleted() || | 131 (service->HasSyncSetupCompleted() || |
132 browser_defaults::kSyncAutoStarts)) { | 132 browser_defaults::kSyncAutoStarts)) { |
133 service->AddObserver(this); | 133 service->AddObserver(this); |
134 } else { | 134 } else { |
135 PostLoadAndRemoveObservers(); | 135 PostLoadAndRemoveObservers(); |
136 } | 136 } |
137 } | 137 } |
138 } else { | 138 } else { |
139 BrowserThread::PostTask( | 139 BrowserThread::PostTask( |
140 BrowserThread::FILE, FROM_HERE, | 140 BrowserThread::FILE, FROM_HERE, |
141 base::Bind(&ExternalPrefLoader::LoadOnFileThread, this)); | 141 base::Bind(&ExternalPrefLoader::LoadOnFileThread, this)); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 void ExternalPrefLoader::OnIsSyncingChanged() { | 145 void ExternalPrefLoader::OnIsSyncingChanged() { |
146 PostLoadIfPrioritySyncReady(); | 146 PostLoadIfPrioritySyncReady(); |
147 } | 147 } |
148 | 148 |
149 void ExternalPrefLoader::OnStateChanged() { | 149 void ExternalPrefLoader::OnStateChanged() { |
150 ProfileSyncService* service = | 150 ProfileSyncService* service = |
151 ProfileSyncServiceFactory::GetForProfile(profile_); | 151 ProfileSyncServiceFactory::GetForProfile(profile_); |
152 DCHECK(service); | 152 DCHECK(service); |
153 if (!service->IsSyncEnabledAndLoggedIn()) { | 153 if (!service->CanSyncStart()) { |
154 PostLoadAndRemoveObservers(); | 154 PostLoadAndRemoveObservers(); |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 bool ExternalPrefLoader::PostLoadIfPrioritySyncReady() { | 158 bool ExternalPrefLoader::PostLoadIfPrioritySyncReady() { |
159 DCHECK(options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC); | 159 DCHECK(options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC); |
160 DCHECK(profile_); | 160 DCHECK(profile_); |
161 | 161 |
162 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); | 162 PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
163 DCHECK(prefs); | 163 DCHECK(prefs); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 LoadFinished(); | 320 LoadFinished(); |
321 } | 321 } |
322 | 322 |
323 ExternalTestingLoader::~ExternalTestingLoader() {} | 323 ExternalTestingLoader::~ExternalTestingLoader() {} |
324 | 324 |
325 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { | 325 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { |
326 return fake_base_path_; | 326 return fake_base_path_; |
327 } | 327 } |
328 | 328 |
329 } // namespace extensions | 329 } // namespace extensions |
OLD | NEW |