chromium/components/bookmarks/browser/bookmark_model.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/bookmarks/browser/bookmark_model.h"

#include <algorithm>
#include <functional>
#include <memory>
#include <string>
#include <utility>

#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/i18n/string_compare.h"
#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/observer_list.h"
#include "base/strings/string_util.h"
#include "base/task/thread_pool.h"
#include "base/uuid.h"
#include "components/bookmarks/browser/bookmark_load_details.h"
#include "components/bookmarks/browser/bookmark_model_observer.h"
#include "components/bookmarks/browser/bookmark_node.h"
#include "components/bookmarks/browser/bookmark_node_data.h"
#include "components/bookmarks/browser/bookmark_storage.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/browser/bookmark_uuids.h"
#include "components/bookmarks/browser/model_loader.h"
#include "components/bookmarks/browser/scoped_group_bookmark_actions.h"
#include "components/bookmarks/browser/titled_url_index.h"
#include "components/bookmarks/browser/titled_url_match.h"
#include "components/bookmarks/browser/typed_count_sorter.h"
#include "components/bookmarks/browser/url_and_title.h"
#include "components/bookmarks/browser/url_index.h"
#include "components/bookmarks/common/bookmark_constants.h"
#include "components/bookmarks/common/bookmark_features.h"
#include "components/bookmarks/common/bookmark_metrics.h"
#include "components/favicon_base/favicon_types.h"
#include "components/strings/grit/components_strings.h"
#include "components/sync/base/features.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/favicon_size.h"

Time;

namespace bookmarks {

namespace {

bool AreFoldersForAccountStorageAllowed() {}

// Helper to get a mutable bookmark node.
BookmarkNode* AsMutable(const BookmarkNode* node) {}

// Traverses ancestors to find a permanent node or null in the rare case where
// the node has no ancestor permanent node. This can happen if `node` is the
// root node or because `node` is in the process of being deleted (i.e. removed
// from the indices), typically as a result of feature code reacting to
// BookmarkModelObserver::BookmarkNodeRemoved().
const BookmarkNode* GetSelfOrAncestorPermanentNode(const BookmarkNode* node) {}

// Comparator used when sorting permanent nodes. Nodes that are initially
// visible are sorted before nodes that are initially hidden.
class VisibilityComparator {};

// Comparator used when sorting bookmarks. Folders are sorted first, then
// bookmarks.
class SortComparator {};

}  // namespace

// BookmarkModel --------------------------------------------------------------

BookmarkModel::BookmarkModel(std::unique_ptr<BookmarkClient> client)
    :{}

BookmarkModel::~BookmarkModel() {}

void BookmarkModel::Load(const base::FilePath& profile_path) {}

scoped_refptr<ModelLoader> BookmarkModel::model_loader() {}

const BookmarkNode* BookmarkModel::account_bookmark_bar_node() const {}

const BookmarkNode* BookmarkModel::account_other_node() const {}

const BookmarkNode* BookmarkModel::account_mobile_node() const {}

bool BookmarkModel::IsLocalOnlyNode(const BookmarkNode& node) const {}

void BookmarkModel::AddObserver(BookmarkModelObserver* observer) {}

void BookmarkModel::RemoveObserver(BookmarkModelObserver* observer) {}

void BookmarkModel::BeginExtensiveChanges() {}

void BookmarkModel::EndExtensiveChanges() {}

void BookmarkModel::BeginGroupedChanges() {}

void BookmarkModel::EndGroupedChanges() {}

void BookmarkModel::Remove(const BookmarkNode* node,
                           metrics::BookmarkEditSource source,
                           const base::Location& location) {}

void BookmarkModel::RemoveAllUserBookmarks(const base::Location& location) {}

void BookmarkModel::Move(const BookmarkNode* node,
                         const BookmarkNode* new_parent,
                         size_t index) {}

void BookmarkModel::UpdateLastUsedTime(const BookmarkNode* node,
                                       const base::Time time,
                                       bool just_opened) {}

void BookmarkModel::UpdateLastUsedTimeImpl(const BookmarkNode* node,
                                           const base::Time time) {}

void BookmarkModel::ClearLastUsedTimeInRange(const base::Time delete_begin,
                                             const base::Time delete_end) {}

void BookmarkModel::ClearLastUsedTimeInRangeRecursive(
    BookmarkNode* node,
    const base::Time delete_begin,
    const base::Time delete_end) {}

void BookmarkModel::Copy(const BookmarkNode* node,
                         const BookmarkNode* new_parent,
                         size_t index) {}

const gfx::Image& BookmarkModel::GetFavicon(const BookmarkNode* node) {}

void BookmarkModel::SetTitle(const BookmarkNode* node,
                             const std::u16string& title,
                             metrics::BookmarkEditSource source) {}

void BookmarkModel::SetURL(const BookmarkNode* node,
                           const GURL& url,
                           metrics::BookmarkEditSource source) {}

void BookmarkModel::SetNodeMetaInfo(const BookmarkNode* node,
                                    const std::string& key,
                                    const std::string& value) {}

void BookmarkModel::SetNodeMetaInfoMap(
    const BookmarkNode* node,
    const BookmarkNode::MetaInfoMap& meta_info_map) {}

void BookmarkModel::DeleteNodeMetaInfo(const BookmarkNode* node,
                                       const std::string& key) {}

void BookmarkModel::OnFaviconsChanged(const std::set<GURL>& page_urls,
                                      const GURL& icon_url) {}

void BookmarkModel::SetDateAdded(const BookmarkNode* node, Time date_added) {}

std::vector<raw_ptr<const BookmarkNode, VectorExperimental>>
BookmarkModel::GetNodesByURL(const GURL& url) const {}

const BookmarkNode* BookmarkModel::GetNodeByUuid(
    const base::Uuid& uuid,
    NodeTypeForUuidLookup type) const {}

const BookmarkNode* BookmarkModel::GetMostRecentlyAddedUserNodeForURL(
    const GURL& url) const {}

bool BookmarkModel::HasBookmarks() const {}

bool BookmarkModel::HasNoUserCreatedBookmarksOrFolders() const {}

bool BookmarkModel::IsBookmarked(const GURL& url) const {}

std::vector<UrlAndTitle> BookmarkModel::GetUniqueUrls() const {}

metrics::BookmarkFolderTypeForUMA BookmarkModel::GetFolderType(
    const BookmarkNode* folder) const {}

const BookmarkNode* BookmarkModel::AddFolder(
    const BookmarkNode* parent,
    size_t index,
    const std::u16string& title,
    const BookmarkNode::MetaInfoMap* meta_info,
    std::optional<base::Time> creation_time,
    std::optional<base::Uuid> uuid) {}

const BookmarkNode* BookmarkModel::AddNewURL(
    const BookmarkNode* parent,
    size_t index,
    const std::u16string& title,
    const GURL& url,
    const BookmarkNode::MetaInfoMap* meta_info) {}

const BookmarkNode* BookmarkModel::AddURL(
    const BookmarkNode* parent,
    size_t index,
    const std::u16string& title,
    const GURL& url,
    const BookmarkNode::MetaInfoMap* meta_info,
    std::optional<base::Time> creation_time,
    std::optional<base::Uuid> uuid,
    bool added_by_user) {}

void BookmarkModel::SortChildren(const BookmarkNode* parent) {}

void BookmarkModel::ReorderChildren(
    const BookmarkNode* parent,
    const std::vector<const BookmarkNode*>& ordered_nodes) {}

void BookmarkModel::SetDateFolderModified(const BookmarkNode* parent,
                                          const Time time) {}

void BookmarkModel::ResetDateFolderModified(const BookmarkNode* node) {}

std::vector<TitledUrlMatch> BookmarkModel::GetBookmarksMatching(
    const std::u16string& query,
    size_t max_count_hint,
    query_parser::MatchingAlgorithm matching_algorithm) const {}

void BookmarkModel::DisableWritesToDiskForTest() {}

void BookmarkModel::LoadEmptyForTest() {}

void BookmarkModel::CommitPendingWriteForTest() {}

bool BookmarkModel::LocalOrSyncableStorageHasPendingWriteForTest() const {}

bool BookmarkModel::AccountStorageHasPendingWriteForTest() const {}

void BookmarkModel::RestoreRemovedNode(const BookmarkNode* parent,
                                       size_t index,
                                       std::unique_ptr<BookmarkNode> node) {}

BookmarkModel::NodeTypeForUuidLookup
BookmarkModel::DetermineTypeForUuidLookupForExistingNode(
    const BookmarkNode* node) const {}

void BookmarkModel::NotifyNodeAddedForAllDescendants(const BookmarkNode* node,
                                                     bool added_by_user) {}

void BookmarkModel::DoneLoading(std::unique_ptr<BookmarkLoadDetails> details) {}

BookmarkNode* BookmarkModel::AddNode(
    BookmarkNode* parent,
    size_t index,
    std::unique_ptr<BookmarkNode> node,
    bool added_by_user,
    NodeTypeForUuidLookup type_for_uuid_lookup) {}

void BookmarkModel::AddNodeToIndicesRecursive(
    const BookmarkNode* node,
    NodeTypeForUuidLookup type_for_uuid_lookup) {}

std::unique_ptr<BookmarkNode> BookmarkModel::RemoveNode(
    const BookmarkNode* node,
    const base::Location& location) {}

void BookmarkModel::RemoveNodeFromIndicesRecursive(
    BookmarkNode* node,
    NodeTypeForUuidLookup type_for_uuid_lookup) {}

bool BookmarkModel::IsValidIndex(const BookmarkNode* parent,
                                 size_t index,
                                 bool allow_end) {}

void BookmarkModel::OnFaviconDataAvailable(
    BookmarkNode* node,
    const favicon_base::FaviconImageResult& image_result) {}

void BookmarkModel::LoadFavicon(BookmarkNode* node) {}

void BookmarkModel::FaviconLoaded(const BookmarkNode* node) {}

void BookmarkModel::CancelPendingFaviconLoadRequests(BookmarkNode* node) {}

int64_t BookmarkModel::generate_next_node_id() {}

void BookmarkModel::CreateAccountPermanentFolders() {}

void BookmarkModel::RemoveAccountPermanentFolders() {}

void BookmarkModel::ScheduleSaveForNode(const BookmarkNode* node) {}

BookmarkStorage* BookmarkModel::GetStorageForNode(const BookmarkNode* node) {}

metrics::StorageStateForUma BookmarkModel::GetStorageStateForUma(
    const BookmarkNode* node) const {}

}  // namespace bookmarks