2016-12-12 11:05:29 +01:00
|
|
|
// Copyright (c) 2016 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.
|
|
|
|
|
|
|
|
#include "tests/cefclient/browser/client_browser.h"
|
2019-02-25 22:17:28 +01:00
|
|
|
#include "tests/cefclient/browser/main_context.h"
|
2016-12-12 11:05:29 +01:00
|
|
|
|
2023-02-17 21:55:12 +01:00
|
|
|
#include "include/base/cef_logging.h"
|
2017-07-11 21:02:44 +02:00
|
|
|
#include "include/cef_command_line.h"
|
2016-12-12 11:05:29 +01:00
|
|
|
#include "include/cef_crash_util.h"
|
2017-07-11 21:02:44 +02:00
|
|
|
#include "include/cef_file_util.h"
|
2022-10-28 20:17:18 +02:00
|
|
|
#include "tests/cefclient/browser/client_prefs.h"
|
2023-02-17 21:55:12 +01:00
|
|
|
#include "tests/cefclient/browser/default_client_handler.h"
|
2017-07-11 21:02:44 +02:00
|
|
|
#include "tests/shared/common/client_switches.h"
|
2016-12-12 11:05:29 +01:00
|
|
|
|
|
|
|
namespace client {
|
|
|
|
namespace browser {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class ClientBrowserDelegate : public ClientAppBrowser::Delegate {
|
|
|
|
public:
|
|
|
|
ClientBrowserDelegate() {}
|
|
|
|
|
2022-10-28 20:17:18 +02:00
|
|
|
void OnRegisterCustomPreferences(
|
|
|
|
CefRefPtr<client::ClientAppBrowser> app,
|
|
|
|
cef_preferences_type_t type,
|
|
|
|
CefRawPtr<CefPreferenceRegistrar> registrar) override {
|
|
|
|
if (type == CEF_PREFERENCES_TYPE_GLOBAL) {
|
|
|
|
// Register global preferences with default values.
|
|
|
|
prefs::RegisterGlobalPreferences(registrar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-17 21:43:06 +02:00
|
|
|
void OnContextInitialized(CefRefPtr<ClientAppBrowser> app) override {
|
2016-12-12 11:05:29 +01:00
|
|
|
if (CefCrashReportingEnabled()) {
|
|
|
|
// Set some crash keys for testing purposes. Keys must be defined in the
|
|
|
|
// "crash_reporter.cfg" file. See cef_crash_util.h for details.
|
2018-02-15 01:12:09 +01:00
|
|
|
CefSetCrashKeyValue("testkey_small1", "value1_small_browser");
|
|
|
|
CefSetCrashKeyValue("testkey_small2", "value2_small_browser");
|
|
|
|
CefSetCrashKeyValue("testkey_medium1", "value1_medium_browser");
|
|
|
|
CefSetCrashKeyValue("testkey_medium2", "value2_medium_browser");
|
|
|
|
CefSetCrashKeyValue("testkey_large1", "value1_large_browser");
|
|
|
|
CefSetCrashKeyValue("testkey_large2", "value2_large_browser");
|
2016-12-12 11:05:29 +01:00
|
|
|
}
|
2017-07-11 21:02:44 +02:00
|
|
|
|
|
|
|
const std::string& crl_sets_path =
|
|
|
|
CefCommandLine::GetGlobalCommandLine()->GetSwitchValue(
|
|
|
|
switches::kCRLSetsPath);
|
|
|
|
if (!crl_sets_path.empty()) {
|
|
|
|
// Load the CRLSets file from the specified path.
|
|
|
|
CefLoadCRLSetsFile(crl_sets_path);
|
|
|
|
}
|
2016-12-12 11:05:29 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 22:17:28 +01:00
|
|
|
void OnBeforeCommandLineProcessing(
|
|
|
|
CefRefPtr<ClientAppBrowser> app,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefCommandLine> command_line) override {
|
2019-02-25 22:17:28 +01:00
|
|
|
// Append Chromium command line parameters if touch events are enabled
|
2023-01-02 23:59:03 +01:00
|
|
|
if (client::MainContext::Get()->TouchEventsEnabled()) {
|
2019-02-25 22:17:28 +01:00
|
|
|
command_line->AppendSwitchWithValue("touch-events", "enabled");
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2019-02-25 22:17:28 +01:00
|
|
|
}
|
|
|
|
|
2023-02-17 21:55:12 +01:00
|
|
|
CefRefPtr<CefClient> GetDefaultClient(
|
|
|
|
CefRefPtr<ClientAppBrowser> app) override {
|
|
|
|
// Default client handler for unmanaged browser windows. Used with the
|
|
|
|
// Chrome runtime only.
|
|
|
|
LOG(INFO) << "Creating a chrome browser with the default client";
|
|
|
|
return new DefaultClientHandler();
|
|
|
|
}
|
|
|
|
|
2016-12-12 11:05:29 +01:00
|
|
|
private:
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ClientBrowserDelegate);
|
|
|
|
IMPLEMENT_REFCOUNTING(ClientBrowserDelegate);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
void CreateDelegates(ClientAppBrowser::DelegateSet& delegates) {
|
|
|
|
delegates.insert(new ClientBrowserDelegate);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace browser
|
|
|
|
} // namespace client
|