#include "components/sync_bookmarks/bookmark_specifics_conversions.h"
#include <string>
#include <string_view>
#include <unordered_set>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/hash/sha1.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "base/uuid.h"
#include "components/bookmarks/browser/bookmark_node.h"
#include "components/bookmarks/browser/bookmark_uuids.h"
#include "components/bookmarks/common/bookmark_metrics.h"
#include "components/favicon/core/favicon_service.h"
#include "components/sync/base/unique_position.h"
#include "components/sync/protocol/bookmark_specifics.pb.h"
#include "components/sync/protocol/entity_data.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync_bookmarks/bookmark_model_view.h"
#include "components/sync_bookmarks/switches.h"
#include "ui/gfx/favicon_size.h"
#include "url/gurl.h"
namespace sync_bookmarks {
namespace {
const int kLegacyCanonicalizedTitleLimitBytes = …;
const char* const kForbiddenTitles[] = …;
const int kMaxFaviconUrlSize = …;
enum class InvalidBookmarkSpecificsError { … };
void LogInvalidSpecifics(InvalidBookmarkSpecificsError error) { … }
void LogFaviconContainedInSpecifics(bool contains_favicon) { … }
void UpdateBookmarkSpecificsMetaInfo(
const bookmarks::BookmarkNode::MetaInfoMap* metainfo_map,
sync_pb::BookmarkSpecifics* bm_specifics) { … }
bookmarks::BookmarkNode::MetaInfoMap GetBookmarkMetaInfo(
const sync_pb::BookmarkSpecifics& specifics) { … }
void SetBookmarkFaviconFromSpecifics(
const sync_pb::BookmarkSpecifics& specifics,
const bookmarks::BookmarkNode* bookmark_node,
favicon::FaviconService* favicon_service) { … }
std::string ComputeGuidFromBytes(base::span<const uint8_t> bytes) { … }
std::string InferGuidForLegacyBookmark(
const std::string& originator_cache_guid,
const std::string& originator_client_item_id) { … }
bool IsForbiddenTitleWithMaybeTrailingSpaces(const std::string& title) { … }
std::u16string NodeTitleFromSpecifics(
const sync_pb::BookmarkSpecifics& specifics) { … }
void MoveAllChildren(BookmarkModelView* model,
const bookmarks::BookmarkNode* old_parent,
const bookmarks::BookmarkNode* new_parent) { … }
}
std::string FullTitleToLegacyCanonicalizedTitle(const std::string& node_title) { … }
bool IsBookmarkEntityReuploadNeeded(
const syncer::EntityData& remote_entity_data) { … }
sync_pb::EntitySpecifics CreateSpecificsFromBookmarkNode(
const bookmarks::BookmarkNode* node,
BookmarkModelView* model,
const sync_pb::UniquePosition& unique_position,
bool force_favicon_load) { … }
const bookmarks::BookmarkNode* CreateBookmarkNodeFromSpecifics(
const sync_pb::BookmarkSpecifics& specifics,
const bookmarks::BookmarkNode* parent,
size_t index,
BookmarkModelView* model,
favicon::FaviconService* favicon_service) { … }
void UpdateBookmarkNodeFromSpecifics(
const sync_pb::BookmarkSpecifics& specifics,
const bookmarks::BookmarkNode* node,
BookmarkModelView* model,
favicon::FaviconService* favicon_service) { … }
sync_pb::BookmarkSpecifics::Type GetProtoTypeFromBookmarkNode(
const bookmarks::BookmarkNode* node) { … }
const bookmarks::BookmarkNode* ReplaceBookmarkNodeUuid(
const bookmarks::BookmarkNode* node,
const base::Uuid& guid,
BookmarkModelView* model) { … }
bool IsValidBookmarkSpecifics(const sync_pb::BookmarkSpecifics& specifics) { … }
base::Uuid InferGuidFromLegacyOriginatorId(
const std::string& originator_cache_guid,
const std::string& originator_client_item_id) { … }
bool HasExpectedBookmarkGuid(const sync_pb::BookmarkSpecifics& specifics,
const syncer::ClientTagHash& client_tag_hash,
const std::string& originator_cache_guid,
const std::string& originator_client_item_id) { … }
}