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

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: 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 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_util.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"
30 #include "chrome/browser/ui/browser_window.h" 31 #include "chrome/browser/ui/browser_window.h"
31 #include "chrome/browser/ui/chrome_pages.h" 32 #include "chrome/browser/ui/chrome_pages.h"
32 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 33 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
(...skipping 19 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_android.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"
68 #include "content/public/browser/android/content_view_core.h"
65 #endif 69 #endif
66 70
67 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); 71 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient);
68 72
69 namespace autofill { 73 namespace autofill {
70 74
71 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) 75 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents)
72 : content::WebContentsObserver(web_contents), 76 : content::WebContentsObserver(web_contents),
73 unmask_controller_( 77 unmask_controller_(
74 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()), 78 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()),
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 337
334 ssl_status = navigation_entry->GetSSL(); 338 ssl_status = navigation_entry->GetSSL();
335 // Note: If changing the implementation below, also change 339 // Note: If changing the implementation below, also change
336 // AwAutofillClient::IsContextSecure. See crbug.com/505388 340 // AwAutofillClient::IsContextSecure. See crbug.com/505388
337 return ssl_status.security_style == content::SECURITY_STYLE_AUTHENTICATED && 341 return ssl_status.security_style == content::SECURITY_STYLE_AUTHENTICATED &&
338 !(ssl_status.content_status & 342 !(ssl_status.content_status &
339 content::SSLStatus::RAN_INSECURE_CONTENT); 343 content::SSLStatus::RAN_INSECURE_CONTENT);
340 } 344 }
341 345
342 bool ChromeAutofillClient::ShouldShowSigninPromo() { 346 bool ChromeAutofillClient::ShouldShowSigninPromo() {
343 #if defined(OS_ANDROID) || defined(OS_IOS) 347 #if defined(OS_IOS)
344 // TODO(crbug.com/626383): Implement signin promo for Android and iOS by 348 // TODO(crbug.com/626383): Implement signin promo for iOS by changing the
345 // changing the logic of StartSigninFlow() below. 349 // logic of StartSigninFlow() below.
346 return false; 350 return false;
347 #else 351 #elif !defined(OS_ANDROID)
348 return chrome::FindBrowserWithWebContents(web_contents()) && 352 // Determine if we are in a valid context (on desktop platforms, we could be
349 signin::ShouldShowPromo( 353 // in an app window with no Browser).
350 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); 354 if (!chrome::FindBrowserWithWebContents(web_contents()))
355 return false;
351 #endif 356 #endif
357
358 return signin::ShouldShowPromo(
359 Profile::FromBrowserContext(web_contents()->GetBrowserContext()));
352 } 360 }
353 361
354 void ChromeAutofillClient::StartSigninFlow() { 362 void ChromeAutofillClient::StartSigninFlow() {
355 // See ShouldShowSigninPromo. 363 // See ShouldShowSigninPromo.
356 #if !defined(OS_ANDROID) && !defined(OS_IOS) 364 #if defined(OS_IOS)
365 return;
366 #elif defined(OS_ANDROID)
367 chrome::android::SigninPromoUtilAndroid::StartAccountSigninActivityForPromo(
368 content::ContentViewCore::FromWebContents(web_contents()),
369 signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN);
370 #else
357 chrome::FindBrowserWithWebContents(web_contents()) 371 chrome::FindBrowserWithWebContents(web_contents())
358 ->window() 372 ->window()
359 ->ShowAvatarBubbleFromAvatarButton( 373 ->ShowAvatarBubbleFromAvatarButton(
360 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN, 374 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN,
361 signin::ManageAccountsParams(), 375 signin::ManageAccountsParams(),
362 signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN); 376 signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN);
363 #endif 377 #endif
364 } 378 }
365 379
366 } // namespace autofill 380 } // namespace autofill
OLDNEW
« 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