Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / android / password_authentication_manager.cc
blob700707571ae67944c4e491b6eceda252f28e551d
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/android/password_authentication_manager.h"
7 #include "chrome/browser/android/tab_android.h"
8 #include "jni/PasswordAuthenticationManager_jni.h"
10 namespace {
12 class PasswordAuthenticationCallback {
13 public:
14 explicit PasswordAuthenticationCallback(
15 const base::Closure& success_callback) {
16 success_callback_ = success_callback;
19 void OnResult(bool result) {
20 if (result)
21 success_callback_.Run();
22 delete this;
25 private:
26 virtual ~PasswordAuthenticationCallback() {}
28 base::Closure success_callback_;
31 } // namespace
33 PasswordAuthenticationManager::PasswordAuthenticationManager() {
36 PasswordAuthenticationManager::~PasswordAuthenticationManager() {
39 bool PasswordAuthenticationManager::RegisterPasswordAuthenticationManager(
40 JNIEnv* env) {
41 return RegisterNativesImpl(env);
44 void PasswordAuthenticationManager::AuthenticatePasswordAutofill(
45 content::WebContents* web_contents,
46 const base::Closure& success_callback) {
47 TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
48 if (!tab)
49 return;
51 JNIEnv* env = base::android::AttachCurrentThread();
52 PasswordAuthenticationCallback* auth_callback =
53 new PasswordAuthenticationCallback(success_callback);
54 Java_PasswordAuthenticationManager_requestAuthentication(
55 env,
56 tab->GetJavaObject().obj(),
57 Java_PasswordAuthenticationCallback_create(
58 env,
59 reinterpret_cast<intptr_t>(auth_callback)).obj());
62 // static
63 void OnResult(JNIEnv* env,
64 jclass jcaller,
65 jlong callback_ptr,
66 jboolean authenticated) {
67 PasswordAuthenticationCallback* callback =
68 reinterpret_cast<PasswordAuthenticationCallback*>(callback_ptr);
69 callback->OnResult(authenticated);