| Index: chrome/browser/ui/android/autofill/instrument_unmask_prompt_view_android.cc
|
| diff --git a/chrome/browser/ui/android/autofill/instrument_unmask_prompt_view_android.cc b/chrome/browser/ui/android/autofill/instrument_unmask_prompt_view_android.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e2ad583846aa528692a37d65808ef7f02451c3e4
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/android/autofill/instrument_unmask_prompt_view_android.cc
|
| @@ -0,0 +1,57 @@
|
| +// Copyright 2014 The Chromium 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 "chrome/browser/ui/android/autofill/instrument_unmask_prompt_view_android.h"
|
| +
|
| +#include "content/public/browser/web_contents.h"
|
| +#include "jni/InstrumentUnmaskBridge_jni.h"
|
| +#include "ui/base/android/view_android.h"
|
| +#include "ui/base/android/window_android.h"
|
| +
|
| +namespace autofill {
|
| +
|
| +scoped_ptr<InstrumentUnmaskPromptView>
|
| +InstrumentUnmaskPromptView::CreateAndShow(content::WebContents* web_contents,
|
| + const UnmaskCallback& finished) {
|
| + scoped_ptr<InstrumentUnmaskPromptViewAndroid> view(
|
| + new InstrumentUnmaskPromptViewAndroid(web_contents, finished));
|
| + view->Show();
|
| + return view.Pass();
|
| +}
|
| +
|
| +InstrumentUnmaskPromptViewAndroid::InstrumentUnmaskPromptViewAndroid(
|
| + content::WebContents* web_contents,
|
| + const UnmaskCallback& finished)
|
| + : web_contents_(web_contents), finished_(finished) {
|
| +}
|
| +
|
| +InstrumentUnmaskPromptViewAndroid::~InstrumentUnmaskPromptViewAndroid() {
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| + Java_InstrumentUnmaskBridge_hide(env, java_object_.obj());
|
| +}
|
| +
|
| +void InstrumentUnmaskPromptViewAndroid::Show() {
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| + ui::ViewAndroid* view_android = web_contents_->GetNativeView();
|
| +
|
| + java_object_.Reset(Java_InstrumentUnmaskBridge_create(
|
| + env, reinterpret_cast<intptr_t>(this),
|
| + view_android->GetWindowAndroid()->GetJavaObject().obj()));
|
| +
|
| + Java_InstrumentUnmaskBridge_show(env, java_object_.obj());
|
| +}
|
| +
|
| +void InstrumentUnmaskPromptViewAndroid::PromptDismissed(JNIEnv* env,
|
| + jobject obj,
|
| + jstring response) {
|
| + finished_.Run(base::android::ConvertJavaStringToUTF16(env, response));
|
| + // |this| is now deleted.
|
| +}
|
| +
|
| +// static
|
| +bool InstrumentUnmaskPromptViewAndroid::Register(JNIEnv* env) {
|
| + return RegisterNativesImpl(env);
|
| +}
|
| +
|
| +} // namespace autofill
|
|
|