OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/password_manager/auto_signin_first_run_infobar_delegate
.h" | |
6 | |
7 #include "chrome/browser/infobars/infobar_service.h" | |
8 #include "chrome/browser/profiles/profile.h" | |
9 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
10 #include "chrome/browser/ui/android/infobars/auto_signin_first_run_infobar.h" | |
11 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" | |
12 #include "chrome/grit/chromium_strings.h" | |
13 #include "chrome/grit/generated_resources.h" | |
14 #include "components/browser_sync/browser/profile_sync_service.h" | |
15 #include "components/infobars/core/infobar.h" | |
16 #include "components/password_manager/core/browser/password_bubble_experiment.h" | |
17 #include "content/public/browser/web_contents.h" | |
18 #include "ui/base/l10n/l10n_util.h" | |
19 | |
20 // static | |
21 void AutoSigninFirstRunInfoBarDelegate::Create( | |
22 content::WebContents* web_contents, | |
23 const base::string16& message) { | |
24 Profile* profile = | |
25 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
26 bool is_smartlock_branding_enabled = | |
27 password_bubble_experiment::IsSmartLockBrandingEnabled( | |
28 ProfileSyncServiceFactory::GetForProfile(profile)); | |
29 InfoBarService::FromWebContents(web_contents) | |
30 ->AddInfoBar(make_scoped_ptr(new AutoSigninFirstRunInfoBar( | |
31 make_scoped_ptr(new AutoSigninFirstRunInfoBarDelegate( | |
32 web_contents, is_smartlock_branding_enabled, message))))); | |
33 } | |
34 | |
35 AutoSigninFirstRunInfoBarDelegate::AutoSigninFirstRunInfoBarDelegate( | |
36 content::WebContents* web_contents, | |
37 bool is_smartlock_branding_enabled, | |
38 const base::string16& message) | |
39 : PasswordManagerInfoBarDelegate(), web_contents_(web_contents) { | |
40 gfx::Range explanation_link_range; | |
41 GetAutoSigninPromptFirstRunExperienceExplanation( | |
42 is_smartlock_branding_enabled, &explanation_, &explanation_link_range); | |
43 SetMessageLinkRange(explanation_link_range); | |
44 SetMessage(message); | |
45 } | |
46 | |
47 AutoSigninFirstRunInfoBarDelegate::~AutoSigninFirstRunInfoBarDelegate() { | |
48 Profile* profile = | |
49 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | |
50 password_bubble_experiment::RecordAutoSignInPromptFirstRunExperienceWasShown( | |
51 profile->GetPrefs()); | |
52 } | |
53 | |
54 infobars::InfoBarDelegate::InfoBarIdentifier | |
55 AutoSigninFirstRunInfoBarDelegate::GetIdentifier() const { | |
56 return AUTO_SIGNIN_FIRST_RUN_INFOBAR_DELEGATE; | |
57 } | |
58 | |
59 base::string16 AutoSigninFirstRunInfoBarDelegate::GetButtonLabel( | |
60 InfoBarButton button) const { | |
61 return l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_OK_BUTTON); | |
62 } | |
63 | |
64 bool AutoSigninFirstRunInfoBarDelegate::Accept() { | |
65 return true; | |
66 } | |
67 | |
68 bool AutoSigninFirstRunInfoBarDelegate::Cancel() { | |
69 return true; | |
70 } | |
OLD | NEW |