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

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: pkasting's & droger's Created 4 years, 4 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "components/signin/core/common/signin_pref_names.h" 50 #include "components/signin/core/common/signin_pref_names.h"
51 #include "components/sync/base/model_type.h" 51 #include "components/sync/base/model_type.h"
52 #include "components/sync_driver/pref_names.h" 52 #include "components/sync_driver/pref_names.h"
53 #include "components/syncable_prefs/pref_model_associator.h" 53 #include "components/syncable_prefs/pref_model_associator.h"
54 #include "components/syncable_prefs/pref_service_syncable.h" 54 #include "components/syncable_prefs/pref_service_syncable.h"
55 #include "components/syncable_prefs/pref_service_syncable_factory.h" 55 #include "components/syncable_prefs/pref_service_syncable_factory.h"
56 #include "components/user_prefs/tracked/pref_names.h" 56 #include "components/user_prefs/tracked/pref_names.h"
57 #include "content/public/browser/browser_context.h" 57 #include "content/public/browser/browser_context.h"
58 #include "content/public/browser/browser_thread.h" 58 #include "content/public/browser/browser_thread.h"
59 #include "grit/browser_resources.h" 59 #include "grit/browser_resources.h"
60 #include "sql/error_delegate_util.h"
60 #include "ui/base/resource/resource_bundle.h" 61 #include "ui/base/resource/resource_bundle.h"
61 62
62 #if defined(ENABLE_EXTENSIONS) 63 #if defined(ENABLE_EXTENSIONS)
63 #include "extensions/browser/pref_names.h" 64 #include "extensions/browser/pref_names.h"
64 #endif 65 #endif
65 66
66 #if defined(ENABLE_SUPERVISED_USERS) 67 #if defined(ENABLE_SUPERVISED_USERS)
67 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" 68 #include "chrome/browser/supervised_user/supervised_user_pref_store.h"
68 #endif 69 #endif
69 70
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD; 347 data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD;
347 } 348 }
348 #endif 349 #endif
349 350
350 result.push_back(data); 351 result.push_back(data);
351 } 352 }
352 return result; 353 return result;
353 } 354 }
354 355
355 // Shows notifications which correspond to PersistentPrefStore's reading errors. 356 // Shows notifications which correspond to PersistentPrefStore's reading errors.
356 void HandleReadError(PersistentPrefStore::PrefReadError error) { 357 void HandleReadError(const base::FilePath& pref_filename,
358 PersistentPrefStore::PrefReadError error) {
357 // Sample the histogram also for the successful case in order to get a 359 // 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. 360 // baseline on the success rate in addition to the error distribution.
359 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, 361 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error,
360 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM); 362 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM);
361 363
362 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) { 364 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE) {
363 #if !defined(OS_CHROMEOS) 365 #if !defined(OS_CHROMEOS)
364 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for 366 // Failing to load prefs on startup is a bad thing(TM). See bug 38352 for
365 // an example problem that this can cause. 367 // an example problem that this can cause.
366 // Do some diagnosis and try to avoid losing data. 368 // Do some diagnosis and try to avoid losing data.
367 int message_id = 0; 369 int message_id = 0;
368 if (error <= PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE) { 370 if (error <= PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE) {
369 message_id = IDS_PREFERENCES_CORRUPT_ERROR; 371 message_id = IDS_PREFERENCES_CORRUPT_ERROR;
370 } else if (error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) { 372 } else if (error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) {
371 message_id = IDS_PREFERENCES_UNREADABLE_ERROR; 373 message_id = IDS_PREFERENCES_UNREADABLE_ERROR;
372 } 374 }
373 375
374 if (message_id) { 376 if (message_id) {
375 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 377 BrowserThread::PostTask(
376 base::Bind(&ShowProfileErrorDialog, 378 BrowserThread::UI, FROM_HERE,
377 PROFILE_ERROR_PREFERENCES, 379 base::Bind(&ShowProfileErrorDialog, PROFILE_ERROR_PREFERENCES,
378 message_id)); 380 message_id,
381 sql::GetCorruptFileDiagnosticsInfo(pref_filename)));
379 } 382 }
380 #else 383 #else
381 // On ChromeOS error screen with message about broken local state 384 // On ChromeOS error screen with message about broken local state
382 // will be displayed. 385 // will be displayed.
383 386
384 // A supplementary error message about broken local state - is included 387 // A supplementary error message about broken local state - is included
385 // in logs and user feedbacks. 388 // in logs and user feedbacks.
386 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE && 389 if (error != PersistentPrefStore::PREF_READ_ERROR_NONE &&
387 error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) { 390 error != PersistentPrefStore::PREF_READ_ERROR_NO_FILE) {
388 LOG(ERROR) << "An error happened during prefs loading: " << error; 391 LOG(ERROR) << "An error happened during prefs loading: " << error;
(...skipping 17 matching lines...) Expand all
406 std::string seed; 409 std::string seed;
407 #if defined(GOOGLE_CHROME_BUILD) 410 #if defined(GOOGLE_CHROME_BUILD)
408 seed = ResourceBundle::GetSharedInstance().GetRawDataResource( 411 seed = ResourceBundle::GetSharedInstance().GetRawDataResource(
409 IDR_PREF_HASH_SEED_BIN).as_string(); 412 IDR_PREF_HASH_SEED_BIN).as_string();
410 #endif 413 #endif
411 return base::WrapUnique(new ProfilePrefStoreManager( 414 return base::WrapUnique(new ProfilePrefStoreManager(
412 profile_path, GetTrackingConfiguration(), kTrackedPrefsReportingIDsCount, 415 profile_path, GetTrackingConfiguration(), kTrackedPrefsReportingIDsCount,
413 seed, device_id, g_browser_process->local_state())); 416 seed, device_id, g_browser_process->local_state()));
414 } 417 }
415 418
416 void PrepareFactory( 419 void PrepareFactory(syncable_prefs::PrefServiceSyncableFactory* factory,
417 syncable_prefs::PrefServiceSyncableFactory* factory, 420 const base::FilePath& pref_filename,
418 policy::PolicyService* policy_service, 421 policy::PolicyService* policy_service,
419 SupervisedUserSettingsService* supervised_user_settings, 422 SupervisedUserSettingsService* supervised_user_settings,
420 scoped_refptr<PersistentPrefStore> user_pref_store, 423 scoped_refptr<PersistentPrefStore> user_pref_store,
421 const scoped_refptr<PrefStore>& extension_prefs, 424 const scoped_refptr<PrefStore>& extension_prefs,
422 bool async) { 425 bool async) {
423 policy::BrowserPolicyConnector* policy_connector = 426 policy::BrowserPolicyConnector* policy_connector =
424 g_browser_process->browser_policy_connector(); 427 g_browser_process->browser_policy_connector();
425 factory->SetManagedPolicies(policy_service, policy_connector); 428 factory->SetManagedPolicies(policy_service, policy_connector);
426 factory->SetRecommendedPolicies(policy_service, policy_connector); 429 factory->SetRecommendedPolicies(policy_service, policy_connector);
427 430
428 #if defined(ENABLE_SUPERVISED_USERS) 431 #if defined(ENABLE_SUPERVISED_USERS)
429 if (supervised_user_settings) { 432 if (supervised_user_settings) {
430 scoped_refptr<PrefStore> supervised_user_prefs = make_scoped_refptr( 433 scoped_refptr<PrefStore> supervised_user_prefs = make_scoped_refptr(
431 new SupervisedUserPrefStore(supervised_user_settings)); 434 new SupervisedUserPrefStore(supervised_user_settings));
432 DCHECK(async || supervised_user_prefs->IsInitializationComplete()); 435 DCHECK(async || supervised_user_prefs->IsInitializationComplete());
433 factory->set_supervised_user_prefs(supervised_user_prefs); 436 factory->set_supervised_user_prefs(supervised_user_prefs);
434 } 437 }
435 #endif 438 #endif
436 439
437 factory->set_async(async); 440 factory->set_async(async);
438 factory->set_extension_prefs(extension_prefs); 441 factory->set_extension_prefs(extension_prefs);
439 factory->set_command_line_prefs(make_scoped_refptr( 442 factory->set_command_line_prefs(make_scoped_refptr(
440 new CommandLinePrefStore(base::CommandLine::ForCurrentProcess()))); 443 new CommandLinePrefStore(base::CommandLine::ForCurrentProcess())));
441 factory->set_read_error_callback(base::Bind(&HandleReadError)); 444 factory->set_read_error_callback(base::Bind(&HandleReadError, pref_filename));
442 factory->set_user_prefs(user_pref_store); 445 factory->set_user_prefs(user_pref_store);
443 factory->SetPrefModelAssociatorClient( 446 factory->SetPrefModelAssociatorClient(
444 ChromePrefModelAssociatorClient::GetInstance()); 447 ChromePrefModelAssociatorClient::GetInstance());
445 } 448 }
446 449
447 } // namespace 450 } // namespace
448 451
449 namespace chrome_prefs { 452 namespace chrome_prefs {
450 453
451 namespace internals { 454 namespace internals {
(...skipping 10 matching lines...) Expand all
462 465
463 } // namespace internals 466 } // namespace internals
464 467
465 std::unique_ptr<PrefService> CreateLocalState( 468 std::unique_ptr<PrefService> CreateLocalState(
466 const base::FilePath& pref_filename, 469 const base::FilePath& pref_filename,
467 base::SequencedTaskRunner* pref_io_task_runner, 470 base::SequencedTaskRunner* pref_io_task_runner,
468 policy::PolicyService* policy_service, 471 policy::PolicyService* policy_service,
469 const scoped_refptr<PrefRegistry>& pref_registry, 472 const scoped_refptr<PrefRegistry>& pref_registry,
470 bool async) { 473 bool async) {
471 syncable_prefs::PrefServiceSyncableFactory factory; 474 syncable_prefs::PrefServiceSyncableFactory factory;
472 PrepareFactory(&factory, policy_service, 475 PrepareFactory(&factory, pref_filename, policy_service,
473 NULL, // supervised_user_settings 476 NULL, // supervised_user_settings
474 new JsonPrefStore(pref_filename, pref_io_task_runner, 477 new JsonPrefStore(pref_filename, pref_io_task_runner,
475 std::unique_ptr<PrefFilter>()), 478 std::unique_ptr<PrefFilter>()),
476 NULL, // extension_prefs 479 NULL, // extension_prefs
477 async); 480 async);
478 return factory.Create(pref_registry.get()); 481 return factory.Create(pref_registry.get());
479 } 482 }
480 483
481 std::unique_ptr<syncable_prefs::PrefServiceSyncable> CreateProfilePrefs( 484 std::unique_ptr<syncable_prefs::PrefServiceSyncable> CreateProfilePrefs(
482 const base::FilePath& profile_path, 485 const base::FilePath& profile_path,
(...skipping 16 matching lines...) Expand all
499 const base::Closure start_sync_flare_for_prefs = 502 const base::Closure start_sync_flare_for_prefs =
500 base::Bind(sync_start_util::GetFlareForSyncableService(profile_path), 503 base::Bind(sync_start_util::GetFlareForSyncableService(profile_path),
501 syncer::PREFERENCES); 504 syncer::PREFERENCES);
502 505
503 syncable_prefs::PrefServiceSyncableFactory factory; 506 syncable_prefs::PrefServiceSyncableFactory factory;
504 scoped_refptr<PersistentPrefStore> user_pref_store( 507 scoped_refptr<PersistentPrefStore> user_pref_store(
505 CreateProfilePrefStoreManager(profile_path) 508 CreateProfilePrefStoreManager(profile_path)
506 ->CreateProfilePrefStore(pref_io_task_runner, 509 ->CreateProfilePrefStore(pref_io_task_runner,
507 start_sync_flare_for_prefs, 510 start_sync_flare_for_prefs,
508 validation_delegate)); 511 validation_delegate));
509 PrepareFactory(&factory, 512 PrepareFactory(&factory, profile_path, policy_service,
510 policy_service, 513 supervised_user_settings, user_pref_store, extension_prefs,
511 supervised_user_settings,
512 user_pref_store,
513 extension_prefs,
514 async); 514 async);
515 std::unique_ptr<syncable_prefs::PrefServiceSyncable> pref_service = 515 std::unique_ptr<syncable_prefs::PrefServiceSyncable> pref_service =
516 factory.CreateSyncable(pref_registry.get()); 516 factory.CreateSyncable(pref_registry.get());
517 517
518 ConfigureDefaultSearchPrefMigrationToDictionaryValue(pref_service.get()); 518 ConfigureDefaultSearchPrefMigrationToDictionaryValue(pref_service.get());
519 519
520 return pref_service; 520 return pref_service;
521 } 521 }
522 522
523 void DisableDomainCheckForTesting() { 523 void DisableDomainCheckForTesting() {
(...skipping 15 matching lines...) Expand all
539 539
540 void ClearResetTime(Profile* profile) { 540 void ClearResetTime(Profile* profile) {
541 ProfilePrefStoreManager::ClearResetTime(profile->GetPrefs()); 541 ProfilePrefStoreManager::ClearResetTime(profile->GetPrefs());
542 } 542 }
543 543
544 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { 544 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
545 ProfilePrefStoreManager::RegisterProfilePrefs(registry); 545 ProfilePrefStoreManager::RegisterProfilePrefs(registry);
546 } 546 }
547 547
548 } // namespace chrome_prefs 548 } // namespace chrome_prefs
OLDNEW
« no previous file with comments | « chrome/browser/history/chrome_history_client.cc ('k') | chrome/browser/ui/android/simple_message_box_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698