Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/prefs/chrome_pref_service_factory.cc

Issue 2107493002: Offer user to send feedback from profile error dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unused variable Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD; 346 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD;
347 } 347 }
348 #endif 348 #endif
349 349
350 result.push_back(data); 350 result.push_back(data);
351 } 351 }
352 return result; 352 return result;
353 } 353 }
354 354
355 // Shows notifications which correspond to PersistentPrefStore's reading errors. 355 // Shows notifications which correspond to PersistentPrefStore's reading errors.
356 void HandleReadError(PersistentPrefStore::PrefReadError error) { 356 void HandleReadError(const base::FilePath& pref_filename,
357 PersistentPrefStore::PrefReadError error) {
357 // Sample the histogram also for the successful case in order to get a 358 // Sample the histogram also for the successful case in order to get a
358 // baseline on the success rate in addition to the error distribution. 359 // baseline on the success rate in addition to the error distribution.
359 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, 360 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error,
360 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM); 361 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM);
361 362
362 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) { 363 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) {
363 #if !defined(OS_CHROMEOS) 364 #if !defined(OS_CHROMEOS)
364 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for 365 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for
365 // an example problem that this can cause. 366 // an example problem that this can cause.
366 // Do some diagnosis and try to avoid losing data. 367 // Do some diagnosis and try to avoid losing data.
367 int message_id = 0; 368 int message_id = 0;
368 if (error <= PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE) { 369 if (error <= PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE) {
369 message_id = IDS_PREFERENCES_CORRUPT_ERROR; 370 message_id = IDS_PREFERENCES_CORRUPT_ERROR;
370 } else if (error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) { 371 } else if (error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) {
371 message_id = IDS_PREFERENCES_UNREADABLE_ERROR; 372 message_id = IDS_PREFERENCES_UNREADABLE_ERROR;
372 } 373 }
373 374
374 if (message_id) { 375 if (message_id) {
375 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 376 BrowserThread::PostTask(
376 base::Bind(&ShowProfileErrorDialog, 377 BrowserThread::UI, FROM_HERE,
377 PROFILE_ERROR_PREFERENCES, 378 base::Bind(&ShowProfileErrorDialog, pref_filename,
378 message_id)); 379 PROFILE_ERROR_PREFERENCES, message_id));
379 } 380 }
380 #else 381 #else
381 // On ChromeOS error screen with message about broken local state 382 // On ChromeOS error screen with message about broken local state
382 // will be displayed. 383 // will be displayed.
383 384
384 // A supplementary error message about broken local state - is included 385 // A supplementary error message about broken local state - is included
385 // in logs and user feedbacks. 386 // in logs and user feedbacks.
386 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE && 387 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE &&
387 error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) { 388 error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) {
388 LOG(ERROR) << "An error happened during prefs loading: " << error; 389 LOG(ERROR) << "An error happened during prefs loading: " << error;
(...skipping 17 matching lines...) Expand all
406 std::string seed; 407 std::string seed;
407 #if defined(GOOGLE_CHROME_BUILD) 408 #if defined(GOOGLE_CHROME_BUILD)
408 seed = ResourceBundle::GetSharedInstance().GetRawDataResource( 409 seed = ResourceBundle::GetSharedInstance().GetRawDataResource(
409 IDR_PREF_HASH_SEED_BIN).as_string(); 410 IDR_PREF_HASH_SEED_BIN).as_string();
410 #endif 411 #endif
411 return base::WrapUnique(new ProfilePrefStoreManager( 412 return base::WrapUnique(new ProfilePrefStoreManager(
412 profile_path, GetTrackingConfiguration(), kTrackedPrefsReportingIDsCount, 413 profile_path, GetTrackingConfiguration(), kTrackedPrefsReportingIDsCount,
413 seed, device_id, g_browser_process->local_state())); 414 seed, device_id, g_browser_process->local_state()));
414 } 415 }
415 416
416 void PrepareFactory( 417 void PrepareFactory(const base::FilePath& pref_filename,
417 syncable_prefs::PrefServiceSyncableFactory* factory, 418 syncable_prefs::PrefServiceSyncableFactory* factory,
418 policy::PolicyService* policy_service, 419 policy::PolicyService* policy_service,
419 SupervisedUserSettingsService* supervised_user_settings, 420 SupervisedUserSettingsService* supervised_user_settings,
420 scoped_refptr<PersistentPrefStore> user_pref_store, 421 scoped_refptr<PersistentPrefStore> user_pref_store,
421 const scoped_refptr<PrefStore>& extension_prefs, 422 const scoped_refptr<PrefStore>& extension_prefs,
422 bool async) { 423 bool async) {
423 policy::BrowserPolicyConnector* policy_connector = 424 policy::BrowserPolicyConnector* policy_connector =
424 g_browser_process->browser_policy_connector(); 425 g_browser_process->browser_policy_connector();
425 factory->SetManagedPolicies(policy_service, policy_connector); 426 factory->SetManagedPolicies(policy_service, policy_connector);
426 factory->SetRecommendedPolicies(policy_service, policy_connector); 427 factory->SetRecommendedPolicies(policy_service, policy_connector);
427 428
428 #if defined(ENABLE_SUPERVISED_USERS) 429 #if defined(ENABLE_SUPERVISED_USERS)
429 if (supervised_user_settings) { 430 if (supervised_user_settings) {
430 scoped_refptr<PrefStore> supervised_user_prefs = make_scoped_refptr( 431 scoped_refptr<PrefStore> supervised_user_prefs = make_scoped_refptr(
431 new SupervisedUserPrefStore(supervised_user_settings)); 432 new SupervisedUserPrefStore(supervised_user_settings));
432 // TODO(bauerb): Temporary CHECK while investigating 433 // TODO(bauerb): Temporary CHECK while investigating
433 // https://crbug.com/425785. Remove when that bug is fixed. 434 // https://crbug.com/425785. Remove when that bug is fixed.
434 CHECK(async || supervised_user_prefs->IsInitializationComplete()); 435 CHECK(async || supervised_user_prefs->IsInitializationComplete());
435 factory->set_supervised_user_prefs(supervised_user_prefs); 436 factory->set_supervised_user_prefs(supervised_user_prefs);
436 } 437 }
437 #endif 438 #endif
438 439
439 factory->set_async(async); 440 factory->set_async(async);
440 factory->set_extension_prefs(extension_prefs); 441 factory->set_extension_prefs(extension_prefs);
441 factory->set_command_line_prefs(make_scoped_refptr( 442 factory->set_command_line_prefs(make_scoped_refptr(
442 new CommandLinePrefStore(base::CommandLine::ForCurrentProcess()))); 443 new CommandLinePrefStore(base::CommandLine::ForCurrentProcess())));
443 factory->set_read_error_callback(base::Bind(&HandleReadError)); 444 factory->set_read_error_callback(base::Bind(&HandleReadError, pref_filename));
444 factory->set_user_prefs(user_pref_store); 445 factory->set_user_prefs(user_pref_store);
445 factory->SetPrefModelAssociatorClient( 446 factory->SetPrefModelAssociatorClient(
446 ChromePrefModelAssociatorClient::GetInstance()); 447 ChromePrefModelAssociatorClient::GetInstance());
447 } 448 }
448 449
449 } // namespace 450 } // namespace
450 451
451 namespace chrome_prefs { 452 namespace chrome_prefs {
452 453
453 namespace internals { 454 namespace internals {
(...skipping 10 matching lines...) Expand all
464 465
465 } // namespace internals 466 } // namespace internals
466 467
467 std::unique_ptr<PrefService> CreateLocalState( 468 std::unique_ptr<PrefService> CreateLocalState(
468 const base::FilePath& pref_filename, 469 const base::FilePath& pref_filename,
469 base::SequencedTaskRunner* pref_io_task_runner, 470 base::SequencedTaskRunner* pref_io_task_runner,
470 policy::PolicyService* policy_service, 471 policy::PolicyService* policy_service,
471 const scoped_refptr<PrefRegistry>& pref_registry, 472 const scoped_refptr<PrefRegistry>& pref_registry,
472 bool async) { 473 bool async) {
473 syncable_prefs::PrefServiceSyncableFactory factory; 474 syncable_prefs::PrefServiceSyncableFactory factory;
474 PrepareFactory(&factory, policy_service, 475 PrepareFactory(pref_filename, &factory, policy_service,
475 NULL, // supervised_user_settings 476 NULL, // supervised_user_settings
476 new JsonPrefStore(pref_filename, pref_io_task_runner, 477 new JsonPrefStore(pref_filename, pref_io_task_runner,
477 std::unique_ptr<PrefFilter>()), 478 std::unique_ptr<PrefFilter>()),
478 NULL, // extension_prefs 479 NULL, // extension_prefs
479 async); 480 async);
480 return factory.Create(pref_registry.get()); 481 return factory.Create(pref_registry.get());
481 } 482 }
482 483
483 std::unique_ptr<syncable_prefs::PrefServiceSyncable> CreateProfilePrefs( 484 std::unique_ptr<syncable_prefs::PrefServiceSyncable> CreateProfilePrefs(
484 const base::FilePath& profile_path, 485 const base::FilePath& profile_path,
(...skipping 16 matching lines...) Expand all
501 const base::Closure start_sync_flare_for_prefs = 502 const base::Closure start_sync_flare_for_prefs =
502 base::Bind(sync_start_util::GetFlareForSyncableService(profile_path), 503 base::Bind(sync_start_util::GetFlareForSyncableService(profile_path),
503 syncer::PREFERENCES); 504 syncer::PREFERENCES);
504 505
505 syncable_prefs::PrefServiceSyncableFactory factory; 506 syncable_prefs::PrefServiceSyncableFactory factory;
506 scoped_refptr<PersistentPrefStore> user_pref_store( 507 scoped_refptr<PersistentPrefStore> user_pref_store(
507 CreateProfilePrefStoreManager(profile_path) 508 CreateProfilePrefStoreManager(profile_path)
508 ->CreateProfilePrefStore(pref_io_task_runner, 509 ->CreateProfilePrefStore(pref_io_task_runner,
509 start_sync_flare_for_prefs, 510 start_sync_flare_for_prefs,
510 validation_delegate)); 511 validation_delegate));
511 PrepareFactory(&factory, 512 PrepareFactory(profile_path, &factory, policy_service,
512 policy_service, 513 supervised_user_settings, user_pref_store, extension_prefs,
513 supervised_user_settings,
514 user_pref_store,
515 extension_prefs,
516 async); 514 async);
517 std::unique_ptr<syncable_prefs::PrefServiceSyncable> pref_service = 515 std::unique_ptr<syncable_prefs::PrefServiceSyncable> pref_service =
518 factory.CreateSyncable(pref_registry.get()); 516 factory.CreateSyncable(pref_registry.get());
519 517
520 ConfigureDefaultSearchPrefMigrationToDictionaryValue(pref_service.get()); 518 ConfigureDefaultSearchPrefMigrationToDictionaryValue(pref_service.get());
521 519
522 return pref_service; 520 return pref_service;
523 } 521 }
524 522
525 void DisableDomainCheckForTesting() { 523 void DisableDomainCheckForTesting() {
(...skipping 19 matching lines...) Expand all
545 543
546 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { 544 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
547 ProfilePrefStoreManager::RegisterProfilePrefs(registry); 545 ProfilePrefStoreManager::RegisterProfilePrefs(registry);
548 } 546 }
549 547
550 void RegisterPrefs(PrefRegistrySimple* registry) { 548 void RegisterPrefs(PrefRegistrySimple* registry) {
551 ProfilePrefStoreManager::RegisterPrefs(registry); 549 ProfilePrefStoreManager::RegisterPrefs(registry);
552 } 550 }
553 551
554 } // namespace chrome_prefs 552 } // namespace chrome_prefs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698