• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #ifndef CEF_TESTS_CEFTESTS_ROUTING_TEST_HANDLER_H_
6 #define CEF_TESTS_CEFTESTS_ROUTING_TEST_HANDLER_H_
7 #pragma once
8 
9 #include "include/wrapper/cef_message_router.h"
10 #include "tests/ceftests/test_handler.h"
11 
12 // Extends TestHandler to provide message routing functionality. The
13 // RoutingTestHandler implementation must be called from subclass
14 // overrides unless otherwise indicated.
15 class RoutingTestHandler : public TestHandler,
16                            public CefMessageRouterBrowserSide::Handler {
17  public:
18   RoutingTestHandler(CompletionState* completion_state = nullptr);
19 
20   void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
21   void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
22   void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
23                                  TerminationStatus status) override;
24 
25   // Only call this method if the navigation isn't canceled.
26   bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
27                       CefRefPtr<CefFrame> frame,
28                       CefRefPtr<CefRequest> request,
29                       bool user_gesture,
30                       bool is_redirect) override;
31 
32   // Returns true if the router handled the navigation.
33   bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
34                                 CefRefPtr<CefFrame> frame,
35                                 CefProcessId source_process,
36                                 CefRefPtr<CefProcessMessage> message) override;
37 
38  private:
39   CefRefPtr<CefMessageRouterBrowserSide> message_router_;
40 };
41 
42 #endif  // CEF_TESTS_CEFTESTS_ROUTING_TEST_HANDLER_H_
43