2015-01-31 05:41:36 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2016-11-18 00:52:42 +01:00
|
|
|
#ifndef CEF_TESTS_SHARED_BROWSER_CLIENT_APP_BROWSER_H_
|
|
|
|
#define CEF_TESTS_SHARED_BROWSER_CLIENT_APP_BROWSER_H_
|
2015-01-31 05:41:36 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/shared/common/client_app.h"
|
2015-01-31 05:41:36 +01:00
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
|
|
|
// Client app implementation for the browser process.
|
2017-05-17 11:29:28 +02:00
|
|
|
class ClientAppBrowser : public ClientApp, public CefBrowserProcessHandler {
|
2015-01-31 05:41:36 +01:00
|
|
|
public:
|
|
|
|
// Interface for browser delegates. All Delegates must be returned via
|
|
|
|
// CreateDelegates. Do not perform work in the Delegate
|
|
|
|
// constructor. See CefBrowserProcessHandler for documentation.
|
2017-02-09 23:07:43 +01:00
|
|
|
class Delegate : public virtual CefBaseRefCounted {
|
2015-01-31 05:41:36 +01:00
|
|
|
public:
|
2015-09-09 16:05:39 +02:00
|
|
|
virtual void OnBeforeCommandLineProcessing(
|
|
|
|
CefRefPtr<ClientAppBrowser> app,
|
|
|
|
CefRefPtr<CefCommandLine> command_line) {}
|
|
|
|
|
2022-10-26 00:50:29 +02:00
|
|
|
virtual void OnRegisterCustomPreferences(
|
|
|
|
CefRefPtr<ClientAppBrowser> app,
|
|
|
|
cef_preferences_type_t type,
|
|
|
|
CefRawPtr<CefPreferenceRegistrar> registrar) {}
|
|
|
|
|
2015-09-09 16:05:39 +02:00
|
|
|
virtual void OnContextInitialized(CefRefPtr<ClientAppBrowser> app) {}
|
2015-01-31 05:41:36 +01:00
|
|
|
|
2023-11-29 02:33:44 +01:00
|
|
|
virtual bool OnAlreadyRunningAppRelaunch(
|
2015-01-31 05:41:36 +01:00
|
|
|
CefRefPtr<ClientAppBrowser> app,
|
2023-11-29 02:33:44 +01:00
|
|
|
CefRefPtr<CefCommandLine> command_line,
|
|
|
|
const CefString& current_directory) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-02-17 21:55:12 +01:00
|
|
|
|
|
|
|
virtual CefRefPtr<CefClient> GetDefaultClient(
|
|
|
|
CefRefPtr<ClientAppBrowser> app) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-01-31 05:41:36 +01:00
|
|
|
};
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
typedef std::set<CefRefPtr<Delegate>> DelegateSet;
|
2015-01-31 05:41:36 +01:00
|
|
|
|
|
|
|
ClientAppBrowser();
|
|
|
|
|
2021-04-09 20:34:45 +02:00
|
|
|
// Called to populate |settings| based on |command_line| and other global
|
|
|
|
// state.
|
|
|
|
static void PopulateSettings(CefRefPtr<CefCommandLine> command_line,
|
|
|
|
CefSettings& settings);
|
|
|
|
|
2015-01-31 05:41:36 +01:00
|
|
|
private:
|
2021-04-09 20:34:45 +02:00
|
|
|
// Registers cookieable schemes. Implemented by cefclient in
|
|
|
|
// client_app_delegates_browser.cc
|
|
|
|
static void RegisterCookieableSchemes(
|
|
|
|
std::vector<std::string>& cookieable_schemes);
|
|
|
|
|
2015-02-03 00:18:16 +01:00
|
|
|
// Creates all of the Delegate objects. Implemented by cefclient in
|
|
|
|
// client_app_delegates_browser.cc
|
2015-01-31 05:41:36 +01:00
|
|
|
static void CreateDelegates(DelegateSet& delegates);
|
|
|
|
|
|
|
|
// CefApp methods.
|
2015-08-18 00:14:59 +02:00
|
|
|
void OnBeforeCommandLineProcessing(
|
|
|
|
const CefString& process_type,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefCommandLine> command_line) override;
|
|
|
|
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
|
2015-01-31 05:41:36 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CefBrowserProcessHandler methods.
|
2022-10-26 00:50:29 +02:00
|
|
|
void OnRegisterCustomPreferences(
|
|
|
|
cef_preferences_type_t type,
|
|
|
|
CefRawPtr<CefPreferenceRegistrar> registrar) override;
|
2021-06-17 21:43:06 +02:00
|
|
|
void OnContextInitialized() override;
|
2023-11-29 02:33:44 +01:00
|
|
|
bool OnAlreadyRunningAppRelaunch(CefRefPtr<CefCommandLine> command_line,
|
|
|
|
const CefString& current_directory) override;
|
2023-06-01 16:06:15 +02:00
|
|
|
void OnScheduleMessagePumpWork(int64_t delay) override;
|
2023-02-17 21:55:12 +01:00
|
|
|
CefRefPtr<CefClient> GetDefaultClient() override;
|
2015-01-31 05:41:36 +01:00
|
|
|
|
|
|
|
// Set of supported Delegates.
|
|
|
|
DelegateSet delegates_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(ClientAppBrowser);
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ClientAppBrowser);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace client
|
|
|
|
|
2016-11-18 00:52:42 +01:00
|
|
|
#endif // CEF_TESTS_SHARED_BROWSER_CLIENT_APP_BROWSER_H_
|