0
Files
android_webview
apps
ash
base
build
build_overrides
buildtools
cc
chrome
chromecast
chromeos
clank
codelabs
components
content
app
app_shim_remote_cocoa
browser
accessibility
aggregation_service
ai
android
attribution_reporting
audio
background_fetch
background_sync
blob_storage
bluetooth
broadcast_channel
browser_plugin
browsing_data
browsing_topics
buckets
cache_storage
client_hints
closewatcher
cocoa
code_cache
compositor
compute_pressure
contacts
content_index
cookie_deprecation_label
cookie_store
date_time_chooser
device
device_posture
device_sensors
devtools
direct_sockets
display_cutout
dom_storage
download
fenced_frame
file_system
file_system_access
first_party_sets
font_access
font_unique_name_lookup
generic_sensor
geolocation
gpu
handwriting
hid
hyphenation
idle
image_capture
indexed_db
installedapp
interest_group
keyboard_lock
loader
lock_screen
locks
manifest
media
media_session
memory
memory_pressure
metrics
navigation_transitions
network
notifications
origin_trials
payments
performance_manager
permissions
picture_in_picture
preloading
presentation
private_aggregation
process_internals
push_messaging
quota
reduce_accept_language
renderer_host
resources
scheduler
screen_details
screen_orientation
screenlock_monitor
security
serial
service_worker
shape_detection
shared_storage
smart_card
sms
speech
ssl
storage_access
system_dns_resolution
tracing
usb
wake_lock
web_contents
web_database
web_package
webauth
webid
webrtc
websockets
webtransport
webui
worker_host
xr
zygote_host
BACK_FORWARD_CACHE_OWNERS
BUILD.gn
CHILD_PROCESS_SECURITY_POLICY_OWNERS
DEPS
OWNERS
PRESUBMIT.py
README.md
about_url_loader_factory.cc
about_url_loader_factory.h
after_startup_task_utils.cc
after_startup_task_utils.h
agent_cluster_key.cc
agent_cluster_key.h
agent_cluster_key_unittest.cc
back_forward_cache_basics_browsertest.cc
back_forward_cache_browsertest.cc
back_forward_cache_browsertest.h
back_forward_cache_features_browsertest.cc
back_forward_cache_internal_browsertest.cc
back_forward_cache_network_request_browsertest.cc
back_forward_cache_no_store_browsertest.cc
back_forward_cache_not_restored_reasons_browsertest.cc
back_forward_cache_test_util.cc
back_forward_cache_test_util.h
bad_message.cc
bad_message.h
battery_monitor_browsertest.cc
bookmarklet_browsertest.cc
browser_child_process_host_impl.cc
browser_child_process_host_impl.h
browser_child_process_host_impl_receiver_bindings.cc
browser_child_process_observer_browsertest.cc
browser_context.cc
browser_context_impl.cc
browser_context_impl.h
browser_interface_binders.cc
browser_interface_binders.h
browser_interface_broker_impl.h
browser_main.cc
browser_main.h
browser_main_loop.cc
browser_main_loop.h
browser_main_loop_unittest.cc
browser_main_runner_impl.cc
browser_main_runner_impl.h
browser_process_io_thread.cc
browser_process_io_thread.h
browser_task_traits_nocompile.nc
browser_thread_browsertest.cc
browser_thread_impl.cc
browser_thread_impl.h
browser_thread_nocompile.nc
browser_thread_unittest.cc
browser_url_handler_impl.cc
browser_url_handler_impl.h
browser_url_handler_impl_unittest.cc
browsing_instance.cc
browsing_instance.h
byte_stream.cc
byte_stream.h
byte_stream_unittest.cc
can_commit_status.h
child_process_host_impl.cc
child_process_host_impl.h
child_process_launcher.cc
child_process_launcher.h
child_process_launcher_browsertest.cc
child_process_launcher_helper.cc
child_process_launcher_helper.h
child_process_launcher_helper_android.cc
child_process_launcher_helper_fuchsia.cc
child_process_launcher_helper_ios.mm
child_process_launcher_helper_linux.cc
child_process_launcher_helper_mac.cc
child_process_launcher_helper_posix.cc
child_process_launcher_helper_posix.h
child_process_launcher_helper_win.cc
child_process_security_policy_browsertest.cc
child_process_security_policy_impl.cc
child_process_security_policy_impl.h
child_process_security_policy_unittest.cc
child_process_task_port_provider_mac.cc
child_process_task_port_provider_mac.h
child_process_task_port_provider_mac_unittest.cc
child_thread_type_switcher_linux.cc
child_thread_type_switcher_linux.h
content_security_policy_browsertest.cc
context_factory.cc
cross_site_transfer_browsertest.cc
data_decoder_browsertest.cc
data_url_loader_factory.cc
data_url_loader_factory.h
database_browsertest.cc
do_not_track_browsertest.cc
eye_dropper_chooser_impl.cc
eye_dropper_chooser_impl.h
feature_observer.cc
feature_observer.h
field_trial_recorder.cc
field_trial_recorder.h
field_trial_synchronizer.cc
field_trial_synchronizer.h
find_in_page_client.cc
find_in_page_client.h
find_request_manager.cc
find_request_manager.h
find_request_manager_browsertest.cc
font_list_async.cc
font_preferences_browsertest.cc
font_service.cc
font_service.h
form_controls_browsertest.cc
framebusting_browsertest.cc
host_zoom_level_context.cc
host_zoom_level_context.h
host_zoom_map_impl.cc
host_zoom_map_impl.h
host_zoom_map_impl_browsertest.cc
host_zoom_map_impl_unittest.cc
in_memory_federated_permission_context.cc
in_memory_federated_permission_context.h
isolated_origin_browsertest.cc
isolated_origin_util.cc
isolated_origin_util.h
isolation_context.cc
isolation_context.h
keyboard_lock_browsertest.cc
keyboard_lock_browsertest.h
keyboard_lock_browsertest_ios.mm
keyboard_lock_browsertest_mac.mm
largest_contentful_paint_browsertests.cc
launch_as_mojo_client_browsertest.cc
log_console_message.cc
log_console_message.h
message_port_close_event_browsertest.cc
message_port_provider.cc
message_port_provider_browsertest.cc
mime_registry_impl.cc
mime_registry_impl.h
mojo_binder_policy_applier.cc
mojo_binder_policy_applier.h
mojo_binder_policy_applier_unittest.cc
mojo_binder_policy_map_impl.cc
mojo_binder_policy_map_impl.h
mojo_binder_policy_map_impl_unittest.cc
mojo_sandbox_browsertest.cc
native_profiling.pdl
navigation_browsertest.cc
navigation_mhtml_browsertest.cc
navigation_or_document_handle.cc
navigation_or_document_handle.h
navigation_subresource_loader_params.cc
navigation_subresource_loader_params.h
net_info_browsertest.cc
network_context_client_base_impl.cc
network_context_client_base_impl.h
network_context_client_base_impl_unittest.cc
network_sandbox.cc
network_sandbox.h
network_sandbox_grant_result.h
network_service_browsertest.cc
network_service_client.cc
network_service_client.h
network_service_instance_impl.cc
network_service_instance_impl.h
network_service_instance_impl_unittest.cc
network_service_restart_browsertest.cc
origin_agent_cluster_isolation_state.cc
origin_agent_cluster_isolation_state.h
per_web_ui_browser_interface_broker.cc
performance_memory_browsertest.cc
performance_timeline_browsertest.cc
plugin_list.cc
plugin_list.h
plugin_list_unittest.cc
plugin_service_impl.cc
plugin_service_impl.h
plugin_service_impl_browsertest.cc
pointer_lock_browsertest.cc
pointer_lock_browsertest.h
pointer_lock_browsertest_ios.mm
pointer_lock_browsertest_mac.mm
posix_file_descriptor_info_impl.cc
posix_file_descriptor_info_impl.h
posix_file_descriptor_info_impl_unittest.cc
power_monitor_browsertest.cc
ppapi_plugin_process_host.cc
ppapi_plugin_process_host.h
ppapi_plugin_process_host_receiver_bindings.cc
ppapi_plugin_sandboxed_process_launcher_delegate.cc
ppapi_plugin_sandboxed_process_launcher_delegate.h
process_lock.cc
process_lock.h
process_reuse_policy.h
process_visibility_util.cc
profiling_utils.cc
resource_context_impl.cc
resource_context_impl.h
resource_coordinator_service.cc
resource_loading_browsertest.cc
sandbox_host_linux.cc
sandbox_host_linux.h
sandbox_ipc_linux.cc
sandbox_ipc_linux.h
sandbox_mac_unittest.mm
sandbox_parameters_mac.h
sandbox_parameters_mac.mm
sandbox_support_mac_impl.h
sandbox_support_mac_impl.mm
scoped_active_url.cc
scoped_active_url.h
security_exploit_browsertest.cc
service_process_host_browsertest.cc
service_process_host_impl.cc
session_history_browsertest.cc
shareable_file_reference_unittest.cc
site_info.cc
site_info.h
site_instance_group.cc
site_instance_group.h
site_instance_group_browsertest.cc
site_instance_group_manager.cc
site_instance_group_manager.h
site_instance_group_unittest.cc
site_instance_impl.cc
site_instance_impl.h
site_instance_impl_unittest.cc
site_isolation_policy_unittest.cc
site_per_process_browsertest.cc
site_per_process_browsertest.h
site_per_process_hit_test_browsertest.cc
site_per_process_layout_browsertest.cc
site_per_process_mac_browsertest.mm
site_per_process_mixed_content_browsertest.cc
site_per_process_oopsif_browsertest.cc
site_per_process_sad_frame_browsertest.cc
site_per_process_scroll_browsertest.cc
site_per_process_unload_browsertest.cc
snapshot_browsertest.cc
ssl_private_key_impl.cc
ssl_private_key_impl.h
startup_data_impl.cc
startup_data_impl.h
startup_helper.cc
startup_helper.h
startup_task_runner.cc
startup_task_runner.h
startup_task_runner_unittest.cc
storage_partition_config_unittest.cc
storage_partition_impl.cc
storage_partition_impl.h
storage_partition_impl_browsertest.cc
storage_partition_impl_map.cc
storage_partition_impl_map.h
storage_partition_impl_map_unittest.cc
storage_partition_impl_unittest.cc
storage_service_restart_browsertest.cc
storage_service_sandbox_browsertest.cc
synthetic_trial_syncer.cc
text_fragment_browsertest.cc
theme_helper.cc
theme_helper.h
theme_helper_mac.h
theme_helper_mac.mm
ukm_internals_ui.cc
ukm_internals_ui.h
url_info.cc
url_info.h
url_loader_factory_params_helper.cc
url_loader_factory_params_helper.h
utility_process_host.cc
utility_process_host.h
utility_process_host_browsertest.cc
utility_process_host_receiver_bindings.cc
utility_process_sandbox_browsertest.cc
utility_sandbox_delegate.cc
utility_sandbox_delegate.h
utility_sandbox_delegate_unittest.cc
utility_sandbox_delegate_win.cc
v8_snapshot_files.cc
v8_snapshot_files.h
vibration_browsertest.cc
video_capture_service_impl.cc
video_capture_service_impl.h
web_exposed_isolation_info.cc
web_exposed_isolation_info.h
web_exposed_isolation_info_unittest.cc
web_ui_browser_interface_broker_registry.cc
webkit_browsertest.cc
worker_network_isolation_key_browsertest.cc
zoom_browsertest.cc
child
common
gpu
ppapi_plugin
public
renderer
services
shell
test
utility
web_test
zygote
BUILD.gn
DEPS
DIR_METADATA
OWNERS
README.md
architecture.png
content_resources.grd
crypto
dbus
device
docs
extensions
fuchsia_web
gin
google_apis
gpu
headless
infra
internal
ios
ios_internal
ipc
media
mojo
native_client
native_client_sdk
net
pdf
ppapi
printing
remoting
rlz
sandbox
services
signing_keys
skia
sql
storage
styleguide
testing
third_party
tools
ui
url
v8
webkit
.clang-format
.clang-tidy
.clangd
.git-blame-ignore-revs
.gitallowed
.gitattributes
.gitignore
.gitmodules
.gn
.mailmap
.rustfmt.toml
.vpython3
.yapfignore
ATL_OWNERS
AUTHORS
BUILD.gn
CODE_OF_CONDUCT.md
CPPLINT.cfg
CRYPTO_OWNERS
DEPS
DIR_METADATA
LICENSE
LICENSE.chromium_os
OWNERS
PRESUBMIT.py
PRESUBMIT_test.py
PRESUBMIT_test_mocks.py
README.md
WATCHLISTS
codereview.settings
src/content/browser/find_request_manager.h
Joey Arhar 525081b25b Remove histogram WebCore.FindInPage.DurationBetweenKeystrokes
This histogram isn't needed anymore now that we have shipped
auto-expanding details and hidden=until-found. This effectively reverts
crrev.com/924007

Fixed: 333390100
Bug: 40197893
Change-Id: I9f5c2773d9440676ce13e085114b59d1522d854a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5519293
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1297260}
2024-05-07 02:13:54 +00:00

385 lines
15 KiB
C++

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_
#define CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "base/cancelable_callback.h"
#include "base/containers/queue.h"
#include "base/functional/function_ref.h"
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/stop_find_action.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
namespace content {
class FindInPageClient;
class RenderFrameHost;
class RenderFrameHostImpl;
class WebContentsImpl;
// FindRequestManager manages all of the find-in-page requests/replies
// initiated/received through a WebContents. It coordinates searching across
// multiple (potentially out-of-process) frames, handles the aggregation of find
// results from each frame, and facilitates active match traversal. It is
// instantiated once per top-level WebContents, and is owned by that
// WebContents.
class FindRequestManager {
public:
explicit FindRequestManager(WebContentsImpl* web_contents);
FindRequestManager(const FindRequestManager&) = delete;
FindRequestManager& operator=(const FindRequestManager&) = delete;
~FindRequestManager();
// Initiates a find operation for |search_text| with the options specified in
// |options|. |request_id| uniquely identifies the find request.
void Find(int request_id,
const std::u16string& search_text,
blink::mojom::FindOptionsPtr options,
bool skip_delay = false);
// Stops the active find session and clears the general highlighting of the
// matches. |action| determines whether the last active match (if any) will be
// activated, cleared, or remain highlighted.
void StopFinding(StopFindAction action);
// Handles the final update from |rfh| for the find request with id
// |request_id|.
void HandleFinalUpdateForFrame(RenderFrameHostImpl* rfh, int request_id);
// The number of matches on |rfh| has changed from |old_count| to |new_count|.
// This method updates the total number of matches and also updates
// |active_match_ordinal_| accordingly.
void UpdatedFrameNumberOfMatches(RenderFrameHostImpl* rfh,
unsigned int old_count,
unsigned int new_count);
bool ShouldIgnoreReply(RenderFrameHostImpl* rfh, int request_id);
void SetActiveMatchRect(const gfx::Rect& active_match_rect);
void SetActiveMatchOrdinal(RenderFrameHostImpl* rfh,
int request_id,
int active_match_ordinal);
// Sends the find results (as they currently are) to the WebContents.
// |final_update| is true if we have received all of the updates from
// every frame for this request.
void NotifyFindReply(int request_id, bool final_update);
// Removes a frame from the set of frames being searched. This should be
// called whenever a frame is discovered to no longer exist.
void RemoveFrame(RenderFrameHost* rfh);
// Tells active frame to clear the active match highlighting.
void ClearActiveFindMatch();
// Runs the delayed find task if present. Returns true if there was a task
// which got run. Returns false if there was no delayed task.
bool CONTENT_EXPORT RunDelayedFindTaskForTesting();
#if BUILDFLAG(IS_ANDROID)
// Selects and zooms to the find result nearest to the point (x, y), defined
// in find-in-page coordinates.
void ActivateNearestFindResult(float x, float y);
// Called when a reply is received from a frame in response to the
// GetNearestFindResult mojo call.
void OnGetNearestFindResultReply(RenderFrameHostImpl* rfh,
int request_id,
float distance);
// Requests the rects of the current find matches from the renderer process.
void RequestFindMatchRects(int current_version);
// Called when a reply is received from a frame in response to a request for
// find match rects.
void OnFindMatchRectsReply(RenderFrameHost* rfh,
int version,
const std::vector<gfx::RectF>& rects,
const gfx::RectF& active_rect);
#endif
const std::unordered_set<raw_ptr<RenderFrameHost, CtnExperimental>>
render_frame_hosts_pending_initial_reply_for_testing() const {
return pending_initial_replies_;
}
gfx::Rect GetSelectionRectForTesting() { return selection_rect_; }
using CreateFindInPageClientFunction = std::unique_ptr<FindInPageClient> (*)(
FindRequestManager* find_request_manager,
RenderFrameHostImpl* rfh);
void SetCreateFindInPageClientFunctionForTesting(
CreateFindInPageClientFunction create_func) {
create_find_in_page_client_for_testing_ = create_func;
}
private:
friend class FindRequestManagerFencedFrameTest;
// An invalid ID. This value is invalid for any render process ID, render
// frame ID, find request ID, or find match rects version number.
static const int kInvalidId;
class FrameObserver;
// The request data for a single find request.
struct FindRequest {
// The find request ID that uniquely identifies this find request.
int id = kInvalidId;
// The text that is being searched for in this find request.
std::u16string search_text;
// The set of find options in effect for this find request.
blink::mojom::FindOptionsPtr options;
FindRequest();
FindRequest(int id,
const std::u16string& search_text,
blink::mojom::FindOptionsPtr options);
FindRequest(const FindRequest& request);
~FindRequest();
FindRequest& operator=(const FindRequest& request);
};
// Resets all of the per-session state for a new find-in-page session.
void Reset(const FindRequest& initial_request);
// Called internally as find requests come up in the queue.
void FindInternal(const FindRequest& request);
// Called when an informative response (a response with enough information to
// be able to route subsequent find requests) comes in for the find request
// with ID |request_id|. Advances the |find_request_queue_| if appropriate.
void AdvanceQueue(int request_id);
// Sends find request |request| through mojo to the RenderFrame associated
// with |rfh|.
void SendFindRequest(const FindRequest& request, RenderFrameHost* rfh);
// Returns the initial frame in search order. This will be either the first
// frame, if searching forward, or the last frame, if searching backward.
RenderFrameHost* GetInitialFrame(bool forward) const;
// Traverses the frame tree to find and return the next RenderFrameHost after
// |from_rfh| in search order. |forward| indicates whether the frame tree
// should be traversed forward (if true) or backward (if false). If
// |matches_only| is set, then the frame tree will be traversed until the
// first frame is found for which matches have been found. If |wrap| is set,
// then the traversal can wrap around past the last frame to the first one (or
// vice-versa, if |forward| == false). If no frame can be found under these
// conditions, nullptr is returned.
RenderFrameHost* Traverse(RenderFrameHost* from_rfh,
bool forward,
bool matches_only,
bool wrap) const;
// Adds a frame to the set of frames that are being searched. The new frame
// will automatically be searched when added, using the same options (stored
// in |current_request_.options|). |force| should be set to true when a
// dynamic content change is suspected, which will treat the frame as a newly
// added frame even if it has already been searched. This will force a
// re-search of the frame.
void AddFrame(RenderFrameHost* rfh, bool force);
// Returns whether |rfh| is in the set of frames being searched in the current
// find session.
CONTENT_EXPORT bool CheckFrame(RenderFrameHost* rfh) const;
// Computes and updates |active_match_ordinal_| based on |active_frame_| and
// |relative_active_match_ordinal_|.
void UpdateActiveMatchOrdinal();
// Called when all pending find replies have been received for the find
// request with ID |request_id|. The final update was received from |rfh|.
//
// Note that this is the final update for this particular find request, but
// not necessarily for all issued requests. If there are still pending replies
// expected for a previous find request, then the outgoing find reply issued
// from this function will not be marked final.
void FinalUpdateReceived(int request_id, RenderFrameHost* rfh);
std::unique_ptr<FindInPageClient> CreateFindInPageClient(
RenderFrameHostImpl* rfh);
// Traverses all RenderFrameHosts added for find-in-page and invokes the
// callback if the each RenderFrameHost is alive and active.
void ForEachAddedFindInPageRenderFrameHost(
base::FunctionRef<void(RenderFrameHostImpl*)> func_ref);
void EmitFindRequest(int request_id,
const std::u16string& search_text,
blink::mojom::FindOptionsPtr options);
#if BUILDFLAG(IS_ANDROID)
// Called when a nearest find result reply is no longer pending for a frame.
void RemoveNearestFindResultPendingReply(RenderFrameHost* rfh);
// Called when a find match rects reply is no longer pending for a frame.
void RemoveFindMatchRectsPendingReply(RenderFrameHost* rfh);
// State related to ActivateNearestFindResult requests.
struct ActivateNearestFindResultState {
// An ID to uniquely identify the current nearest find result request and
// its replies.
int current_request_id = kInvalidId;
// The value of the requested point, in find-in-page coordinates.
gfx::PointF point = gfx::PointF(0.0f, 0.0f);
float nearest_distance = FLT_MAX;
// The frame containing the nearest result found so far.
raw_ptr<RenderFrameHostImpl> nearest_frame = nullptr;
// Nearest find result replies are still pending for these frames.
std::unordered_set<raw_ptr<RenderFrameHost, CtnExperimental>>
pending_replies;
ActivateNearestFindResultState();
ActivateNearestFindResultState(float x, float y);
~ActivateNearestFindResultState();
static int GetNextID() {
static int next_id = 0;
return next_id++;
}
} activate_;
// Data for find match rects in a single frame.
struct FrameRects {
// The rects contained in a single frame.
std::vector<gfx::RectF> rects;
// The version number for these rects, as reported by their containing
// frame. This version is incremented independently in each frame.
int version = kInvalidId;
FrameRects();
FrameRects(const std::vector<gfx::RectF>& rects, int version);
~FrameRects();
};
// State related to FindMatchRects requests.
struct FindMatchRectsState {
// The latest find match rects version known by the requester. This will be
// compared to |known_version_| after polling frames for updates to their
// match rects, in order to determine if the requester already has the
// latest version of rects or not.
int request_version = kInvalidId;
// The current overall find match rects version known by
// FindRequestManager. This version should be incremented whenever
// |frame_rects| is updated.
int known_version = 0;
// A map from each frame to its find match rects.
std::unordered_map<RenderFrameHost*, FrameRects> frame_rects;
// The active find match rect.
gfx::RectF active_rect;
// Find match rects replies are still pending for these frames.
std::unordered_set<raw_ptr<RenderFrameHost, CtnExperimental>>
pending_replies;
FindMatchRectsState();
~FindMatchRectsState();
} match_rects_;
#endif
// The WebContents that owns this FindRequestManager. This also defines the
// scope of all find sessions. Only frames in |contents_| and any inner
// WebContentses within it will be searched.
const raw_ptr<WebContentsImpl> contents_;
// The request ID of the initial find request in the current find-in-page
// session, which uniquely identifies this session. Request IDs are included
// in all find-related IPCs, which allows reply IPCs containing results from
// previous sessions (with |request_id| < |current_session_id_|) to be easily
// identified and ignored.
int current_session_id_ = kInvalidId;
// The current find request.
FindRequest current_request_;
// The set of frames that are still expected to reply to a pending initial
// find request. Frames are removed from |pending_initial_replies_| when their
// reply to the initial find request is received with |final_update| set to
// true.
std::unordered_set<raw_ptr<RenderFrameHost, CtnExperimental>>
pending_initial_replies_;
// The frame (if any) that is still expected to reply to the last pending
// "find next" request.
raw_ptr<RenderFrameHost> pending_find_next_reply_ = nullptr;
// Indicates whether an update to the active match ordinal is expected. Once
// set, |pending_active_match_ordinal_| will not reset until an update to the
// active match ordinal is received in response to the find request with ID
// |current_request_.id| (the latest request).
bool pending_active_match_ordinal_ = false;
// The FindInPageClient associated with each frame. There will necessarily be
// entries in this map for every frame that is being (or has been) searched in
// the current find session, and no other frames.
std::unordered_map<RenderFrameHost*, std::unique_ptr<FindInPageClient>>
find_in_page_clients_;
// The total number of matches found in the current find-in-page session. This
// should always be equal to the sum of all the entries in
// |matches_per_frame_|.
int number_of_matches_ = 0;
// The frame containing the active match, if one exists, or nullptr otherwise.
raw_ptr<RenderFrameHostImpl> active_frame_ = nullptr;
// The active match ordinal relative to the matches found in its own frame.
int relative_active_match_ordinal_ = 0;
// The overall active match ordinal for the current find-in-page session.
int active_match_ordinal_ = 0;
// The rectangle around the active match, in screen coordinates.
gfx::Rect selection_rect_;
// Find requests are queued here when previous requests need to be handled
// before these ones can be properly routed.
base::queue<FindRequest> find_request_queue_;
// Keeps track of the find request ID of the last find reply reported via
// NotifyFindReply().
int last_reported_id_ = kInvalidId;
// WebContentsObservers to observe frame changes in |contents_| and its inner
// WebContentses.
std::vector<std::unique_ptr<FrameObserver>> frame_observers_;
base::CancelableOnceClosure delayed_find_task_;
CreateFindInPageClientFunction create_find_in_page_client_for_testing_ =
nullptr;
base::WeakPtrFactory<FindRequestManager> weak_factory_{this};
};
} // namespace content
#endif // CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_