Implement nacl_irt_memory for non-sfi mode.
[chromium-blink-merge.git] / chrome / test / base / find_in_page_observer.h
blobd6eae3c6babdf7f5f8e52c813bd4df06b91492c5
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_TEST_BASE_FIND_IN_PAGE_OBSERVER_H_
6 #define CHROME_TEST_BASE_FIND_IN_PAGE_OBSERVER_H_
8 #include "base/memory/ref_counted.h"
9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_registrar.h"
11 #include "ui/gfx/rect.h"
13 namespace content {
14 class MessageLoopRunner;
15 class WebContents;
18 namespace ui_test_utils {
20 // FindInPageNotificationObserver allows blocking UI thread until find results
21 // are available. Typical usage:
22 // FindInPageWchar();
23 // FindInPageNotificationObserver observer(tab);
24 // observer.Wait();
26 // Always construct FindInPageNotificationObserver AFTER initiating the search.
27 // It captures the current search ID in constructor and waits for it only.
28 class FindInPageNotificationObserver : public content::NotificationObserver {
29 public:
30 explicit FindInPageNotificationObserver(content::WebContents* parent_tab);
31 virtual ~FindInPageNotificationObserver();
33 void Wait();
35 int active_match_ordinal() const { return active_match_ordinal_; }
36 int number_of_matches() const { return number_of_matches_; }
37 gfx::Rect selection_rect() const { return selection_rect_; }
39 private:
40 virtual void Observe(int type,
41 const content::NotificationSource& source,
42 const content::NotificationDetails& details) OVERRIDE;
44 content::NotificationRegistrar registrar_;
45 // We will at some point (before final update) be notified of the ordinal and
46 // we need to preserve it so we can send it later.
47 int active_match_ordinal_;
48 int number_of_matches_;
49 gfx::Rect selection_rect_;
50 // The id of the current find request, obtained from WebContents. Allows us
51 // to monitor when the search completes.
52 int current_find_request_id_;
53 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
55 bool seen_; // true after transition to expected state has been seen
56 bool running_; // indicates whether message loop is running
58 DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver);
61 } // namespace ui_test_utils
63 #endif // CHROME_TEST_BASE_FIND_IN_PAGE_OBSERVER_H_