V2EX 09月17日 16:32
Chromium浏览器数据同步内部查看方法
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

Chromium内核的浏览器会同步大量用户数据,用户可以通过输入“chrome://sync-internals/”来查看详细的数据同步情况。这段地址会展示同步的各种细节,其中源代码头文件定义了更多的数据类型,包括企业版Chrome的一些特定数据。文章探讨了如何理解和利用这一功能来审视浏览器的同步机制。

🔑 **数据同步概览**: 用户可以通过访问`chrome://sync-internals/`来直观地了解Chromium浏览器中各类数据的同步状态。这个内部页面提供了详细的同步信息,使用户能够监控哪些数据正在被同步以及同步的进度。

💡 **数据类型与扩展**: 源代码的头文件中定义了比`chrome://sync-internals/`页面所展示的更多数据类型,其中一些是专属于企业版Chrome的数据。这表明同步机制支持广泛的数据种类,并可能根据不同的版本或部署环境有所差异。

🔍 **理解同步机制**: 了解`chrome://sync-internals/`提供的细节,有助于用户深入理解浏览器的数据同步原理和工作方式。这对于诊断同步问题、管理个人数据以及确保数据安全都具有重要意义。

chromium 内核的浏览器同步了很多数据。一般输入“chrome://sync-internals/”可以查看数据同步情况。
![]( )

源代码的头文件中定义了更多类型,有一些是企业版 chrome 的数据。那么如题,你怎么看?回复即答谢。

<br />// Copyright 2012 The Chromium Authors<br />// Use of this source code is governed by a BSD-style license that can be<br />// found in the LICENSE file.<br /><br />#ifndef COMPONENTS_SYNC_BASE_MODEL_TYPE_H_<br />#define COMPONENTS_SYNC_BASE_MODEL_TYPE_H_<br /><br />#include &lt;iosfwd&gt;<br />#include &lt;map&gt;<br />#include &lt;memory&gt;<br />#include &lt;string&gt;<br /><br />#include "base/containers/enum_set.h"<br />#include "base/values.h"<br /><br />namespace sync_pb {<br />class EntitySpecifics;<br />}<br /><br />namespace syncer {<br /><br />// Enumerate the various item subtypes that are supported by sync.<br />// Each sync object is expected to have an immutable object type.<br />// An object's type is inferred from the type of data it holds.<br />//<br />// A Java counterpart will be generated for this enum.<br />// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.sync<br />//<br />// |kModelTypeInfoMap| struct entries are in the same order as their definition<br />// in ModelType enum. When you make changes in ModelType enum, don't forget to<br />// update the |kModelTypeInfoMap| struct in <a href="http://model_type.cc" rel="nofollow noopener" target="_blank">model_type.cc</a> and also the<br />// SyncModelType histogram suffix in histograms.xml<br />enum ModelType {<br /> // Object type unknown. This may be used when:<br /> // a) The client received *valid* data from a data type which this version<br /> // is unaware of (only present in versions newer than this one, or present<br /> // in older versions but removed since).<br /> // b) The client received invalid data from the server due to some error.<br /> // c) A data object was just created, in which case this is a temporary state.<br /> UNSPECIFIED,<br /><br /> // ------------------------------------ Start of "real" model types.<br /> // The model types declared before here are somewhat special, as they<br /> // they do not correspond to any browser data model. The remaining types<br /> // are bona fide model types; all have a related browser data model and<br /> // can be represented in the protocol using a specific Message type in the<br /> // EntitySpecifics protocol buffer.<br /> //<br /> // A bookmark folder or a bookmark URL object.<br /> BOOKMARKS,<br /> FIRST_USER_MODEL_TYPE = BOOKMARKS, // Declared 2nd, for debugger prettiness.<br /> FIRST_REAL_MODEL_TYPE = FIRST_USER_MODEL_TYPE,<br /><br /> // A preference object, a.k.a. "Settings".<br /> PREFERENCES,<br /> // A password object.<br /> PASSWORDS,<br /> // An autofill_profile object, i.e. an address.<br /> AUTOFILL_PROFILE,<br /> // An autofill object, i.e. an autocomplete entry keyed to an HTML form field.<br /> AUTOFILL,<br /> // Credentials related to an autofill wallet instrument; aka the CVC/CVV code.<br /> AUTOFILL_WALLET_CREDENTIAL,<br /> // Credit cards and customer data from the user's account. These are read-only<br /> // on the client.<br /> AUTOFILL_WALLET_DATA,<br /> // Usage counts and last use dates for Wallet cards. This data is both<br /> // readable and writable.<br /> AUTOFILL_WALLET_METADATA,<br /> // Offers and rewards from the user's account. These are read-only on the<br /> // client side.<br /> AUTOFILL_WALLET_OFFER,<br /> // Autofill usage data of a payment method related to a specific merchant.<br /> AUTOFILL_WALLET_USAGE,<br /> // A theme object.<br /> THEMES,<br /> // An extension object.<br /> EXTENSIONS,<br /> // An object representing a custom search engine.<br /> SEARCH_ENGINES,<br /> // An object representing a browser session, e.g. an open tab. This is used<br /> // for "Open Tabs".<br /> SESSIONS,<br /> // An app object.<br /> APPS,<br /> // An app setting from the extension settings API.<br /> APP_SETTINGS,<br /> // An extension setting from the extension settings API.<br /> EXTENSION_SETTINGS,<br /> // History delete directives, used to propagate history deletions (e.g. based<br /> // on a time range).<br /> HISTORY_DELETE_DIRECTIVES,<br /> // Custom spelling dictionary entries.<br /> DICTIONARY,<br /> // Client-specific metadata, synced before other user types.<br /> DEVICE_INFO,<br /> // These preferences are synced before other user types and are never<br /> // encrypted.<br /> PRIORITY_PREFERENCES,<br /> // Supervised user settings. Cannot be encrypted.<br /> SUPERVISED_USER_SETTINGS,<br /> // App List items, used by the ChromeOS app launcher.<br /> APP_LIST,<br /> // ARC package items, i.e. Android apps on ChromeOS.<br /> ARC_PACKAGE,<br /> // Printer device information. ChromeOS only.<br /> PRINTERS,<br /> // Reading list items.<br /> READING_LIST,<br /> // Commit only user events.<br /> USER_EVENTS,<br /> // Commit only user consents.<br /> USER_CONSENTS,<br /> // Tabs sent between devices.<br /> SEND_TAB_TO_SELF,<br /> // Commit only security events.<br /> SECURITY_EVENTS,<br /> // Wi-Fi network configurations + credentials<br /> WIFI_CONFIGURATIONS,<br /> // A web app object.<br /> WEB_APPS,<br /> // A WebAPK object.<br /> WEB_APKS,<br /> // OS-specific preferences (a.k.a. "OS settings"). ChromeOS only.<br /> OS_PREFERENCES,<br /> // Synced before other user types. Never encrypted. ChromeOS only.<br /> OS_PRIORITY_PREFERENCES,<br /> // Commit only sharing message object.<br /> SHARING_MESSAGE,<br /> // A workspace desk saved by user. ChromeOS only.<br /> WORKSPACE_DESK,<br /> // Synced history. An entity roughly corresponds to a navigation.<br /> HISTORY,<br /> // Trusted Authorization Servers for printers. ChromeOS only.<br /> PRINTERS_AUTHORIZATION_SERVERS,<br /> // Contact information from the Google Address Storage.<br /> CONTACT_INFO,<br /> // A tab group saved by a user. Currently only supported on desktop platforms<br /> // (Linux, Mac, Windows, ChromeOS) and Android.<br /> SAVED_TAB_GROUP,<br /><br /> // Power bookmarks are features associated with bookmarks(i.e. notes, price<br /> // tracking). Their life cycle are synced with bookmarks.<br /> POWER_BOOKMARK,<br /><br /> // WebAuthn credentials, more commonly known as passkeys.<br /> WEBAUTHN_CREDENTIAL,<br /><br /> // Invitations for sending passwords. Outgoing invitation from one user will<br /> // become an incoming one for another.<br /> INCOMING_PASSWORD_SHARING_INVITATION,<br /> OUTGOING_PASSWORD_SHARING_INVITATION,<br /><br /> // Data related to tab group sharing.<br /> SHARED_TAB_GROUP_DATA,<br /><br /> // Special datatype to notify client about People Group changes. Read-only on<br /> // the client.<br /> COLLABORATION_GROUP,<br /><br /> // Origin-specific email addresses forwarded from the user's account.<br /> // Read-only on the client.<br /> PLUS_ADDRESS,<br /><br /> // Product comparison groups.<br /> PRODUCT_COMPARISON,<br /><br /> // Browser cookies, ChromeOS only.<br /> COOKIES,<br /><br /> // Settings for PLUS_ADDRESS forwarded from the user's account. Since the<br /> // settings originate from the user's account, this is not reusing any of the<br /> // standard syncable prefs.<br /> PLUS_ADDRESS_SETTING,<br /><br /> LAST_USER_MODEL_TYPE = PLUS_ADDRESS_SETTING,<br /><br /> // ---- Control Types ----<br /> // An object representing a set of Nigori keys.<br /> NIGORI,<br /> LAST_REAL_MODEL_TYPE = NIGORI,<br /><br /> // NEW ENTRIES MUST BE ADDED ABOVE THIS.<br /> LAST_ENTRY = LAST_REAL_MODEL_TYPE,<br />};<br /><br />using ModelTypeSet =<br /> base::EnumSet&lt;ModelType, FIRST_REAL_MODEL_TYPE, LAST_REAL_MODEL_TYPE&gt;;<br /><br />constexpr int GetNumModelTypes() {<br /> return static_cast&lt;int&gt;(ModelType::LAST_ENTRY) + 1;<br />}<br /><br />// A version of the ModelType enum for use in histograms. ModelType does not<br />// have stable values (e.g. new ones may be inserted in the middle), so it can't<br />// be recorded directly.<br />// Instead of using entries from this enum directly, you'll usually want to get<br />// them via ModelTypeHistogramValue(model_type).<br />// These values are persisted to logs. Entries should not be renumbered and<br />// numeric values should never be reused. When you add a new entry or when you<br />// deprecate an existing one, also update SyncModelTypes in enums.xml and<br />// SyncModelType suffix in histograms.xml.<br />// LINT.IfChange(SyncModelTypes)<br />enum class ModelTypeForHistograms {<br /> kUnspecified = 0,<br /> // kTopLevelFolder = 1,<br /> kBookmarks = 2,<br /> kPreferences = 3,<br /> kPasswords = 4,<br /> kAutofillProfile = 5,<br /> kAutofill = 6,<br /> kThemes = 7,<br /> // kDeprecatedTypedUrls = 8,<br /> kExtensions = 9,<br /> kSearchEngines = 10,<br /> kSessions = 11,<br /> kApps = 12,<br /> kAppSettings = 13,<br /> kExtensionSettings = 14,<br /> // kDeprecatedAppNotifications = 15,<br /> kHistoryDeleteDirectices = 16,<br /> kNigori = 17,<br /> kDeviceInfo = 18,<br /> // kDeprecatedExperiments = 19,<br /> // kDeprecatedSyncedNotifications = 20,<br /> kPriorityPreferences = 21,<br /> kDictionary = 22,<br /> // kFaviconImages = 23,<br /> // kFaviconTracking = 24,<br /> kProxyTabs = 25,<br /> kSupervisedUserSettings = 26,<br /> // kDeprecatedSupervisedUsers = 27,<br /> // kDeprecatedArticles = 28,<br /> kAppList = 29,<br /> // kDeprecatedSupervisedUserSharedSettings = 30,<br /> // kDeprecatedSyncedNotificationAppInfo = 31,<br /> // kDeprecatedWifiCredentials = 32,<br /> kDeprecatedSupervisedUserAllowlists = 33,<br /> kAutofillWalletData = 34,<br /> kAutofillWalletMetadata = 35,<br /> kArcPackage = 36,<br /> kPrinters = 37,<br /> kReadingList = 38,<br /> kUserEvents = 39,<br /> // kDeprecatedMountainShares = 40,<br /> kUserConsents = 41,<br /> kSendTabToSelf = 42,<br /> kSecurityEvents = 43,<br /> kWifiConfigurations = 44,<br /> kWebApps = 45,<br /> kOsPreferences = 46,<br /> kOsPriorityPreferences = 47,<br /> kSharingMessage = 48,<br /> kAutofillWalletOffer = 49,<br /> kWorkspaceDesk = 50,<br /> kHistory = 51,<br /> kPrintersAuthorizationServers = 52,<br /> kContactInfo = 53,<br /> kAutofillWalletUsage = 54,<br /> // kDeprecatedSegmentation = 55,<br /> kSavedTabGroups = 56,<br /> kPowerBookmark = 57,<br /> kWebAuthnCredentials = 58,<br /> kIncomingPasswordSharingInvitations = 59,<br /> kOutgoingPasswordSharingInvitations = 60,<br /> kAutofillWalletCredential = 61,<br /> kWebApks = 62,<br /> kSharedTabGroupData = 63,<br /> kCollaborationGroup = 64,<br /> kPlusAddresses = 65,<br /> kProductComparison = 66,<br /> kCookies = 67,<br /> kPlusAddressSettings = 68,<br /> kMaxValue = kPlusAddressSettings,<br />};<br />// LINT.ThenChange(/tools/metrics/histograms/metadata/sync/enums.xml:SyncModelTypes)<br /><br />// Used to mark the type of EntitySpecifics that has no actual data.<br />void AddDefaultFieldValue(ModelType type, sync_pb::EntitySpecifics* specifics);<br /><br />// Extract the model type from an EntitySpecifics field. ModelType is a<br />// local concept: the enum is not in the protocol.<br />ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics&amp; specifics);<br /><br />// Protocol types are those types that have actual protocol buffer<br />// representations. This is the same as the "real" model types, i.e. all types<br />// except UNSPECIFIED.<br />constexpr ModelTypeSet ProtocolTypes() {<br /> // Note that ModelTypeSet only covers the real types, not UNSPECIFIED.<br /> static_assert(!ModelTypeSet::All().Has(ModelType::UNSPECIFIED));<br /> return ModelTypeSet::All();<br />}<br /><br />// These are the normal user-controlled types. This is to distinguish from<br />// ControlTypes which are always enabled. Note that some of these share a<br />// preference flag, so not all of them are individually user-selectable.<br />constexpr ModelTypeSet UserTypes() {<br /> return ModelTypeSet::FromRange(FIRST_USER_MODEL_TYPE, LAST_USER_MODEL_TYPE);<br />}<br /><br />// User types which are not user-controlled.<br />constexpr ModelTypeSet AlwaysPreferredUserTypes() {<br /> return {DEVICE_INFO,<br /> USER_CONSENTS,<br /> PLUS_ADDRESS,<br /> PLUS_ADDRESS_SETTING,<br /> SECURITY_EVENTS,<br /> SEND_TAB_TO_SELF,<br /> SUPERVISED_USER_SETTINGS,<br /> SHARING_MESSAGE};<br />}<br /><br />// User types which are always encrypted.<br />constexpr ModelTypeSet AlwaysEncryptedUserTypes() {<br /> // If you add a new model type here that is conceptually different from a<br /> // password, make sure you audit UI code that refers to these types as<br /> // passwords, e.g. consumers of IsEncryptEverythingEnabled().<br /> return {AUTOFILL_WALLET_CREDENTIAL, PASSWORDS, WIFI_CONFIGURATIONS, COOKIES};<br />}<br /><br />// This is the subset of UserTypes() that have priority over other types. These<br />// types are synced before other user types (both for get_updates and commits).<br />// This mostly matters during initial sync, since priority types can become<br />// active before all the data for non-prio types has been downloaded (which may<br />// be a lot of data).<br />constexpr ModelTypeSet HighPriorityUserTypes() {<br /> return {<br /> // The "Send to Your Devices" feature needs fast updating of the list of<br /> // your devices and also fast sending of the actual messages.<br /> DEVICE_INFO, SHARING_MESSAGE,<br /> // For supervised users, it is important to quickly deliver changes in<br /> // settings and in allowed sites to the supervised user.<br /> SUPERVISED_USER_SETTINGS,<br /> // These are by definition preferences for which it is important that the<br /> // client picks them up quickly (also because these can get changed<br /> // server-side). For example, such a pref could control whether a<br /> // non-priority type gets enabled (Wallet has such a pref).<br /> PRIORITY_PREFERENCES, OS_PRIORITY_PREFERENCES,<br /> // Speed matters for the user experience when sync gets enabled directly<br /> // in the creation flow for a new profile. If the user has no theme in<br /> // their sync data, the browser offers a theme customization bubble which<br /> // should appear soon after opening the browser.<br /> THEMES};<br />}<br /><br />// This is the subset of UserTypes() that have a *lower* priority than other<br />// types. These types are synced only after all other user types (both for<br />// get_updates and commits). This mostly matters during initial sync, since<br />// high-priority and regular types can become active before all the data for<br />// low-priority types has been downloaded (which may be a lot of data).<br />constexpr ModelTypeSet LowPriorityUserTypes() {<br /> return {<br /> // Downloading History may take a while, but should not block the download<br /> // of other data types.<br /> HISTORY,<br /> // User Events should not block or delay commits for other data types.<br /> USER_EVENTS,<br /> // Incoming password sharing invitations must be processed after<br /> // Passwords data type to prevent storing incoming passwords locally first<br /> // and overwriting the remote password during conflict resolution.<br /> INCOMING_PASSWORD_SHARING_INVITATION};<br />}<br /><br />// Returns a list of all control types.<br />//<br />// The control types are intended to contain metadata nodes that are essential<br />// for the normal operation of the syncer. As such, they have the following<br />// special properties:<br />// - They are downloaded early during SyncBackend initialization.<br />// - They are always enabled. Users may not disable these types.<br />// - Their contents are not encrypted automatically.<br />// - They support custom update application and conflict resolution logic.<br />// - All change processing occurs on the sync thread.<br />constexpr ModelTypeSet ControlTypes() {<br /> return {NIGORI};<br />}<br /><br />// Types that may commit data, but should never be included in a GetUpdates.<br />// These are never encrypted.<br />constexpr ModelTypeSet CommitOnlyTypes() {<br /> return {USER_EVENTS, USER_CONSENTS, SECURITY_EVENTS, SHARING_MESSAGE,<br /> OUTGOING_PASSWORD_SHARING_INVITATION};<br />}<br /><br />// Types for which downloaded updates are applied immediately, before all<br />// updates are downloaded and the Sync cycle finishes.<br />// For these types, ModelTypeSyncBridge::MergeFullSyncData() will never be<br />// called (since without downloading all the data, no initial merge is<br />// possible).<br />constexpr ModelTypeSet ApplyUpdatesImmediatelyTypes() {<br /> return {HISTORY};<br />}<br /><br />// Types for whichcollaboration_idfield in SyncEntity should be provided.<br />// These types also supportgc_directivefor collaborations to track active<br />// collaboratons.<br />constexpr ModelTypeSet SharedTypes() {<br /> return {SHARED_TAB_GROUP_DATA};<br />}<br /><br />// Types triggering a warning when the user signs out and the types have<br />// unsynced data. The warning offers the user to either save the data locally or<br />// abort sign-out, depending on the platform.<br />constexpr ModelTypeSet TypesRequiringUnsyncedDataCheckOnSignout() {<br /> return {syncer::BOOKMARKS, syncer::CONTACT_INFO, syncer::PASSWORDS,<br /> syncer::READING_LIST, syncer::SAVED_TAB_GROUP};<br />}<br /><br />// User types that can be encrypted, which is a subset of UserTypes() and a<br />// superset of AlwaysEncryptedUserTypes();<br />ModelTypeSet EncryptableUserTypes();<br /><br />// Determine a model type from the field number of its associated<br />// EntitySpecifics field. Returns UNSPECIFIED if the field number is<br />// not recognized.<br />ModelType GetModelTypeFromSpecificsFieldNumber(int field_number);<br /><br />namespace internal {<br />// Obtain model type from field_number and add to model_types if valid.<br />void GetModelTypeSetFromSpecificsFieldNumberListHelper(<br /> ModelTypeSet&amp; model_types,<br /> int field_number);<br />} // namespace internal<br /><br />// Build a ModelTypeSet from a list of field numbers. Any unknown field numbers<br />// are ignored.<br />template &lt;typename ContainerT&gt;<br />ModelTypeSet GetModelTypeSetFromSpecificsFieldNumberList(<br /> const ContainerT&amp; field_numbers) {<br /> ModelTypeSet model_types;<br /> for (int field_number : field_numbers) {<br /> internal::GetModelTypeSetFromSpecificsFieldNumberListHelper(model_types,<br /> field_number);<br /> }<br /> return model_types;<br />}<br /><br />// Return the field number of the EntitySpecifics field associated with<br />// a model type.<br />int GetSpecificsFieldNumberFromModelType(ModelType model_type);<br /><br />// Returns a string with application lifetime that represents the name of<br />// |model_type|.<br />const char* ModelTypeToDebugString(ModelType model_type);<br /><br />// Returns a string with application lifetime that is used as the histogram<br />// suffix for |model_type|.<br />const char* ModelTypeToHistogramSuffix(ModelType model_type);<br /><br />// Some histograms take an integer parameter that represents a model type.<br />// The mapping from ModelType to integer is defined here. It defines a<br />// completely different order than the ModelType enum itself. The mapping should<br />// match the SyncModelTypes mapping from integer to labels defined in enums.xml.<br />ModelTypeForHistograms ModelTypeHistogramValue(ModelType model_type);<br /><br />// Returns for every model_type a positive unique integer that is stable over<br />// time and thus can be used when persisting data.<br />int ModelTypeToStableIdentifier(ModelType model_type);<br /><br />// Returns the comma-separated string representation of |model_types|.<br />std::string ModelTypeSetToDebugString(ModelTypeSet model_types);<br /><br />// Necessary for compatibility with EXPECT_EQ and the like.<br />std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out, ModelTypeSet model_type_set);<br /><br />// Returns a string corresponding to the root tag as exposed in the sync<br />// protocol as the root entity's ID, which makes the root entity trivially<br />// distinguishable from regular entities. Note that the existence of a root<br />// entity in the sync protocol is a legacy artifact, and modern clients ignore<br />// it except for bookmarks and Nigori. For this reason, the server may or may<br />// not return the root entity.<br />std::string ModelTypeToProtocolRootTag(ModelType model_type);<br /><br />// As opposed to ModelTypeToProtocolRootTag(), this returns a string that isn't<br />// exposed in the sync protocol, but that is still stable and thus can be used<br />// for local persistence. It is guaranteed to be lowercase.<br />const char* GetModelTypeLowerCaseRootTag(ModelType model_type);<br /><br />// Returns true if |model_type| is a real datatype<br />bool IsRealDataType(ModelType model_type);<br /><br />// Returns true if |model_type| is an act-once type. Act once types drop<br />// entities after applying them. Drops are deletes that are not synced to other<br />// clients.<br />bool IsActOnceDataType(ModelType model_type);<br /><br />} // namespace syncer<br /><br />#endif // COMPONENTS_SYNC_BASE_MODEL_TYPE_H_<br /><br />

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Chromium 浏览器同步 chrome://sync-internals/ 数据同步 技术揭秘
相关文章