Repository navigation
Expand file tree
/
Copy pathclient_app.h
More file actions
145 lines (135 loc) · 3.57 KB
/
Copy pathclient_app.h
File metadata and controls
145 lines (135 loc) · 3.57 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#pragma once
#pragma warning(push, 0)
#include <codeanalysis/warnings.h>
#pragma warning(disable \
: ALL_CODE_ANALYSIS_WARNINGS)
#pragma push_macro("max")
#pragma push_macro("min")
#undef max
#undef min
#include "include/cef_app.h"
#pragma pop_macro("max")
#pragma pop_macro("min")
#pragma warning(pop)
#include "client_handler.h"
#include "client_util.h"
class ClientApp : public CefApp,
public CefBrowserProcessHandler
{
public:
ClientApp(void);
ClientApp(HWND hWnd);
~ClientApp(void);
// CefApp methods:
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override { return this; }
virtual void OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line);
virtual void OnContextInitialized() override;
virtual void OnScheduleMessagePumpWork(int64_t delayMs) override;
#if CHROME_VERSION_MAJOR >= 120
virtual bool OnAlreadyRunningAppRelaunch(CefRefPtr<CefCommandLine> command_line, const CefString& current_directory) override;
#endif
private:
IMPLEMENT_REFCOUNTING(ClientApp);
};
class CefNavigationEntryVisitorAdapter : public CefNavigationEntryVisitor
{
private:
public:
CStringArray m_strArrayRet;
int m_iCurrentIndex;
CefNavigationEntryVisitorAdapter()
{
m_iCurrentIndex = 0;
m_strArrayRet.SetSize(20);
}
~CefNavigationEntryVisitorAdapter()
{
}
bool Visit(CefRefPtr<CefNavigationEntry> entry,
bool current,
int index,
int total) override
{
if (!entry->IsValid()) return true;
INT_PTR iCurrentSize = 0;
INT_PTR iIndex = index;
iCurrentSize = m_strArrayRet.GetSize();
if (iCurrentSize < total)
{
m_strArrayRet.SetSize(total);
}
CString strTitle;
CefString strcefTitle;
strcefTitle = entry->GetTitle();
strTitle = (LPCWSTR)strcefTitle.c_str();
strTitle.TrimLeft();
strTitle.TrimRight();
if (strTitle.IsEmpty())
{
CString strURL;
CefString strcefURL;
strcefURL = entry->GetDisplayURL();
strURL = (LPCWSTR)strcefURL.c_str();
strTitle = strURL;
}
m_strArrayRet.SetAt(iIndex, strTitle);
if (current)
m_iCurrentIndex = index;
return true;
}
private:
// multi_threaded_message_loopのとき、Visit()はCEFのUIスレッド上で実行され、
// 呼び出し元のスタックが巻き戻された後に発火する可能性がある。
// 非同期コールバック配信を通じてビジターが生存し続けられるよう、
// 実際の参照カウント機構を使用する。
IMPLEMENT_REFCOUNTING(CefNavigationEntryVisitorAdapter);
};
class CBrowserFrame;
class DownloadFaviconCB : public CefDownloadImageCallback
{
public:
virtual void OnDownloadImageFinished(const CefString& image_url,
int http_status_code,
CefRefPtr<CefImage> image);
public:
CBrowserFrame* m_pwndFrame = nullptr;
void SetFramePtr(CBrowserFrame* pwndFrame) { m_pwndFrame = pwndFrame; }
void AddRef() const override
{
}
bool Release() const override
{
return true;
}
bool HasOneRef() const override
{
return false;
}
bool HasAtLeastOneRef() const override
{
return false;
}
};
class DownloadImageCopyClipboard : public CefDownloadImageCallback
{
public:
virtual void OnDownloadImageFinished(const CefString& image_url,
int http_status_code,
CefRefPtr<CefImage> image);
public:
void AddRef() const override
{
}
bool Release() const override
{
return true;
}
bool HasOneRef() const override
{
return false;
}
bool HasAtLeastOneRef() const override
{
return false;
}
};