| Index: content/browser/find_request_manager.h
|
| diff --git a/content/browser/find_request_manager.h b/content/browser/find_request_manager.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a7ab990ceb67edbf5f50a90d7275c23b7b136cb9
|
| --- /dev/null
|
| +++ b/content/browser/find_request_manager.h
|
| @@ -0,0 +1,117 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +// FindRequestManager manages all of the find-in-page requests/replies
|
| +// initiated/received through a WebContents.
|
| +
|
| +#ifndef CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_
|
| +#define CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_
|
| +
|
| +#include <set>
|
| +#include <vector>
|
| +
|
| +#include "content/public/common/stop_find_action.h"
|
| +#include "third_party/WebKit/public/web/WebFindOptions.h"
|
| +#include "ui/gfx/geometry/rect.h"
|
| +#include "ui/gfx/geometry/rect_f.h"
|
| +
|
| +namespace content {
|
| +
|
| +class RenderFrameHost;
|
| +class WebContentsImpl;
|
| +
|
| +class FindRequestManager {
|
| + public:
|
| + explicit FindRequestManager(WebContentsImpl* web_contents);
|
| + ~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 base::string16& search_text,
|
| + const blink::WebFindOptions& options);
|
| +
|
| + // 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);
|
| +
|
| + // Called when a reply is received from a frame with the results from a
|
| + // find request.
|
| + void FindReply(RenderFrameHost* rfh,
|
| + int request_id,
|
| + int number_of_matches,
|
| + const gfx::Rect& selection_rect,
|
| + int active_match_ordinal,
|
| + bool final_update);
|
| +
|
| +#if defined(OS_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);
|
| +
|
| + // Requests the rects of the current find matches from the renderer process.
|
| + void RequestFindMatchRects(int current_version);
|
| +
|
| + // Called when a reply is received in response to a request for find match
|
| + // rects.
|
| + void FindMatchRectsReply(RenderFrameHost* rfh,
|
| + int version,
|
| + const std::vector<gfx::RectF>& rects,
|
| + const gfx::RectF& active_rect);
|
| +#endif
|
| +
|
| +private:
|
| + // Reset all of the per-session state for a new find-in-page session.
|
| + void Reset(int new_request_id, const base::string16& new_search_text);
|
| +
|
| + // Send a find IPC to the RenderFrame associated with |rfh| to begin a find
|
| + // operation with the search text |current_search_text_| and the find options
|
| + // in |current_find_options_|.
|
| + void SendFindIPC(int request_id, RenderFrameHost* rfh);
|
| +
|
| + // Send a stop finding IPC to the RenderFrame associated with
|
| + // |render_frame_host|.
|
| + void SendStopFindingIPC(StopFindAction action,
|
| + RenderFrameHost* rfh) const;
|
| +
|
| + // Send the find results (as they currently are) to the WebContents.
|
| + void SendFindReply(int request_id, bool final_update) const;
|
| +
|
| +#if defined(OS_ANDROID)
|
| + // Request the latest find match rects from a frame.
|
| + void SendFindMatchRectsIPC(RenderFrameHost* rfh);
|
| +
|
| + // The latest find match rects version known by the requester.
|
| + int fmr_request_version_;
|
| +#endif
|
| +
|
| + // The WebContents that owns this FindRequestManager.
|
| + WebContentsImpl* const contents_;
|
| +
|
| + // The find request ID that uniquely identifies this find-in-page session (The
|
| + // ID of the initial request of this session). Request IDs are included in all
|
| + // find-related IPCs, which allows IPCs containing results from previous
|
| + // sessions to be easily identified and ignored.
|
| + int current_request_id_;
|
| +
|
| + // The text that is being searched for in the current find-in-page session.
|
| + base::string16 current_search_text_;
|
| +
|
| + // The current set of find options in effect.
|
| + blink::WebFindOptions current_find_options_;
|
| +
|
| + // The total number of matches found in the current find-in-page session.
|
| + int number_of_matches_;
|
| +
|
| + // The overall active match ordinal for the current find-in-page session.
|
| + int active_match_ordinal_;
|
| +
|
| + // The rectangle around the active match, in screen coordinates.
|
| + gfx::Rect selection_rect_;
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_FIND_REQUEST_MANAGER_H_
|
|
|