forked from chromiumembedded/cef-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_browser_impl.cc
More file actions
80 lines (62 loc) · 2.21 KB
/
app_browser_impl.cc
File metadata and controls
80 lines (62 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (c) 2017 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 <sstream>
#include "examples/shared/app_factory.h"
#include "examples/minimal/client_minimal.h"
#include "examples/scheme_handler/scheme_handler_impl.h"
#include "examples/scheme_handler/scheme_strings.h"
#include "examples/shared/browser_util.h"
#include "examples/shared/resource_util.h"
namespace scheme_handler {
namespace {
std::string GetStartupURL() {
std::stringstream ss;
ss << kScheme << "://" << kDomain << "/" << kFileName;
return ss.str();
}
} // namespace
// Implementation of CefApp for the browser process.
class BrowserApp : public CefApp, public CefBrowserProcessHandler {
public:
BrowserApp() {}
// CefApp methods:
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
return this;
}
void OnBeforeCommandLineProcessing(
const CefString& process_type,
CefRefPtr<CefCommandLine> command_line) override {
// Command-line flags can be modified in this callback.
// |process_type| is empty for the browser process.
if (process_type.empty()) {
#if defined(OS_MACOSX)
// Disable the macOS keychain prompt. Cookies will not be encrypted.
command_line->AppendSwitch("use-mock-keychain");
#endif
}
}
void OnRegisterCustomSchemes(
CefRawPtr<CefSchemeRegistrar> registrar) override {
// Register the custom scheme as standard and secure.
// Must be the same implementation in all processes.
registrar->AddCustomScheme(kScheme, kSchemeRegistrationOptions);
}
// CefBrowserProcessHandler methods:
void OnContextInitialized() override {
// Register the custom scheme handler factory.
RegisterSchemeHandlerFactory();
// Create the browser window.
shared::CreateBrowser(new minimal::Client(), GetStartupURL(),
CefBrowserSettings());
}
private:
IMPLEMENT_REFCOUNTING(BrowserApp);
DISALLOW_COPY_AND_ASSIGN(BrowserApp);
};
} // namespace scheme_handler
namespace shared {
CefRefPtr<CefApp> CreateBrowserProcessApp() {
return new scheme_handler::BrowserApp();
}
} // namespace shared