Index: chrome/browser/password_manager/auto_signin_first_run_infobar_delegate.cc |
diff --git a/chrome/browser/password_manager/auto_signin_first_run_infobar_delegate.cc b/chrome/browser/password_manager/auto_signin_first_run_infobar_delegate.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e8fd3b9850272aac0ea224dda3b2afbcf5b914c3 |
--- /dev/null |
+++ b/chrome/browser/password_manager/auto_signin_first_run_infobar_delegate.cc |
@@ -0,0 +1,65 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/password_manager/auto_signin_first_run_infobar_delegate.h" |
+ |
+#include "chrome/browser/infobars/infobar_service.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/sync/profile_sync_service.h" |
+#include "chrome/browser/sync/profile_sync_service_factory.h" |
+#include "chrome/browser/ui/android/infobars/auto_signin_first_run_infobar.h" |
+#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" |
+#include "chrome/grit/chromium_strings.h" |
+#include "chrome/grit/generated_resources.h" |
+#include "components/infobars/core/infobar.h" |
+#include "components/password_manager/core/browser/password_bubble_experiment.h" |
+#include "content/public/browser/web_contents.h" |
+#include "ui/base/l10n/l10n_util.h" |
+ |
+// static |
+void AutoSigninFirstRunInfobarDelegate::Create( |
+ content::WebContents* web_contents, |
+ const base::string16& message) { |
+ Profile* profile = |
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
+ bool is_smartlock_branding_enabled = |
+ password_bubble_experiment::IsSmartLockBrandingEnabled( |
+ ProfileSyncServiceFactory::GetForProfile(profile)); |
+ InfoBarService::FromWebContents(web_contents) |
+ ->AddInfoBar(make_scoped_ptr(new AutoSigninFirstRunInfobar( |
+ make_scoped_ptr(new AutoSigninFirstRunInfobarDelegate( |
+ web_contents, is_smartlock_branding_enabled, message))))); |
+} |
+ |
+AutoSigninFirstRunInfobarDelegate::AutoSigninFirstRunInfobarDelegate( |
+ content::WebContents* web_contents, |
+ bool is_smartlock_branding_enabled, |
+ const base::string16& message) |
+ : PasswordManagerInfoBarDelegate(), web_contents_(web_contents) { |
+ gfx::Range explanation_link_range; |
+ GetAutoSigninPromptFirstRunExperienceExplanation( |
+ is_smartlock_branding_enabled, &explanation_, &explanation_link_range); |
+ SetMessageLinkRange(explanation_link_range); |
+ SetMessage(message); |
+} |
+ |
+AutoSigninFirstRunInfobarDelegate::~AutoSigninFirstRunInfobarDelegate() { |
+ Profile* profile = |
+ Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
+ password_bubble_experiment::RecordAutoSignInPromptFirstRunExperienceWasShown( |
+ profile->GetPrefs()); |
+} |
+ |
+base::string16 AutoSigninFirstRunInfobarDelegate::GetButtonLabel( |
+ InfoBarButton button) const { |
+ return l10n_util::GetStringUTF16(IDS_ONE_CLICK_SIGNIN_DIALOG_OK_BUTTON); |
+} |
+ |
+bool AutoSigninFirstRunInfobarDelegate::Accept() { |
+ return true; |
+} |
+ |
+bool AutoSigninFirstRunInfobarDelegate::Cancel() { |
+ return true; |
+} |