-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathfocus_handler.cpp
59 lines (48 loc) · 1.82 KB
/
focus_handler.cpp
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
// Copyright (c) 2014 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 "focus_handler.h"
#include "include/base/cef_callback.h"
#include "include/wrapper/cef_closure_task.h"
#include "client_handler.h"
#include "jni_util.h"
FocusHandler::FocusHandler(JNIEnv* env, jobject handler)
: handle_(env, handler) {}
void FocusHandler::OnTakeFocus(CefRefPtr<CefBrowser> browser, bool next) {
ScopedJNIEnv env;
if (!env)
return;
ScopedJNIBrowser jbrowser(env, browser);
JNI_CALL_VOID_METHOD(env, handle_, "onTakeFocus",
"(Lorg/cef/browser/CefBrowser;Z)V", jbrowser.get(),
(jboolean)next);
}
bool FocusHandler::OnSetFocus(CefRefPtr<CefBrowser> browser,
FocusSource source) {
ScopedJNIEnv env;
if (!env)
return false;
jboolean jreturn = JNI_FALSE;
ScopedJNIObjectResult jsource(env);
switch (source) {
JNI_CASE(env, "org/cef/handler/CefFocusHandler$FocusSource",
FOCUS_SOURCE_NAVIGATION, jsource);
default:
JNI_CASE(env, "org/cef/handler/CefFocusHandler$FocusSource",
FOCUS_SOURCE_SYSTEM, jsource);
}
ScopedJNIBrowser jbrowser(env, browser);
JNI_CALL_METHOD(env, handle_, "onSetFocus",
"(Lorg/cef/browser/CefBrowser;Lorg/cef/handler/"
"CefFocusHandler$FocusSource;)Z",
Boolean, jreturn, jbrowser.get(), jsource.get());
return (jreturn != JNI_FALSE);
}
void FocusHandler::OnGotFocus(CefRefPtr<CefBrowser> browser) {
ScopedJNIEnv env;
if (!env)
return;
ScopedJNIBrowser jbrowser(env, browser);
JNI_CALL_VOID_METHOD(env, handle_, "onGotFocus",
"(Lorg/cef/browser/CefBrowser;)V", jbrowser.get());
}