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

Unified Diff: ios/chrome/browser/passwords/ios_chrome_password_manager_infobar_delegate.mm

Issue 2108593002: Create superclass for IOSChromeSavePasswordInfobarDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review rd 2 Created 4 years, 6 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: ios/chrome/browser/passwords/ios_chrome_password_manager_infobar_delegate.mm
diff --git a/ios/chrome/browser/passwords/ios_chrome_password_manager_infobar_delegate.mm b/ios/chrome/browser/passwords/ios_chrome_password_manager_infobar_delegate.mm
new file mode 100644
index 0000000000000000000000000000000000000000..d88064322633d9fb39485c95960e07fca3a9eb1d
--- /dev/null
+++ b/ios/chrome/browser/passwords/ios_chrome_password_manager_infobar_delegate.mm
@@ -0,0 +1,62 @@
+// Copyright 2016 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.
+
+#import "ios/chrome/browser/passwords/ios_chrome_password_manager_infobar_delegate.h"
+
+#include <utility>
+
+#include "base/mac/scoped_nsobject.h"
+#include "base/strings/string16.h"
+#include "components/password_manager/core/browser/password_form_manager.h"
+#include "components/password_manager/core/browser/password_manager_constants.h"
+#include "components/strings/grit/components_strings.h"
+#import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
+#import "ios/chrome/browser/ui/commands/open_url_command.h"
+#include "ios/chrome/grit/ios_strings.h"
+#include "ios/chrome/grit/ios_theme_resources.h"
+#include "ios/web/public/referrer.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "url/gurl.h"
+
+IOSChromePasswordManagerInfoBarDelegate::
+ ~IOSChromePasswordManagerInfoBarDelegate() {
+ password_manager::metrics_util::LogUIDismissalReason(infobar_response_);
+};
+
+IOSChromePasswordManagerInfoBarDelegate::
+ IOSChromePasswordManagerInfoBarDelegate(
+ bool is_smart_lock_branding_enabled,
+ std::unique_ptr<password_manager::PasswordFormManager> form_to_save)
+ : form_to_save_(std::move(form_to_save)),
+ infobar_response_(password_manager::metrics_util::NO_DIRECT_INTERACTION),
+ is_smart_lock_branding_enabled_(is_smart_lock_branding_enabled) {}
+
+infobars::InfoBarDelegate::Type
+IOSChromePasswordManagerInfoBarDelegate::GetInfoBarType() const {
+ return PAGE_ACTION_TYPE;
+};
+
+base::string16 IOSChromePasswordManagerInfoBarDelegate::GetLinkText() const {
+ return is_smart_lock_branding_enabled_
+ ? l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK)
+ : base::string16();
+};
+
+int IOSChromePasswordManagerInfoBarDelegate::GetIconId() const {
+ return IDR_IOS_INFOBAR_SAVE_PASSWORD;
+};
+
+bool IOSChromePasswordManagerInfoBarDelegate::LinkClicked(
+ WindowOpenDisposition disposition) {
+ base::scoped_nsobject<OpenUrlCommand> command([[OpenUrlCommand alloc]
+ initWithURL:GURL(password_manager::kPasswordManagerHelpCenterSmartLock)
+ referrer:web::Referrer()
+ windowName:nil
+ inIncognito:NO
+ inBackground:NO
+ appendTo:kCurrentTab]);
+ UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];
+ [mainWindow chromeExecuteCommand:command];
+ return true;
+};

Powered by Google App Engine
This is Rietveld 408576698