• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2013 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_SHARED_BROWSER_CLIENT_APP_BROWSER_H_
6 #define CEF_TESTS_SHARED_BROWSER_CLIENT_APP_BROWSER_H_
7 #pragma once
8 
9 #include <set>
10 
11 #include "tests/shared/common/client_app.h"
12 
13 namespace client {
14 
15 // Client app implementation for the browser process.
16 class ClientAppBrowser : public ClientApp, public CefBrowserProcessHandler {
17  public:
18   // Interface for browser delegates. All Delegates must be returned via
19   // CreateDelegates. Do not perform work in the Delegate
20   // constructor. See CefBrowserProcessHandler for documentation.
21   class Delegate : public virtual CefBaseRefCounted {
22    public:
OnBeforeCommandLineProcessing(CefRefPtr<ClientAppBrowser> app,CefRefPtr<CefCommandLine> command_line)23     virtual void OnBeforeCommandLineProcessing(
24         CefRefPtr<ClientAppBrowser> app,
25         CefRefPtr<CefCommandLine> command_line) {}
26 
OnContextInitialized(CefRefPtr<ClientAppBrowser> app)27     virtual void OnContextInitialized(CefRefPtr<ClientAppBrowser> app) {}
28 
OnBeforeChildProcessLaunch(CefRefPtr<ClientAppBrowser> app,CefRefPtr<CefCommandLine> command_line)29     virtual void OnBeforeChildProcessLaunch(
30         CefRefPtr<ClientAppBrowser> app,
31         CefRefPtr<CefCommandLine> command_line) {}
32   };
33 
34   typedef std::set<CefRefPtr<Delegate>> DelegateSet;
35 
36   ClientAppBrowser();
37 
38   // Called to populate |settings| based on |command_line| and other global
39   // state.
40   static void PopulateSettings(CefRefPtr<CefCommandLine> command_line,
41                                CefSettings& settings);
42 
43  private:
44   // Registers cookieable schemes. Implemented by cefclient in
45   // client_app_delegates_browser.cc
46   static void RegisterCookieableSchemes(
47       std::vector<std::string>& cookieable_schemes);
48 
49   // Creates all of the Delegate objects. Implemented by cefclient in
50   // client_app_delegates_browser.cc
51   static void CreateDelegates(DelegateSet& delegates);
52 
53   // CefApp methods.
54   void OnBeforeCommandLineProcessing(
55       const CefString& process_type,
56       CefRefPtr<CefCommandLine> command_line) override;
GetBrowserProcessHandler()57   CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
58     return this;
59   }
60 
61   // CefBrowserProcessHandler methods.
62   void OnContextInitialized() override;
63   void OnBeforeChildProcessLaunch(
64       CefRefPtr<CefCommandLine> command_line) override;
65   void OnScheduleMessagePumpWork(int64 delay) override;
66 
67   // Set of supported Delegates.
68   DelegateSet delegates_;
69 
70   IMPLEMENT_REFCOUNTING(ClientAppBrowser);
71   DISALLOW_COPY_AND_ASSIGN(ClientAppBrowser);
72 };
73 
74 }  // namespace client
75 
76 #endif  // CEF_TESTS_SHARED_BROWSER_CLIENT_APP_BROWSER_H_
77