OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/infobars/account_chooser_infobar.h" | 5 #include "chrome/browser/ui/android/infobars/account_chooser_infobar.h" |
6 | 6 |
7 #include "base/android/scoped_java_ref.h" | 7 #include "base/android/scoped_java_ref.h" |
8 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 8 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro
id.h" | 10 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro
id.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 CreateNativeCredentialArray(env, credential_array_size); | 107 CreateNativeCredentialArray(env, credential_array_size); |
108 AddElementsToJavaCredentialArray( | 108 AddElementsToJavaCredentialArray( |
109 env, java_credentials_array, GetDelegate()->local_credentials_forms(), | 109 env, java_credentials_array, GetDelegate()->local_credentials_forms(), |
110 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); | 110 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); |
111 AddElementsToJavaCredentialArray( | 111 AddElementsToJavaCredentialArray( |
112 env, java_credentials_array, GetDelegate()->federated_credentials_forms(), | 112 env, java_credentials_array, GetDelegate()->federated_credentials_forms(), |
113 password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED, | 113 password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED, |
114 GetDelegate()->local_credentials_forms().size()); | 114 GetDelegate()->local_credentials_forms().size()); |
115 base::android::ScopedJavaGlobalRef<jobject> java_infobar_global; | 115 base::android::ScopedJavaGlobalRef<jobject> java_infobar_global; |
116 java_infobar_global.Reset(Java_AccountChooserInfoBar_show( | 116 java_infobar_global.Reset(Java_AccountChooserInfoBar_show( |
117 env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(), | 117 env, GetEnumeratedIconId(), java_credentials_array.obj())); |
118 java_credentials_array.obj())); | |
119 base::android::ScopedJavaLocalRef<jobject> java_infobar(java_infobar_global); | 118 base::android::ScopedJavaLocalRef<jobject> java_infobar(java_infobar_global); |
120 content::WebContents* web_contents = | 119 content::WebContents* web_contents = |
121 InfoBarService::WebContentsFromInfoBar(this); | 120 InfoBarService::WebContentsFromInfoBar(this); |
122 net::URLRequestContextGetter* request_context = | 121 net::URLRequestContextGetter* request_context = |
123 Profile::FromBrowserContext(web_contents->GetBrowserContext()) | 122 Profile::FromBrowserContext(web_contents->GetBrowserContext()) |
124 ->GetRequestContext(); | 123 ->GetRequestContext(); |
125 FetchAvatars(java_infobar_global, GetDelegate()->local_credentials_forms(), 0, | 124 FetchAvatars(java_infobar_global, GetDelegate()->local_credentials_forms(), 0, |
126 request_context); | 125 request_context); |
127 FetchAvatars( | 126 FetchAvatars( |
128 java_infobar_global, GetDelegate()->federated_credentials_forms(), | 127 java_infobar_global, GetDelegate()->federated_credentials_forms(), |
(...skipping 17 matching lines...) Expand all Loading... |
146 return; // We're closing; don't call anything, it might access the owner. | 145 return; // We're closing; don't call anything, it might access the owner. |
147 GetDelegate()->ChooseCredential( | 146 GetDelegate()->ChooseCredential( |
148 -1, password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY); | 147 -1, password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY); |
149 RemoveSelf(); | 148 RemoveSelf(); |
150 } | 149 } |
151 | 150 |
152 AccountChooserInfoBarDelegateAndroid* AccountChooserInfoBar::GetDelegate() { | 151 AccountChooserInfoBarDelegateAndroid* AccountChooserInfoBar::GetDelegate() { |
153 return static_cast<AccountChooserInfoBarDelegateAndroid*>(delegate()); | 152 return static_cast<AccountChooserInfoBarDelegateAndroid*>(delegate()); |
154 } | 153 } |
155 | 154 |
| 155 void AccountChooserInfoBar::SetJavaInfoBar( |
| 156 const base::android::JavaRef<jobject>& java_info_bar) { |
| 157 InfoBarAndroid::SetJavaInfoBar(java_info_bar); |
| 158 JNIEnv* env = base::android::AttachCurrentThread(); |
| 159 Java_AccountChooserInfoBar_setNativePtr(env, java_info_bar.obj(), |
| 160 reinterpret_cast<intptr_t>(this)); |
| 161 } |
| 162 |
156 bool RegisterAccountChooserInfoBar(JNIEnv* env) { | 163 bool RegisterAccountChooserInfoBar(JNIEnv* env) { |
157 return RegisterNativesImpl(env); | 164 return RegisterNativesImpl(env); |
158 } | 165 } |
OLD | NEW |