Chromium Code Reviews| Index: chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm b/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm |
| index 2377b86d59389f9620980de11e65ff1ff571f308..0804f1c519b62f5994c96bbf649d1c7dd69ce3ae 100644 |
| --- a/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm |
| +++ b/chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm |
| @@ -11,6 +11,7 @@ |
| #include "chrome/browser/profiles/profile_attributes_storage.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/profiles/profiles_state.h" |
| +#include "chrome/browser/sync/profile_sync_service_factory.h" |
| #include "chrome/browser/themes/theme_service.h" |
| #include "chrome/browser/themes/theme_service_factory.h" |
| #include "chrome/browser/ui/browser.h" |
| @@ -18,15 +19,21 @@ |
| #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| #import "chrome/browser/ui/cocoa/profiles/avatar_button.h" |
| #include "chrome/grit/generated_resources.h" |
| +#include "components/browser_sync/browser/profile_sync_service.h" |
| #include "components/signin/core/browser/signin_error_controller.h" |
| +#include "components/signin/core/common/profile_management_switches.h" |
| +#include "components/sync_driver/sync_error_controller.h" |
| #include "grit/theme_resources.h" |
| #import "ui/base/cocoa/appkit_utils.h" |
| #include "ui/base/l10n/l10n_util_mac.h" |
| #include "ui/base/material_design/material_design_controller.h" |
| #include "ui/base/nine_image_painter_factory.h" |
| #include "ui/base/resource/resource_bundle.h" |
| +#include "ui/gfx/color_palette.h" |
| #include "ui/gfx/image/image_skia_operations.h" |
| #include "ui/gfx/image/image_skia_util_mac.h" |
| +#include "ui/gfx/paint_vector_icon.h" |
| +#include "ui/gfx/vector_icons_public.h" |
| namespace { |
| @@ -163,10 +170,22 @@ NSImage* GetImageFromResourceID(int resourceId) { |
| [[CustomThemeButtonCell alloc] initWithThemedWindow:isThemedWindow_]); |
| [avatarButton setCell:cell.get()]; |
| - // Check if the account already has an authentication error. |
| - SigninErrorController* errorController = |
| + // Check if the account already has an authentication or sync error. |
| + SigninErrorController* signinErrorController = |
| profiles::GetSigninErrorController(browser->profile()); |
| - hasError_ = errorController && errorController->HasError(); |
| + hasError_ = signinErrorController && signinErrorController->HasError(); |
| + ProfileSyncService* syncService = |
|
groby-ooo-7-16
2016/07/22 23:53:16
Probably shareable as well?
|
| + ProfileSyncServiceFactory::GetForProfile(browser->profile()); |
| + if (switches::IsMaterialDesignUserMenu() && syncService) { |
| + SyncErrorController* syncErrorController = |
| + syncService->sync_error_controller(); |
| + ProfileSyncService::Status status; |
| + syncService->QueryDetailedSyncStatus(&status); |
| + hasError_ |= |
| + (syncService->HasUnrecoverableError() || |
| + status.sync_protocol_error.action == syncer::UPGRADE_CLIENT || |
| + (syncErrorController && syncErrorController->HasError())); |
| + } |
| [avatarButton setWantsLayer:YES]; |
| [self setView:avatarButton]; |
| @@ -260,12 +279,15 @@ NSImage* GetImageFromResourceID(int resourceId) { |
| [button setImage:GetImageFromResourceID(IDR_AVATAR_NATIVE_BUTTON_AVATAR)]; |
| [button setImagePosition:NSImageOnly]; |
| } else if (hasError_) { |
| - [button setDefaultImage:GetImageFromResourceID( |
| - IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR)]; |
| + NSImage* errorIcon = |
| + switches::IsMaterialDesignUserMenu() |
| + ? NSImageFromImageSkia(gfx::CreateVectorIcon( |
| + gfx::VectorIconId::SYNC_PROBLEM, 13, gfx::kGoogleRed700)) |
| + : GetImageFromResourceID(IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR); |
| + [button setDefaultImage:errorIcon]; |
| [button setHoverImage:nil]; |
| [button setPressedImage:nil]; |
| - [button setImage:GetImageFromResourceID( |
| - IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR)]; |
| + [button setImage:errorIcon]; |
| [button setImagePosition:NSImageRight]; |
| } else { |
| [button setDefaultImage:nil]; |