OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/android/autofill/card_unmask_prompt_view_android.h" | 5 #include "chrome/browser/ui/android/autofill/card_unmask_prompt_view_android.h" |
6 | 6 |
7 #include "chrome/browser/android/resource_mapper.h" | 7 #include "chrome/browser/android/resource_mapper.h" |
8 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" | 8 #include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h" |
| 9 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller.h" |
9 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
10 #include "jni/CardUnmaskBridge_jni.h" | 11 #include "jni/CardUnmaskBridge_jni.h" |
11 #include "ui/android/view_android.h" | 12 #include "ui/android/view_android.h" |
12 #include "ui/android/window_android.h" | 13 #include "ui/android/window_android.h" |
13 | 14 |
14 namespace autofill { | 15 namespace autofill { |
15 | 16 |
16 CardUnmaskPromptView* CardUnmaskPromptView::CreateAndShow( | 17 CardUnmaskPromptView* CreateCardUnmaskPromptView( |
17 CardUnmaskPromptController* controller) { | 18 CardUnmaskPromptController* controller, |
18 CardUnmaskPromptViewAndroid* view = | 19 content::WebContents* web_contents) { |
19 new CardUnmaskPromptViewAndroid(controller); | 20 return new CardUnmaskPromptViewAndroid(controller, web_contents); |
20 view->Show(); | |
21 return view; | |
22 } | 21 } |
23 | 22 |
24 CardUnmaskPromptViewAndroid::CardUnmaskPromptViewAndroid( | 23 CardUnmaskPromptViewAndroid::CardUnmaskPromptViewAndroid( |
25 CardUnmaskPromptController* controller) | 24 CardUnmaskPromptController* controller, |
26 : controller_(controller) { | 25 content::WebContents* web_contents) |
| 26 : controller_(controller), web_contents_(web_contents) { |
27 } | 27 } |
28 | 28 |
29 CardUnmaskPromptViewAndroid::~CardUnmaskPromptViewAndroid() { | 29 CardUnmaskPromptViewAndroid::~CardUnmaskPromptViewAndroid() { |
30 if (controller_) | 30 if (controller_) |
31 controller_->OnUnmaskDialogClosed(); | 31 controller_->OnUnmaskDialogClosed(); |
32 } | 32 } |
33 | 33 |
34 void CardUnmaskPromptViewAndroid::Show() { | 34 void CardUnmaskPromptViewAndroid::Show() { |
35 JNIEnv* env = base::android::AttachCurrentThread(); | 35 JNIEnv* env = base::android::AttachCurrentThread(); |
36 ui::ViewAndroid* view_android = | 36 ui::ViewAndroid* view_android = web_contents_->GetNativeView(); |
37 controller_->GetWebContents()->GetNativeView(); | |
38 | 37 |
39 ScopedJavaLocalRef<jstring> dialog_title = | 38 ScopedJavaLocalRef<jstring> dialog_title = |
40 base::android::ConvertUTF16ToJavaString(env, | 39 base::android::ConvertUTF16ToJavaString(env, |
41 controller_->GetWindowTitle()); | 40 controller_->GetWindowTitle()); |
42 ScopedJavaLocalRef<jstring> instructions = | 41 ScopedJavaLocalRef<jstring> instructions = |
43 base::android::ConvertUTF16ToJavaString( | 42 base::android::ConvertUTF16ToJavaString( |
44 env, controller_->GetInstructionsMessage()); | 43 env, controller_->GetInstructionsMessage()); |
45 java_object_.Reset(Java_CardUnmaskBridge_create( | 44 java_object_.Reset(Java_CardUnmaskBridge_create( |
46 env, reinterpret_cast<intptr_t>(this), dialog_title.obj(), | 45 env, reinterpret_cast<intptr_t>(this), dialog_title.obj(), |
47 instructions.obj(), | 46 instructions.obj(), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 Java_CardUnmaskBridge_verificationFinished(env, java_object_.obj(), | 99 Java_CardUnmaskBridge_verificationFinished(env, java_object_.obj(), |
101 message.obj(), allow_retry); | 100 message.obj(), allow_retry); |
102 } | 101 } |
103 | 102 |
104 // static | 103 // static |
105 bool CardUnmaskPromptViewAndroid::Register(JNIEnv* env) { | 104 bool CardUnmaskPromptViewAndroid::Register(JNIEnv* env) { |
106 return RegisterNativesImpl(env); | 105 return RegisterNativesImpl(env); |
107 } | 106 } |
108 | 107 |
109 } // namespace autofill | 108 } // namespace autofill |
OLD | NEW |