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..a2a19c9e5e66cac70cc79af8a3fb6baf15b2b54a |
--- /dev/null |
+++ b/chrome/browser/ui/android/autofill/instrument_unmask_prompt_view_android.cc |
@@ -0,0 +1,56 @@ |
+// 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 { |
+ |
+InstrumentUnmaskPromptView* |
+InstrumentUnmaskPromptView::CreateAndShow(content::WebContents* web_contents, |
+ const UnmaskCallback& finished) { |
+ InstrumentUnmaskPromptViewAndroid* view = |
+ new InstrumentUnmaskPromptViewAndroid(web_contents, finished); |
+ view->Show(); |
+ return view; |
+} |
+ |
+InstrumentUnmaskPromptViewAndroid::InstrumentUnmaskPromptViewAndroid( |
+ content::WebContents* web_contents, |
+ const UnmaskCallback& finished) |
+ : web_contents_(web_contents), finished_(finished) { |
+} |
+ |
+InstrumentUnmaskPromptViewAndroid::~InstrumentUnmaskPromptViewAndroid() { |
+ finished_.Run(response_); |
+} |
+ |
+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) { |
+ response_ = base::android::ConvertJavaStringToUTF16(env, response); |
+ delete this; |
+} |
+ |
+// static |
+bool InstrumentUnmaskPromptViewAndroid::Register(JNIEnv* env) { |
+ return RegisterNativesImpl(env); |
+} |
+ |
+} // namespace autofill |