forked from chromiumembedded/cef-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_browser_impl.cc
64 lines (50 loc) · 1.74 KB
/
app_browser_impl.cc
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
// 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 "examples/message_router/client_impl.h"
#include "examples/shared/app_factory.h"
#include "examples/shared/browser_util.h"
#include "examples/shared/resource_util.h"
namespace message_router {
namespace {
std::string GetStartupURL() {
return shared::kTestOrigin + std::string("message_router.html");
}
} // 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
}
}
// CefBrowserProcessHandler methods:
void OnContextInitialized() OVERRIDE {
// Create the browser window.
const CefString& startup_url = GetStartupURL();
shared::CreateBrowser(new Client(startup_url), startup_url,
CefBrowserSettings());
}
private:
IMPLEMENT_REFCOUNTING(BrowserApp);
DISALLOW_COPY_AND_ASSIGN(BrowserApp);
};
} // namespace message_router
namespace shared {
CefRefPtr<CefApp> CreateBrowserProcessApp() {
return new message_router::BrowserApp();
}
} // namespace shared