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

Side by Side 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: fix return type 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 unified diff | Download patch
OLDNEW
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/autofill/chrome_autofill_client.h" 5 #include "chrome/browser/ui/autofill/chrome_autofill_client.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/autofill/personal_data_manager_factory.h" 14 #include "chrome/browser/autofill/personal_data_manager_factory.h"
15 #include "chrome/browser/autofill/risk_util.h" 15 #include "chrome/browser/autofill/risk_util.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/infobars/infobar_service.h" 17 #include "chrome/browser/infobars/infobar_service.h"
18 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 18 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
21 #include "chrome/browser/signin/signin_manager_factory.h" 22 #include "chrome/browser/signin/signin_manager_factory.h"
22 #include "chrome/browser/signin/signin_promo.h" 23 #include "chrome/browser/signin/signin_promo.h"
23 #include "chrome/browser/sync/profile_sync_service_factory.h" 24 #include "chrome/browser/sync/profile_sync_service_factory.h"
24 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" 25 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
25 #include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h" 26 #include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h"
26 #include "chrome/browser/ui/autofill/credit_card_scanner_controller.h" 27 #include "chrome/browser/ui/autofill/credit_card_scanner_controller.h"
27 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" 28 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h"
28 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_finder.h" 30 #include "chrome/browser/ui/browser_finder.h"
(...skipping 22 matching lines...) Expand all
52 53
53 #if BUILDFLAG(ANDROID_JAVA_UI) 54 #if BUILDFLAG(ANDROID_JAVA_UI)
54 #include "chrome/browser/android/chrome_application.h" 55 #include "chrome/browser/android/chrome_application.h"
55 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" 56 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h"
56 #else 57 #else
57 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 58 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
58 #include "components/zoom/zoom_controller.h" 59 #include "components/zoom/zoom_controller.h"
59 #endif 60 #endif
60 61
61 #if defined(OS_ANDROID) 62 #if defined(OS_ANDROID)
63 #include "base/android/context_utils.h"
64 #include "chrome/browser/android/signin/signin_promo_util.h"
62 #include "components/autofill/core/browser/autofill_save_card_infobar_delegate_m obile.h" 65 #include "components/autofill/core/browser/autofill_save_card_infobar_delegate_m obile.h"
63 #include "components/autofill/core/browser/autofill_save_card_infobar_mobile.h" 66 #include "components/autofill/core/browser/autofill_save_card_infobar_mobile.h"
64 #include "components/infobars/core/infobar.h" 67 #include "components/infobars/core/infobar.h"
65 #endif 68 #endif
66 69
67 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); 70 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient);
68 71
69 namespace autofill { 72 namespace autofill {
70 73
71 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) 74 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents)
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 336
334 ssl_status = navigation_entry->GetSSL(); 337 ssl_status = navigation_entry->GetSSL();
335 // Note: If changing the implementation below, also change 338 // Note: If changing the implementation below, also change
336 // AwAutofillClient::IsContextSecure. See crbug.com/505388 339 // AwAutofillClient::IsContextSecure. See crbug.com/505388
337 return ssl_status.security_style == content::SECURITY_STYLE_AUTHENTICATED && 340 return ssl_status.security_style == content::SECURITY_STYLE_AUTHENTICATED &&
338 !(ssl_status.content_status & 341 !(ssl_status.content_status &
339 content::SSLStatus::RAN_INSECURE_CONTENT); 342 content::SSLStatus::RAN_INSECURE_CONTENT);
340 } 343 }
341 344
342 bool ChromeAutofillClient::ShouldShowSigninPromo() { 345 bool ChromeAutofillClient::ShouldShowSigninPromo() {
343 #if defined(OS_ANDROID) || defined(OS_IOS) 346 #if defined(OS_IOS)
344 // TODO(crbug.com/626383): Implement signin promo for Android and iOS by 347 // TODO(crbug.com/626383): Implement sign-in promo for iOS by changing the
345 // changing the logic of StartSigninFlow() below. 348 // logic of StartSigninFlow() below.
346 return false; 349 return false;
350 #elif defined(OS_ANDROID)
351 // On Android, we show the promo if the user is signed out and not currently
352 // signing in.
353 Profile* profile = ProfileManager::GetActiveUserProfile();
354 SigninManager* signin = SigninManagerFactory::GetForProfile(profile);
355 return !signin->AuthInProgress() && signin->IsSigninAllowed() &&
Evan Stade 2016/07/12 18:16:22 this looks suspiciously similar to the implementat
Mathieu 2016/07/12 18:47:25 Unfortunately signing_promo.h/cc is not included o
356 !signin->IsAuthenticated();
347 #else 357 #else
348 return chrome::FindBrowserWithWebContents(web_contents()) && 358 return chrome::FindBrowserWithWebContents(web_contents()) &&
349 signin::ShouldShowPromo( 359 signin::ShouldShowPromo(
350 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); 360 Profile::FromBrowserContext(web_contents()->GetBrowserContext()));
351 #endif 361 #endif
352 } 362 }
353 363
354 void ChromeAutofillClient::StartSigninFlow() { 364 void ChromeAutofillClient::StartSigninFlow() {
355 // See ShouldShowSigninPromo. 365 // See ShouldShowSigninPromo.
356 #if !defined(OS_ANDROID) && !defined(OS_IOS) 366 #if defined(OS_IOS)
367 return;
368 #elif defined(OS_ANDROID)
369 chrome::android::SigninPromoUtil::OpenAccountSigninActivityForPromo(
370 signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN);
371 #else
357 chrome::FindBrowserWithWebContents(web_contents()) 372 chrome::FindBrowserWithWebContents(web_contents())
358 ->window() 373 ->window()
359 ->ShowAvatarBubbleFromAvatarButton( 374 ->ShowAvatarBubbleFromAvatarButton(
360 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN, 375 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN,
361 signin::ManageAccountsParams(), 376 signin::ManageAccountsParams(),
362 signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN); 377 signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN);
363 #endif 378 #endif
364 } 379 }
365 380
366 } // namespace autofill 381 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/autofill/autofill_popup_view_android.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698