Commit e875b9d4 authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS] Add profile avatar to SigninNotificationInfobarDelegate.

Adds the user's profile image in the signed-in notification infobar.

Bug: 1145592
Change-Id: If70abf051c2cbee54381f4646c499c7d55ae3675
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521622Reviewed-by: default avatarChris Lu <thegreenfrog@chromium.org>
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825218}
parent 1a0289a3
......@@ -18,16 +18,25 @@
#import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/signin/authentication_service.h"
#import "ios/chrome/browser/signin/authentication_service_factory.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/chrome/grit/ios_chromium_strings.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/signin/chrome_identity.h"
#include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// Avatar profile picture size.
const CGFloat kAvatarImageDimension = 40.0f;
} // namespace
// static
bool SigninNotificationInfoBarDelegate::Create(
infobars::InfoBarManager* infobar_manager,
......@@ -48,6 +57,13 @@ SigninNotificationInfoBarDelegate::SigninNotificationInfoBarDelegate(
DCHECK(auth_service);
ChromeIdentity* identity = auth_service->GetAuthenticatedIdentity();
UIImage* image = ios::GetChromeBrowserProvider()
->GetChromeIdentityService()
->GetCachedAvatarForIdentity(identity);
if (!image) {
image = [UIImage imageNamed:@"ios_default_avatar"];
}
icon_ = gfx::Image(CircularImageFromImage(image, kAvatarImageDimension));
message_ = base::SysNSStringToUTF16(l10n_util::GetNSStringF(
IDS_IOS_SIGNIN_ACCOUNT_NOTIFICATION_TITLE_WITH_USERNAME,
base::SysNSStringToUTF16(identity.userFullName)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment