1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_STARTUP_DATA_H_
6 #define CHROME_BROWSER_STARTUP_DATA_H_
10 #include "base/macros.h"
11 #include "base/memory/scoped_refptr.h"
12 #include "build/build_config.h"
13 #include "components/leveldb_proto/public/proto_database_provider.h"
15 namespace user_prefs {
16 class PrefRegistrySyncable;
20 class ProfilePolicyConnector;
21 class SchemaRegistryService;
22 class UserCloudPolicyManager;
25 namespace sync_preferences {
26 class PrefServiceSyncable;
31 class ChromeFeatureListCreator;
33 // The StartupData owns any pre-created objects in //chrome before the full
34 // browser starts, including the ChromeFeatureListCreator and the Profile's
35 // PrefService. See doc:
36 // https://docs.google.com/document/d/1ybmGWRWXu0aYNxA99IcHFesDAslIaO1KFP6eGdHTJaE/edit#heading=h.7bk05syrcom
42 // Records core profile settings into the SystemProfileProto. It is important
43 // when Chrome is running in the reduced mode, which doesn't start UMA
44 // recording but persists all of the UMA data into a memory mapped file. The
45 // file will be picked up by Chrome next time it is launched in the full
47 void RecordCoreSystemProfile();
49 #if defined(OS_ANDROID)
50 // Initializes all necessary parameters to create the Profile's PrefService.
51 void CreateProfilePrefService();
53 // Returns whether a PrefService has been created.
54 bool HasBuiltProfilePrefService();
56 ProfileKey* GetProfileKey();
58 // Passes ownership of the |key_| to the caller.
59 std::unique_ptr<ProfileKey> TakeProfileKey();
61 // Passes ownership of the |schema_registry_service_| to the caller.
62 std::unique_ptr<policy::SchemaRegistryService> TakeSchemaRegistryService();
64 // Passes ownership of the |user_cloud_policy_manager_| to the caller.
65 std::unique_ptr<policy::UserCloudPolicyManager> TakeUserCloudPolicyManager();
67 // Passes ownership of the |profile_policy_connector_| to the caller.
68 std::unique_ptr<policy::ProfilePolicyConnector> TakeProfilePolicyConnector();
70 // Passes ownership of the |pref_registry_| to the caller.
71 scoped_refptr<user_prefs::PrefRegistrySyncable> TakePrefRegistrySyncable();
73 // Passes ownership of the |prefs_| to the caller.
74 std::unique_ptr<sync_preferences::PrefServiceSyncable>
75 TakeProfilePrefService();
77 // Passes ownership of the |proto_db_provider_| to the caller.
78 std::unique_ptr<leveldb_proto::ProtoDatabaseProvider>
79 TakeProtoDatabaseProvider();
82 ChromeFeatureListCreator* chrome_feature_list_creator() {
83 return chrome_feature_list_creator_.get();
87 #if defined(OS_ANDROID)
88 void PreProfilePrefServiceInit();
89 void CreateServicesInternal();
91 std::unique_ptr<ProfileKey> key_;
93 std::unique_ptr<policy::SchemaRegistryService> schema_registry_service_;
94 std::unique_ptr<policy::UserCloudPolicyManager> user_cloud_policy_manager_;
95 std::unique_ptr<policy::ProfilePolicyConnector> profile_policy_connector_;
97 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry_;
99 std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs_;
101 std::unique_ptr<leveldb_proto::ProtoDatabaseProvider> proto_db_provider_;
104 std::unique_ptr<ChromeFeatureListCreator> chrome_feature_list_creator_;
106 DISALLOW_COPY_AND_ASSIGN(StartupData);
109 #endif // CHROME_BROWSER_STARTUP_DATA_H_