Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3212)

Unified Diff: chrome/browser/ui/autofill/chrome_autofill_client.cc

Issue 2138643004: [Autofill] Add support for signin promo on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@aaa
Patch Set: nits Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/chrome_autofill_client.cc
diff --git a/chrome/browser/ui/autofill/chrome_autofill_client.cc b/chrome/browser/ui/autofill/chrome_autofill_client.cc
index a79166311efe32669afdebd5c6642d63c06c0a4f..a297373e01503eeabff6a5dc59edb1204b7b87b2 100644
--- a/chrome/browser/ui/autofill/chrome_autofill_client.cc
+++ b/chrome/browser/ui/autofill/chrome_autofill_client.cc
@@ -17,9 +17,10 @@
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/password_manager/chrome_password_manager_client.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/signin/signin_promo.h"
+#include "chrome/browser/signin/signin_promo_util.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
#include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h"
@@ -59,9 +60,12 @@
#endif
#if defined(OS_ANDROID)
+#include "base/android/context_utils.h"
+#include "chrome/browser/android/signin/signin_promo_util_android.h"
#include "components/autofill/core/browser/autofill_save_card_infobar_delegate_mobile.h"
#include "components/autofill/core/browser/autofill_save_card_infobar_mobile.h"
#include "components/infobars/core/infobar.h"
+#include "content/public/browser/android/content_view_core.h"
#endif
DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient);
@@ -340,20 +344,30 @@ bool ChromeAutofillClient::IsContextSecure(const GURL& form_origin) {
}
bool ChromeAutofillClient::ShouldShowSigninPromo() {
-#if defined(OS_ANDROID) || defined(OS_IOS)
- // TODO(crbug.com/626383): Implement signin promo for Android and iOS by
- // changing the logic of StartSigninFlow() below.
+#if defined(OS_IOS)
+ // TODO(crbug.com/626383): Implement signin promo for iOS by changing the
+ // logic of StartSigninFlow() below.
return false;
-#else
- return chrome::FindBrowserWithWebContents(web_contents()) &&
- signin::ShouldShowPromo(
- Profile::FromBrowserContext(web_contents()->GetBrowserContext()));
+#elif !defined(OS_ANDROID)
+ // Determine if we are in a valid context (on desktop platforms, we could be
+ // in an app window with no Browser).
+ if (!chrome::FindBrowserWithWebContents(web_contents()))
+ return false;
#endif
+
+ return signin::ShouldShowPromo(
+ Profile::FromBrowserContext(web_contents()->GetBrowserContext()));
}
void ChromeAutofillClient::StartSigninFlow() {
// See ShouldShowSigninPromo.
-#if !defined(OS_ANDROID) && !defined(OS_IOS)
+#if defined(OS_IOS)
+ return;
+#elif defined(OS_ANDROID)
+ chrome::android::SigninPromoUtilAndroid::StartAccountSigninActivityForPromo(
+ content::ContentViewCore::FromWebContents(web_contents()),
+ signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN);
+#else
chrome::FindBrowserWithWebContents(web_contents())
->window()
->ShowAvatarBubbleFromAvatarButton(
« no previous file with comments | « chrome/browser/ui/android/autofill/autofill_popup_view_android.cc ('k') | chrome/browser/ui/sync/sync_promo_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698