-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBroView.h
391 lines (357 loc) · 8.97 KB
/
BroView.h
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
#pragma once
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Sazabi.h"
#define ViewBaseClass CWnd
#define FRM ((CBrowserFrame*)m_pwndFrame)
class CChildView : public ViewBaseClass
{
public:
CChildView();
CWnd* m_pwndFrame;
CString m_UpDateAddressBarURL_Cache;
CString m_NavigateCompleteURL_Cache;
CString m_strTitle;
void ResizeWindowPopup();
void ResizeWindowPopupInpl();
void ResizeFrmWindow(RECT& rectClient);
BOOL ZoomTo(double lFactor);
double GetZoomSizeEx();
void SetWheelZoom(int iDel);
double m_dbZoomSize;
double m_dbZoomSizeDefault;
CString m_strURL;
protected:
//SZB
CefRefPtr<CefBrowser> m_cefBrowser;
INT m_nBrowserID;
CefRefPtr<ClientHandler> m_clientHandler;
CefPopupFeatures* m_popupFeatures;
BOOL m_bDevToolsWnd;
afx_msg LRESULT OnBeforeBrowse(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnDownloadUpdate(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnDownloadBlankPage(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnBeforeDownload(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnLoadStart(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnBeforeResourceLoad(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnLoadEnd(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnTitleChange(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnFaviconChange(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnFullScreenModeChange(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnProgressChange(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnStateChange(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnAddressChange(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnStatusMessage(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSearchURL(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnCloseBrowser(WPARAM wParam, LPARAM lParam);
//afx_msg LRESULT OnNewBrowser(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnNewWindow(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnAuthenticate(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnBadCertificate(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnWindowActivate(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetRendererPID(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnCopyImage(WPARAM wParam, LPARAM lParam);
public:
void SetBrowserPtr(INT nBrowserId, CefRefPtr<CefBrowser> browser);
void ReSetRendererPID();
CString GetLocationURL()
{
CString strRet;
if (IsBrowserNull())
return strRet;
if (m_cefBrowser->GetMainFrame())
{
CefString strURL;
strURL = m_cefBrowser->GetMainFrame()->GetURL();
strRet = (LPCWSTR)strURL.c_str();
}
return strRet;
}
INT GetBrowserId()
{
if (IsBrowserNull())
return -1;
INT nBrowserId = m_cefBrowser->GetIdentifier();
return nBrowserId;
}
protected:
static const UINT m_pFindDialogMessage;
CFindReplaceDialog* m_pFindDialog;
bool m_bFindNext;
BOOL m_bWndCloseFlg;
public:
void Navigate(LPCTSTR pszURL);
void SafeWindowCloseFunction();
//{{AFX_VIRTUAL(CChildView)
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
public:
virtual void OnDraw(CDC* pDC){}; // overridden to draw this view
virtual ~CChildView();
void UpDateAddressBar();
void GetTravelLog(CStringArray& strArrayRet, BOOL bBack = true)
{
try
{
if (IsBrowserNull())
return;
strArrayRet.RemoveAll();
CefNavigationEntryVisitorAdapter CefEntryVisitor;
m_cefBrowser->GetHost()->GetNavigationEntries(&CefEntryVisitor, false);
int iMax = (int)CefEntryVisitor.m_strArrayRet.GetSize();
int iCurrentIndex = 0;
iCurrentIndex = CefEntryVisitor.m_iCurrentIndex;
if (bBack)
{
for (int i = iCurrentIndex - 1; i >= 0; i--)
{
CString strData;
strData = CefEntryVisitor.m_strArrayRet.GetAt(i);
strData.TrimLeft();
strData.TrimRight();
if (strData.IsEmpty())
continue;
strArrayRet.Add(strData);
}
}
else
{
for (int i = iCurrentIndex + 1; i < iMax; i++)
{
CString strData;
strData = CefEntryVisitor.m_strArrayRet.GetAt(i);
strData.TrimLeft();
strData.TrimRight();
if (strData.IsEmpty())
continue;
strArrayRet.Add(strData);
}
}
}
catch (...)
{
ATLASSERT(0);
}
}
inline void GoBack()
{
try
{
if (IsBrowserNull())
return;
m_cefBrowser->GoBack();
}
catch (...)
{
ATLASSERT(0);
}
}
inline void GoForward()
{
try
{
if (IsBrowserNull())
return;
m_cefBrowser->GoForward();
}
catch (...)
{
ATLASSERT(0);
}
}
BOOL m_bFirstCallDontClose;
inline void GoHomeFirstCall()
{
try
{
//初めのインスタンスの場合
if (theApp.IsFirstInstance())
{
m_bFirstCallDontClose = TRUE;
}
else
{
m_bFirstCallDontClose = FALSE;
}
this->GoHome();
}
catch (...)
{
ATLASSERT(0);
}
}
inline void GoHome()
{
try
{
CString strHomeURL;
strHomeURL = theApp.m_AppSettings.GetStartURL();
this->Navigate(strHomeURL);
}
catch (...)
{
ATLASSERT(0);
}
}
inline void Refresh()
{
try
{
if (IsBrowserNull())
return;
m_cefBrowser->Reload();
}
catch (...)
{
ATLASSERT(0);
}
}
inline void Refresh2(int nLevel)
{
try
{
if (IsBrowserNull())
return;
m_cefBrowser->ReloadIgnoreCache();
}
catch (...)
{
ATLASSERT(0);
}
}
inline void Stop()
{
try
{
if (IsBrowserNull())
return;
m_cefBrowser->StopLoad();
}
catch (...)
{
ATLASSERT(0);
}
}
inline BOOL IsPopupWindow()
{
BOOL bSuggestWindow = FALSE;
if (m_popupFeatures)
bSuggestWindow = TRUE;
return bSuggestWindow;
}
BOOL GetToolBar() const;
BOOL GetMenuBar() const;
BOOL GetStatusBar() const;
BOOL GetAddressBar() const;
void OnFullScreen(BOOL bFlg);
void OnAddressBar(BOOL bFlg);
void OnToolBar(BOOL bFlg);
void OnMenuBar(BOOL bFlg);
void OnStatusBar(BOOL bFlg);
void OnVisible(BOOL bFlg);
void OnWindowSetResizable(BOOL bFlg);
void ShowTimeoutMessageBox(LPCTSTR strMsg, int iType, int iTimeOut);
void IsRedirectWndAutoCloseChk();
BOOL IsRedirectURLChk(const CString& strURL, BOOL bTop);
BOOL IsRedirectScriptEx(LPCTSTR sURL, LPCTSTR sChkURLNoQuery, BOOL bTop);
BOOL IsFileURINavigation(const CString& strURL);
void CreateNewBrowserWindow(LPCTSTR lpszUrl, BOOL bActive = true);
LRESULT OnCreateNewBrowserWindow(WPARAM wParam, LPARAM lParam);
inline BOOL IsBrowserNull()
{
return (m_cefBrowser == NULL);
}
HWND m_pFocusWnd;
virtual void EnableWinEx(BOOL bShow = TRUE)
{
if (bShow)
{
if (!this->IsWindowEnabled())
{
if (theApp.IsWnd(m_pwndFrame))
{
if (!m_pwndFrame->IsWindowEnabled())
return;
}
EnableWindow(TRUE);
}
}
else
{
if (this->IsWindowEnabled())
{
EnableWindow(FALSE);
}
}
}
BOOL bSetCefBrowserFocus();
BOOL SetFocusApp()
{
BOOL bRet = FALSE;
try
{
EnableWinEx(TRUE);
if (bSetCefBrowserFocus())
{
bRet = TRUE;
}
}
catch (...)
{
ATLASSERT(0);
}
return bRet;
}
protected:
//{{AFX_MSG(CChildView)
afx_msg void OnDestroy();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnNew();
afx_msg void OnNewBlank();
afx_msg void OnReopenCloseTab();
afx_msg void OnNewSession();
afx_msg void OnPrint();
afx_msg void ShowDevTools();
afx_msg void OnGoBack();
afx_msg void OnUpdateGoBack(CCmdUI* pCmdUI);
afx_msg void OnGoForward();
afx_msg void OnUpdateGoForward(CCmdUI* pCmdUI);
afx_msg void OnGoStartPage();
afx_msg void OnUpdateGoStartPage(CCmdUI* pCmdUI);
afx_msg void OnViewRefresh();
afx_msg void OnUpdateViewRefresh(CCmdUI* pCmdUI);
afx_msg void OnViewStop();
afx_msg void OnUpdateViewStop(CCmdUI* pCmdUI);
afx_msg void OnOpen();
afx_msg void OnCut();
afx_msg void OnCopy();
afx_msg void OnPaste();
afx_msg void OnSelAll();
afx_msg void OnFindPage();
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg void OnZoomUp();
afx_msg void OnZoomDown();
afx_msg void OnZoomReset();
//}}AFX_MSG
virtual afx_msg void OnBroBack(UINT nID);
virtual afx_msg void OnBroForward(UINT nID);
virtual afx_msg void OnZoom(UINT nID);
virtual void OnTitleChange(LPCWSTR lpwszText);
virtual void OnQuit();
virtual void OnStatusTextChange(LPCTSTR lpszText);
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnUpdateCut(CCmdUI* pCmdUI);
afx_msg void OnUpdatePaste(CCmdUI* pCmdUI);
afx_msg void OnSettings();
afx_msg void OnAppAbout();
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnSetFocus(CWnd* pOldWnd);
};