Repository navigation
Expand file tree
/
Copy pathclient_handler.cpp
More file actions
697 lines (647 loc) · 27.9 KB
/
Copy pathclient_handler.cpp
File metadata and controls
697 lines (647 loc) · 27.9 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
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
// Copyright (c) 2012-2013 The CEF Python authors. All rights reserved.
// License: New BSD License.
// Website: http://code.google.com/p/cefpython/
#include "client_handler.h"
#include "cefpython_public_api.h"
#include "DebugLog.h"
// ----------------------------------------------------------------------------
// CefClient
// ----------------------------------------------------------------------------
bool ClientHandler::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) {
if (source_process != PID_RENDERER) {
return false;
}
std::string messageName = message->GetName().ToString();
std::string logMessage = "Browser: OnProcessMessageReceived(): ";
logMessage.append(messageName.c_str());
DebugLog(logMessage.c_str());
if (messageName == "OnContextCreated") {
CefRefPtr<CefListValue> arguments = message->GetArgumentList();
if (arguments->GetSize() == 1 && arguments->GetType(0) == VTYPE_INT) {
int64 frameId = arguments->GetInt(0);
CefRefPtr<CefFrame> frame = browser->GetFrame(frameId);
V8ContextHandler_OnContextCreated(browser, frame);
return true;
} else {
DebugLog("Browser: OnProcessMessageReceived(): invalid arguments" \
", messageName = OnContextCreated");
return false;
}
} else if (messageName == "OnContextReleased") {
CefRefPtr<CefListValue> arguments = message->GetArgumentList();
if (arguments->GetSize() == 2 \
&& arguments->GetType(0) == VTYPE_INT \
&& arguments->GetType(1) == VTYPE_INT) {
int browserId = arguments->GetInt(0);
int64 frameId = arguments->GetInt(1);
V8ContextHandler_OnContextReleased(browserId, frameId);
return true;
} else {
DebugLog("Browser: OnProcessMessageReceived(): invalid arguments" \
", messageName = OnContextReleased");
return false;
}
} else if (messageName == "V8FunctionHandler::Execute") {
CefRefPtr<CefListValue> arguments = message->GetArgumentList();
if (arguments->GetSize() == 3
&& arguments->GetType(0) == VTYPE_INT // frameId
&& arguments->GetType(1) == VTYPE_STRING // functionName
&& arguments->GetType(2) == VTYPE_LIST) { // functionArguments
int64 frameId = arguments->GetInt(0);
CefString functionName = arguments->GetString(1);
CefRefPtr<CefListValue> functionArguments = arguments->GetList(2);
CefRefPtr<CefFrame> frame = browser->GetFrame(frameId);
V8FunctionHandler_Execute(browser, frame, functionName, functionArguments);
return true;
} else {
DebugLog("Browser: OnProcessMessageReceived(): invalid arguments" \
", messageName = V8FunctionHandler::Execute");
return false;
}
} else if (messageName == "ExecutePythonCallback") {
CefRefPtr<CefListValue> arguments = message->GetArgumentList();
if (arguments->GetSize() == 2
&& arguments->GetType(0) == VTYPE_INT // callbackId
&& arguments->GetType(1) == VTYPE_LIST) { // functionArguments
int callbackId = arguments->GetInt(0);
CefRefPtr<CefListValue> functionArguments = arguments->GetList(1);
ExecutePythonCallback(browser, callbackId, functionArguments);
return true;
} else {
DebugLog("Browser: OnProcessMessageReceived(): invalid arguments" \
", messageName = ExecutePythonCallback");
return false;
}
} else if (messageName == "RemovePythonCallbacksForFrame") {
CefRefPtr<CefListValue> arguments = message->GetArgumentList();
if (arguments->GetSize() == 1 && arguments->GetType(0) == VTYPE_INT) {
int frameId = arguments->GetInt(0);
RemovePythonCallbacksForFrame(frameId);
return true;
} else {
DebugLog("Browser: OnProcessMessageReceived(): invalid arguments" \
", messageName = ExecutePythonCallback");
return false;
}
}
return false;
}
// ----------------------------------------------------------------------------
// CefLifeSpanHandler
// ----------------------------------------------------------------------------
///
// Called on the IO thread before a new popup window is created. The |browser|
// and |frame| parameters represent the source of the popup request. The
// |target_url| and |target_frame_name| values may be empty if none were
// specified with the request. The |popupFeatures| structure contains
// information about the requested popup window. To allow creation of the
// popup window optionally modify |windowInfo|, |client|, |settings| and
// |no_javascript_access| and return false. To cancel creation of the popup
// window return true. The |client| and |settings| values will default to the
// source browser's values. The |no_javascript_access| value indicates whether
// the new browser window should be scriptable and in the same process as the
// source browser.
/*--cef(optional_param=target_url,optional_param=target_frame_name)--*/
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& target_url,
const CefString& target_frame_name,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings,
bool* no_javascript_access) {
return false;
}
///
// Called after a new browser is created.
///
/*--cef()--*/
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
}
///
// Called when a modal window is about to display and the modal loop should
// begin running. Return false to use the default modal loop implementation or
// true to use a custom implementation.
///
/*--cef()--*/
bool ClientHandler::RunModal(CefRefPtr<CefBrowser> browser) {
return false;
}
///
// Called when a browser has recieved a request to close. This may result
// directly from a call to CefBrowserHost::CloseBrowser() or indirectly if the
// browser is a top-level OS window created by CEF and the user attempts to
// close the window. This method will be called after the JavaScript
// 'onunload' event has been fired. It will not be called for browsers after
// the associated OS window has been destroyed (for those browsers it is no
// longer possible to cancel the close).
//
// If CEF created an OS window for the browser returning false will send an OS
// close notification to the browser window's top-level owner (e.g. WM_CLOSE
// on Windows, performClose: on OS-X and "delete_event" on Linux). If no OS
// window exists (window rendering disabled) returning false will cause the
// browser object to be destroyed immediately. Return true if the browser is
// parented to another window and that other window needs to receive close
// notification via some non-standard technique.
//
// If an application provides its own top-level window it should handle OS
// close notifications by calling CefBrowserHost::CloseBrowser(false) instead
// of immediately closing (see the example below). This gives CEF an
// opportunity to process the 'onbeforeunload' event and optionally cancel the
// close before DoClose() is called.
//
// The CefLifeSpanHandler::OnBeforeClose() method will be called immediately
// before the browser object is destroyed. The application should only exit
// after OnBeforeClose() has been called for all existing browsers.
//
// If the browser represents a modal window and a custom modal loop
// implementation was provided in CefLifeSpanHandler::RunModal() this callback
// should be used to restore the opener window to a usable state.
//
// By way of example consider what should happen during window close when the
// browser is parented to an application-provided top-level OS window.
// 1. User clicks the window close button which sends an OS close
// notification (e.g. WM_CLOSE on Windows, performClose: on OS-X and
// "delete_event" on Linux).
// 2. Application's top-level window receives the close notification and:
// A. Calls CefBrowserHost::CloseBrowser(false).
// B. Cancels the window close.
// 3. JavaScript 'onbeforeunload' handler executes and shows the close
// confirmation dialog (which can be overridden via
// CefJSDialogHandler::OnBeforeUnloadDialog()).
// 4. User approves the close.
// 5. JavaScript 'onunload' handler executes.
// 6. Application's DoClose() handler is called. Application will:
// A. Call CefBrowserHost::ParentWindowWillClose() to notify CEF that the
// parent window will be closing.
// B. Set a flag to indicate that the next close attempt will be allowed.
// C. Return false.
// 7. CEF sends an OS close notification.
// 8. Application's top-level window receives the OS close notification and
// allows the window to close based on the flag from #6B.
// 9. Browser OS window is destroyed.
// 10. Application's CefLifeSpanHandler::OnBeforeClose() handler is called and
// the browser object is destroyed.
// 11. Application exits by calling CefQuitMessageLoop() if no other browsers
// exist.
///
/*--cef()--*/
bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser) {
return false;
}
///
// Called just before a browser is destroyed. Release all references to the
// browser object and do not attempt to execute any methods on the browser
// object after this callback returns. If this is a modal window and a custom
// modal loop implementation was provided in RunModal() this callback should
// be used to exit the custom modal loop. See DoClose() documentation for
// additional usage information.
///
/*--cef()--*/
void ClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
REQUIRE_UI_THREAD();
LifespanHandler_OnBeforeClose(browser);
}
// --------------------------------------------------------------------------
// CefDisplayHandler
// --------------------------------------------------------------------------
///
// Implement this interface to handle events related to browser display state.
// The methods of this class will be called on the UI thread.
///
///
// Called when the loading state has changed.
///
/*--cef()--*/
void ClientHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
bool isLoading,
bool canGoBack,
bool canGoForward) {
REQUIRE_UI_THREAD();
DisplayHandler_OnLoadingStateChange(browser, isLoading, canGoBack,
canGoForward);
}
///
// Called when a frame's address has changed.
///
/*--cef()--*/
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& url) {
REQUIRE_UI_THREAD();
DisplayHandler_OnAddressChange(browser, frame, url);
}
///
// Called when the page title changes.
///
/*--cef(optional_param=title)--*/
void ClientHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
REQUIRE_UI_THREAD();
DisplayHandler_OnTitleChange(browser, title);
}
///
// Called when the browser is about to display a tooltip. |text| contains the
// text that will be displayed in the tooltip. To handle the display of the
// tooltip yourself return true. Otherwise, you can optionally modify |text|
// and then return false to allow the browser to display the tooltip.
// When window rendering is disabled the application is responsible for
// drawing tooltips and the return value is ignored.
///
/*--cef(optional_param=text)--*/
bool ClientHandler::OnTooltip(CefRefPtr<CefBrowser> browser,
CefString& text) {
REQUIRE_UI_THREAD();
return DisplayHandler_OnTooltip(browser, text);
// return false;
}
///
// Called when the browser receives a status message. |text| contains the text
// that will be displayed in the status message and |type| indicates the
// status message type.
///
/*--cef(optional_param=value)--*/
void ClientHandler::OnStatusMessage(CefRefPtr<CefBrowser> browser,
const CefString& value) {
REQUIRE_UI_THREAD();
DisplayHandler_OnStatusMessage(browser, value);
}
///
// Called to display a console message. Return true to stop the message from
// being output to the console.
///
/*--cef(optional_param=message,optional_param=source)--*/
bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
const CefString& message,
const CefString& source,
int line) {
REQUIRE_UI_THREAD();
return DisplayHandler_OnConsoleMessage(browser, message, source, line);
// return false;
}
// ----------------------------------------------------------------------------
// CefKeyboardHandler
// ----------------------------------------------------------------------------
///
// Implement this interface to handle events related to keyboard input. The
// methods of this class will be called on the UI thread.
///
// Called before a keyboard event is sent to the renderer. |event| contains
// information about the keyboard event. |os_event| is the operating system
// event message, if any. Return true if the event was handled or false
// otherwise. If the event will be handled in OnKeyEvent() as a keyboard
// shortcut set |is_keyboard_shortcut| to true and return false.
/*--cef()--*/
bool ClientHandler::OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event,
bool* is_keyboard_shortcut) {
REQUIRE_UI_THREAD();
return KeyboardHandler_OnPreKeyEvent(browser, event, os_event,
is_keyboard_shortcut);
// Default: return false;
}
///
// Called after the renderer and JavaScript in the page has had a chance to
// handle the event. |event| contains information about the keyboard event.
// |os_event| is the operating system event message, if any. Return true if
// the keyboard event was handled or false otherwise.
///
/*--cef()--*/
bool ClientHandler::OnKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event) {
REQUIRE_UI_THREAD();
return KeyboardHandler_OnKeyEvent(browser, event, os_event);
// Default: return false;
}
// --------------------------------------------------------------------------
// CefRequestHandler
// --------------------------------------------------------------------------
///
// Implement this interface to handle events related to browser requests. The
// methods of this class will be called on the thread indicated.
///
///
// Called on the IO thread before a resource request is loaded. The |request|
// object may be modified. To cancel the request return true otherwise return
// false.
///
/*--cef()--*/
bool ClientHandler::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {
REQUIRE_IO_THREAD();
return RequestHandler_OnBeforeResourceLoad(browser, frame, request);
// Default: return false;
}
///
// Called on the IO thread before a resource is loaded. To allow the resource
// to load normally return NULL. To specify a handler for the resource return
// a CefResourceHandler object. The |request| object should not be modified in
// this callback.
///
/*--cef()--*/
CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {
REQUIRE_IO_THREAD();
// Not yet implemented.
return NULL;
}
///
// Called on the IO thread when a resource load is redirected. The |old_url|
// parameter will contain the old URL. The |new_url| parameter will contain
// the new URL and can be changed if desired.
///
/*--cef()--*/
void ClientHandler::OnResourceRedirect(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& old_url,
CefString& new_url) {
REQUIRE_IO_THREAD();
RequestHandler_OnResourceRedirect(browser, frame, old_url, new_url);
}
///
// Called on the IO thread when the browser needs credentials from the user.
// |isProxy| indicates whether the host is a proxy server. |host| contains the
// hostname and |port| contains the port number. Return true to continue the
// request and call CefAuthCallback::Continue() when the authentication
// information is available. Return false to cancel the request.
///
/*--cef(optional_param=realm)--*/
bool ClientHandler::GetAuthCredentials(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isProxy,
const CefString& host,
int port,
const CefString& realm,
const CefString& scheme,
CefRefPtr<CefAuthCallback> callback) {
REQUIRE_IO_THREAD();
return RequestHandler_GetAuthCredentials(browser, frame, isProxy, host,
port, realm, scheme, callback);
// Default: return false;
}
///
// Called on the IO thread when JavaScript requests a specific storage quota
// size via the webkitStorageInfo.requestQuota function. |origin_url| is the
// origin of the page making the request. |new_size| is the requested quota
// size in bytes. Return true and call CefQuotaCallback::Continue() either in
// this method or at a later time to grant or deny the request. Return false
// to cancel the request.
///
/*--cef(optional_param=realm)--*/
bool ClientHandler::OnQuotaRequest(CefRefPtr<CefBrowser> browser,
const CefString& origin_url,
int64 new_size,
CefRefPtr<CefQuotaCallback> callback) {
REQUIRE_IO_THREAD();
return RequestHandler_OnQuotaRequest(browser, origin_url, new_size,
callback);
// Default: return false;
}
///
// Called on the IO thread to retrieve the cookie manager. |main_url| is the
// URL of the top-level frame. Cookies managers can be unique per browser or
// shared across multiple browsers. The global cookie manager will be used if
// this method returns NULL.
///
/*--cef()--*/
CefRefPtr<CefCookieManager> ClientHandler::GetCookieManager(
CefRefPtr<CefBrowser> browser,
const CefString& main_url) {
REQUIRE_IO_THREAD();
return RequestHandler_GetCookieManager(browser, main_url);
// Default: return NULL.
}
///
// Called on the UI thread to handle requests for URLs with an unknown
// protocol component. Set |allow_os_execution| to true to attempt execution
// via the registered OS protocol handler, if any.
// SECURITY WARNING: YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED
// ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
///
/*--cef()--*/
void ClientHandler::OnProtocolExecution(CefRefPtr<CefBrowser> browser,
const CefString& url,
bool& allow_os_execution) {
REQUIRE_UI_THREAD();
RequestHandler_OnProtocolExecution(browser, url, allow_os_execution);
}
///
// Called on the browser process IO thread before a plugin is loaded. Return
// true to block loading of the plugin.
///
/*--cef(optional_param=url,optional_param=policy_url)--*/
bool ClientHandler::OnBeforePluginLoad(CefRefPtr<CefBrowser> browser,
const CefString& url,
const CefString& policy_url,
CefRefPtr<CefWebPluginInfo> info) {
REQUIRE_IO_THREAD();
return RequestHandler_OnBeforePluginLoad(browser, url, policy_url, info);
// Default: return false;
}
///
// Called on the UI thread to handle requests for URLs with an invalid
// SSL certificate. Return true and call CefAllowCertificateErrorCallback::
// Continue() either in this method or at a later time to continue or cancel
// the request. Return false to cancel the request immediately. If |callback|
// is empty the error cannot be recovered from and the request will be
// canceled automatically. If CefSettings.ignore_certificate_errors is set
// all invalid certificates will be accepted without calling this method.
///
/*--cef()--*/
bool ClientHandler::OnCertificateError(
cef_errorcode_t cert_error,
const CefString& request_url,
CefRefPtr<CefAllowCertificateErrorCallback> callback) {
REQUIRE_UI_THREAD();
return RequestHandler_OnCertificateError(
cert_error, request_url, callback);
// Default: return false;
}
// --------------------------------------------------------------------------
// CefLoadHandler
// --------------------------------------------------------------------------
///
// Implement this interface to handle events related to browser load status.
// The methods of this class will be called on the UI thread.
///
///
// Called when the browser begins loading a frame. The |frame| value will
// never be empty -- call the IsMain() method to check if this frame is the
// main frame. Multiple frames may be loading at the same time. Sub-frames may
// start or continue loading after the main frame load has ended. This method
// may not be called for a particular frame if the load request for that frame
// fails.
///
/*--cef()--*/
void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame) {
REQUIRE_UI_THREAD();
LoadHandler_OnLoadStart(browser, frame);
}
///
// Called when the browser is done loading a frame. The |frame| value will
// never be empty -- call the IsMain() method to check if this frame is the
// main frame. Multiple frames may be loading at the same time. Sub-frames may
// start or continue loading after the main frame load has ended. This method
// will always be called for all frames irrespective of whether the request
// completes successfully.
///
/*--cef()--*/
void ClientHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int httpStatusCode) {
REQUIRE_UI_THREAD();
LoadHandler_OnLoadEnd(browser, frame, httpStatusCode);
}
///
// Called when the browser fails to load a resource. |errorCode| is the error
// code number, |errorText| is the error text and and |failedUrl| is the URL
// that failed to load. See net\base\net_error_list.h for complete
// descriptions of the error codes.
///
/*--cef(optional_param=errorText)--*/
void ClientHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
cef_errorcode_t errorCode,
const CefString& errorText,
const CefString& failedUrl) {
REQUIRE_UI_THREAD();
LoadHandler_OnLoadError(browser, frame, errorCode, errorText, failedUrl);
}
///
// Called when the render process terminates unexpectedly. |status| indicates
// how the process terminated.
///
/*--cef()--*/
void ClientHandler::OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
cef_termination_status_t status) {
REQUIRE_UI_THREAD();
LoadHandler_OnRendererProcessTerminated(browser, status);
}
///
// Called when a plugin has crashed. |plugin_path| is the path of the plugin
// that crashed.
///
/*--cef()--*/
void ClientHandler::OnPluginCrashed(CefRefPtr<CefBrowser> browser,
const CefString& plugin_path) {
REQUIRE_UI_THREAD();
LoadHandler_OnPluginCrashed(browser, plugin_path);
}
// ----------------------------------------------------------------------------
// CefRenderHandler
// ----------------------------------------------------------------------------
///
// Implement this interface to handle events when window rendering is disabled.
// The methods of this class will be called on the UI thread.
///
///
// Called to retrieve the root window rectangle in screen coordinates. Return
// true if the rectangle was provided.
///
/*--cef()--*/
bool ClientHandler::GetRootScreenRect(CefRefPtr<CefBrowser> browser,
CefRect& rect) {
REQUIRE_UI_THREAD();
return RenderHandler_GetRootScreenRect(browser, rect);
}
///
// Called to retrieve the view rectangle which is relative to screen
// coordinates. Return true if the rectangle was provided.
///
/*--cef()--*/
bool ClientHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) {
REQUIRE_UI_THREAD();
return RenderHandler_GetViewRect(browser, rect);
}
///
// Called to retrieve the translation from view coordinates to actual screen
// coordinates. Return true if the screen coordinates were provided.
///
/*--cef()--*/
bool ClientHandler::GetScreenPoint(CefRefPtr<CefBrowser> browser,
int viewX,
int viewY,
int& screenX,
int& screenY) {
REQUIRE_UI_THREAD();
return RenderHandler_GetScreenPoint(browser, viewX, viewY, screenX,
screenY);
}
///
// Called to allow the client to fill in the CefScreenInfo object with
// appropriate values. Return true if the |screen_info| structure has been
// modified.
//
// If the screen info rectangle is left empty the rectangle from GetViewRect
// will be used. If the rectangle is still empty or invalid popups may not be
// drawn correctly.
///
/*--cef()--*/
bool ClientHandler::GetScreenInfo(CefRefPtr<CefBrowser> browser,
CefScreenInfo& screen_info) {
REQUIRE_UI_THREAD();
return RenderHandler_GetScreenInfo(browser, screen_info);
}
///
// Called when the browser wants to show or hide the popup widget. The popup
// should be shown if |show| is true and hidden if |show| is false.
///
/*--cef()--*/
void ClientHandler::OnPopupShow(CefRefPtr<CefBrowser> browser,
bool show) {
REQUIRE_UI_THREAD();
RenderHandler_OnPopupShow(browser, show);
}
///
// Called when the browser wants to move or resize the popup widget. |rect|
// contains the new location and size.
///
/*--cef()--*/
void ClientHandler::OnPopupSize(CefRefPtr<CefBrowser> browser,
const CefRect& rect) {
REQUIRE_UI_THREAD();
RenderHandler_OnPopupSize(browser, rect);
}
///
// Called when an element should be painted. |type| indicates whether the
// element is the view or the popup widget. |buffer| contains the pixel data
// for the whole image. |dirtyRects| contains the set of rectangles that need
// to be repainted. On Windows |buffer| will be |width|*|height|*4 bytes
// in size and represents a BGRA image with an upper-left origin.
///
/*--cef()--*/
void ClientHandler::OnPaint(CefRefPtr<CefBrowser> browser,
PaintElementType type,
const RectList& dirtyRects,
const void* buffer,
int width, int height) {
REQUIRE_UI_THREAD();
RenderHandler_OnPaint(browser, type, const_cast<RectList&>(dirtyRects), \
buffer, width, height);
};
///
// Called when the browser window's cursor has changed.
///
/*--cef()--*/
void ClientHandler::OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor) {
REQUIRE_UI_THREAD();
RenderHandler_OnCursorChange(browser, cursor);
}
///
// Called when the scroll offset has changed.
///
/*--cef()--*/
void ClientHandler::OnScrollOffsetChanged(CefRefPtr<CefBrowser> browser) {
REQUIRE_UI_THREAD();
RenderHandler_OnScrollOffsetChanged(browser);
}