summaryrefslogtreecommitdiffstats
path: root/chromium/content/browser/find_in_page_client.h
blob: a79c1a56d0ae759720df8fa28ee62cf38cf37483 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2018 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.

#ifndef CONTENT_BROWSER_FIND_IN_PAGE_CLIENT_H_
#define CONTENT_BROWSER_FIND_IN_PAGE_CLIENT_H_

#include "mojo/public/cpp/bindings/receiver.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h"

namespace content {

class RenderFrameHostImpl;
class FindRequestManager;

// Per-frame client of FindInPage, owned by FindRequestManager.
// Keeps track of the current match count for the frame.
class FindInPageClient final : public blink::mojom::FindInPageClient {
 public:
  FindInPageClient(FindRequestManager* find_request_manager,
                   RenderFrameHostImpl* rfh);

  ~FindInPageClient() override;

  void ActivateNearestFindResult(int request_id, const gfx::PointF& point);

  // Current number of matches for this frame.
  int number_of_matches() { return number_of_matches_; }

  // blink::mojom::FindInPageClient overrides

  void SetNumberOfMatches(int request_id,
                          unsigned int current_number_of_matches,
                          blink::mojom::FindMatchUpdateType update_type) final;

  void SetActiveMatch(int request_id,
                      const gfx::Rect& active_match_rect,
                      int active_match_ordinal,
                      blink::mojom::FindMatchUpdateType update_type) final;

 private:
  void HandleUpdateType(int request_id,
                        blink::mojom::FindMatchUpdateType update_type);
  RenderFrameHostImpl* const frame_;
  FindRequestManager* const find_request_manager_;
  mojo::Receiver<blink::mojom::FindInPageClient> receiver_{this};
  int number_of_matches_ = 0;

  DISALLOW_COPY_AND_ASSIGN(FindInPageClient);
};

}  // namespace content

#endif  // CONTENT_BROWSER_FIND_IN_PAGE_CLIENT_H_