chromium/chrome/renderer/searchbox/searchbox.cc

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

#include "chrome/renderer/searchbox/searchbox.h"

#include <stddef.h>
#include <stdint.h>

#include <string_view>
#include <utility>

#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/token.h"
#include "base/types/optional_util.h"
#include "chrome/common/search/search.mojom.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/renderer/searchbox/searchbox_extension.h"
#include "components/favicon_base/favicon_types.h"
#include "components/favicon_base/favicon_url_parser.h"
#include "components/url_formatter/url_fixer.h"
#include "content/public/renderer/render_frame.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/web/web_frame.h"
#include "third_party/blink/public/web/web_local_frame.h"

namespace {

// The size of the InstantMostVisitedItem cache.
const size_t kMaxInstantMostVisitedItemCacheSize =;

// Returns true if items stored in |old_item_id_pairs| and |new_items| are
// equal.
bool AreMostVisitedItemsEqual(
    const std::vector<InstantMostVisitedItemIDPair>& old_item_id_pairs,
    const std::vector<InstantMostVisitedItem>& new_items) {}

// Helper for SearchBox::GenerateImageURLFromTransientURL().
class SearchBoxIconURLHelper: public SearchBox::IconURLHelper {};

SearchBoxIconURLHelper::SearchBoxIconURLHelper(const SearchBox* search_box)
    :{}

SearchBoxIconURLHelper::~SearchBoxIconURLHelper() {}

std::string SearchBoxIconURLHelper::GetMainFrameToken() const {}

std::string SearchBoxIconURLHelper::GetURLStringFromRestrictedID(
    InstantRestrictedID rid) const {}

}  // namespace

namespace internal {  // for testing

// Parses "<frame_token>/<restricted_id>". If successful, assigns
// |*frame_token| := "<frame_token>", |*rid| := "<restricted_id>", and returns
// true.
bool ParseFrameTokenAndRestrictedId(const std::string& id_part,
                                    std::string* frame_token_out,
                                    InstantRestrictedID* rid_out) {}

// Takes a favicon |url| that looks like:
//
//   chrome-search://favicon/<frame_token>/<restricted_id>
//   chrome-search://favicon/<parameters>/<frame_token>/<restricted_id>
//
// If successful, assigns |*param_part| := "" or "<parameters>/" (note trailing
// slash), |*frame_id| := "<frame_id>", |*rid| := "rid", and returns true.
bool ParseIconRestrictedUrl(const GURL& url,
                            std::string* param_part,
                            std::string* frame_token,
                            InstantRestrictedID* rid) {}

void TranslateIconRestrictedUrl(const GURL& transient_url,
                                const SearchBox::IconURLHelper& helper,
                                GURL* url) {}

}  // namespace internal

SearchBox::IconURLHelper::IconURLHelper() = default;

SearchBox::IconURLHelper::~IconURLHelper() = default;

SearchBox::SearchBox(content::RenderFrame* render_frame)
    :{}

SearchBox::~SearchBox() = default;

void SearchBox::DeleteMostVisitedItem(
    InstantRestrictedID most_visited_item_id) {}

void SearchBox::GenerateImageURLFromTransientURL(const GURL& transient_url,
                                                 GURL* url) const {}

void SearchBox::GetMostVisitedItems(
    std::vector<InstantMostVisitedItemIDPair>* items) const {}

bool SearchBox::AreMostVisitedItemsAvailable() const {}

bool SearchBox::GetMostVisitedItemWithID(
    InstantRestrictedID most_visited_item_id,
    InstantMostVisitedItem* item) const {}

const NtpTheme* SearchBox::GetNtpTheme() const {}

void SearchBox::StartCapturingKeyStrokes() {}

void SearchBox::StopCapturingKeyStrokes() {}

void SearchBox::UndoAllMostVisitedDeletions() {}

void SearchBox::UndoMostVisitedDeletion(
    InstantRestrictedID most_visited_item_id) {}

void SearchBox::SetPageSequenceNumber(int page_seq_no) {}

void SearchBox::FocusChanged(OmniboxFocusState new_focus_state,
                             OmniboxFocusChangeReason reason) {}

void SearchBox::MostVisitedInfoChanged(
    const InstantMostVisitedInfo& most_visited_info) {}

void SearchBox::SetInputInProgress(bool is_input_in_progress) {}

void SearchBox::ThemeChanged(const NtpTheme& theme) {}

GURL SearchBox::GetURLForMostVisitedItem(InstantRestrictedID item_id) const {}

void SearchBox::DidCommitProvisionalLoad(ui::PageTransition transition) {}

void SearchBox::OnDestruct() {}