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/prefs/chrome_pref_service_factory.h" | 5 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 // Specifically enable extension settings enforcement. | 300 // Specifically enable extension settings enforcement. |
301 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD; | 301 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD; |
302 } | 302 } |
303 #endif | 303 #endif |
304 | 304 |
305 result.push_back(data); | 305 result.push_back(data); |
306 } | 306 } |
307 return result; | 307 return result; |
308 } | 308 } |
309 | 309 |
310 | |
311 // Shows notifications which correspond to PersistentPrefStore's reading errors. | 310 // Shows notifications which correspond to PersistentPrefStore's reading errors. |
312 void HandleReadError(PersistentPrefStore::PrefReadError error) { | 311 void HandleReadError(PersistentPrefStore::PrefReadError error) { |
313 // Sample the histogram also for the successful case in order to get a | 312 // Sample the histogram also for the successful case in order to get a |
314 // baseline on the success rate in addition to the error distribution. | 313 // baseline on the success rate in addition to the error distribution. |
315 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, | 314 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, |
316 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM); | 315 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM); |
317 | 316 |
318 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) { | 317 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) { |
319 #if !defined(OS_CHROMEOS) | 318 #if !defined(OS_CHROMEOS) |
320 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for | 319 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for |
321 // an example problem that this can cause. | 320 // an example problem that this can cause. |
322 // Do some diagnosis and try to avoid losing data. | 321 // Do some diagnosis and try to avoid losing data. |
323 int message_id = 0; | 322 int message_id = 0; |
324 if (error <= PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE || | 323 if (error <= PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE || |
325 error == PersistentPrefStore::PREF_READ_ERROR_LEVELDB_CORRUPTION) { | 324 error == PersistentPrefStore::PREF_READ_ERROR_LEVELDB_CORRUPTION) { |
326 message_id = IDS_PREFERENCES_CORRUPT_ERROR; | 325 message_id = IDS_PREFERENCES_CORRUPT_ERROR; |
327 } else if (error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) { | 326 } else if (error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) { |
328 message_id = IDS_PREFERENCES_UNREADABLE_ERROR; | 327 message_id = IDS_PREFERENCES_UNREADABLE_ERROR; |
329 } | 328 } |
330 | 329 |
331 if (message_id) { | 330 if (message_id) { |
332 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 331 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
333 base::Bind(&ShowProfileErrorDialog, | 332 base::Bind(&ShowProfileErrorDialog, |
334 PROFILE_ERROR_PREFERENCES, | 333 PROFILE_ERROR_PREFERENCES, |
335 message_id)); | 334 message_id)); |
336 } | 335 } |
337 #else | 336 #else |
338 // On ChromeOS error screen with message about broken local state | 337 // On ChromeOS error screen with message about broken local state |
339 // will be displayed. | 338 // will be displayed. |
| 339 |
| 340 // A supplementary error message about broken local state - is included |
| 341 // in logs and user feedbacks. |
| 342 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE && |
| 343 error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) { |
| 344 LOG(ERROR) << "An error happened during prefs loading: " << error; |
| 345 } |
340 #endif | 346 #endif |
341 } | 347 } |
342 } | 348 } |
343 | 349 |
344 scoped_ptr<ProfilePrefStoreManager> CreateProfilePrefStoreManager( | 350 scoped_ptr<ProfilePrefStoreManager> CreateProfilePrefStoreManager( |
345 const base::FilePath& profile_path) { | 351 const base::FilePath& profile_path) { |
346 std::string device_id; | 352 std::string device_id; |
347 #if defined(OS_WIN) && defined(ENABLE_RLZ) | 353 #if defined(OS_WIN) && defined(ENABLE_RLZ) |
348 // This is used by | 354 // This is used by |
349 // chrome/browser/extensions/api/music_manager_private/device_id_win.cc | 355 // chrome/browser/extensions/api/music_manager_private/device_id_win.cc |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 | 523 |
518 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 524 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
519 ProfilePrefStoreManager::RegisterProfilePrefs(registry); | 525 ProfilePrefStoreManager::RegisterProfilePrefs(registry); |
520 } | 526 } |
521 | 527 |
522 void RegisterPrefs(PrefRegistrySimple* registry) { | 528 void RegisterPrefs(PrefRegistrySimple* registry) { |
523 ProfilePrefStoreManager::RegisterPrefs(registry); | 529 ProfilePrefStoreManager::RegisterPrefs(registry); |
524 } | 530 } |
525 | 531 |
526 } // namespace chrome_prefs | 532 } // namespace chrome_prefs |
OLD | NEW |