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

Unified Diff: chrome/browser/ui/cocoa/profiles/avatar_icon_controller.mm

Issue 1631283002: [Mac] Remove some dead avatar menu code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 11 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: chrome/browser/ui/cocoa/profiles/avatar_icon_controller.mm
diff --git a/chrome/browser/ui/cocoa/profiles/avatar_icon_controller.mm b/chrome/browser/ui/cocoa/profiles/avatar_icon_controller.mm
index 120abec0385f5532f5cd6c8409f1389921e502d2..7ca3c2c03183624a33cafd443d65b8d9f5bfd247 100644
--- a/chrome/browser/ui/cocoa/profiles/avatar_icon_controller.mm
+++ b/chrome/browser/ui/cocoa/profiles/avatar_icon_controller.mm
@@ -14,9 +14,6 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_window.h"
-#import "chrome/browser/ui/cocoa/browser_window_controller.h"
-#import "chrome/browser/ui/cocoa/profiles/avatar_label_button.h"
#include "chrome/grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -24,33 +21,10 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
-namespace {
-
-// Space between the avatar label and the left edge of the container containing
-// the label and the icon.
-const CGFloat kAvatarSpacing = 4;
-
-// Space between the bottom of the avatar icon and the bottom of the avatar
-// label.
-const CGFloat kAvatarLabelBottomSpacing = 3;
-
-// Space between the right edge of the avatar label and the right edge of the
-// avatar icon.
-const CGFloat kAvatarLabelRightSpacing = 2;
-
-} // namespace
-
@interface AvatarIconController (Private)
- (void)setButtonEnabled:(BOOL)flag;
- (NSImage*)compositeImageWithShadow:(NSImage*)image;
- (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent;
-- (void)addOrRemoveButtonIfNecessary;
-@end
-
-// Declare a 10.7+ private API.
-// NSThemeFrame < NSTitledFrame < NSFrameView < NSView.
-@interface NSView (NSThemeFrame)
-- (void)_tileTitlebarAndRedisplay:(BOOL)redisplay;
@end
@implementation AvatarIconController
@@ -100,58 +74,16 @@ const CGFloat kAvatarLabelRightSpacing = 2;
l10n_util::GetNSString(IDS_PROFILES_BUBBLE_ACCESSIBLE_DESCRIPTION)
forAttribute:NSAccessibilityDescriptionAttribute];
- Profile* profile = browser_->profile();
-
- if (profile->IsOffTheRecord() || profile->IsGuestSession()) {
- const int icon_id = profile->IsGuestSession() ?
- profiles::GetPlaceholderAvatarIconResourceID() : IDR_OTR_ICON;
- NSImage* icon = ResourceBundle::GetSharedInstance().GetNativeImageNamed(
- icon_id).ToNSImage();
- [self setImage:[self compositeImageWithShadow:icon]];
- [self setButtonEnabled:profile->IsGuestSession()];
- } else {
- [self setButtonEnabled:YES];
- [self updateAvatarButtonAndLayoutParent:NO];
-
- // Supervised users cannot enter incognito mode, so we only need to check
- // it in this code path.
- if (profile->IsSupervised()) {
- // Initialize the avatar label button.
- CGFloat extraWidth =
- profiles::kAvatarIconWidth + kAvatarLabelRightSpacing;
- NSRect frame = NSMakeRect(
- kAvatarSpacing, kAvatarLabelBottomSpacing, extraWidth, 0);
- labelButton_.reset([[AvatarLabelButton alloc] initWithFrame:frame]);
- [labelButton_ setTarget:self];
- [labelButton_ setAction:@selector(buttonClicked:)];
- [[self view] addSubview:labelButton_];
-
- // Resize the container and reposition the avatar button.
- NSSize textSize = [[labelButton_ cell] labelTextSize];
- [container setFrameSize:
- NSMakeSize([labelButton_ frame].size.width + kAvatarSpacing,
- profiles::kAvatarIconHeight)];
- [button_
- setFrameOrigin:NSMakePoint(kAvatarSpacing + textSize.width, 0)];
- }
- }
+ NSImage* icon = ResourceBundle::GetSharedInstance().GetNativeImageNamed(
+ IDR_OTR_ICON).ToNSImage();
+ [button_ setImage:[self compositeImageWithShadow:icon]];
+ [button_ setEnabled:NO];
+
[[self view] addSubview:button_];
}
return self;
}
-- (NSButton*)labelButtonView {
- return labelButton_.get();
-}
-
-- (void)setImage:(NSImage*)image {
- [button_ setImage:image];
-}
-
-- (void)setButtonEnabled:(BOOL)flag {
- [button_ setEnabled:flag];
-}
-
// This will take in an original image and redraw it with a shadow.
- (NSImage*)compositeImageWithShadow:(NSImage*)image {
gfx::ScopedNSGraphicsContextSaveGState scopedGState;
@@ -183,64 +115,6 @@ const CGFloat kAvatarLabelRightSpacing = 2;
return destination.autorelease();
}
-// Updates the avatar information from the profile cache.
-- (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent {
- // No updates are needed for an incognito or guest window, as the avatar
- // is always fixed.
- Profile* profile = browser_->profile();
- if (profile->IsOffTheRecord() || profile->IsGuestSession())
- return;
-
- ProfileInfoCache& cache =
- g_browser_process->profile_manager()->GetProfileInfoCache();
- size_t index =
- cache.GetIndexOfProfileWithPath(browser_->profile()->GetPath());
- if (index == std::string::npos)
- return;
-
- BOOL is_gaia_picture =
- cache.IsUsingGAIAPictureOfProfileAtIndex(index) &&
- cache.GetGAIAPictureOfProfileAtIndex(index);
- gfx::Image icon = profiles::GetAvatarIconForTitleBar(
- cache.GetAvatarIconOfProfileAtIndex(index), is_gaia_picture,
- profiles::kAvatarIconWidth, profiles::kAvatarIconHeight);
- [self setImage:icon.ToNSImage()];
-
- const base::string16& name = cache.GetNameOfProfileAtIndex(index);
- NSString* nsName = base::SysUTF16ToNSString(name);
- [button_ setToolTip:nsName];
- [[button_ cell]
- accessibilitySetOverrideValue:nsName
- forAttribute:NSAccessibilityValueAttribute];
- if (layoutParent)
- [self addOrRemoveButtonIfNecessary];
-}
-
-// If the second-to-last profile was removed or a second profile was added,
-// show or hide the avatar button from the window frame.
-- (void)addOrRemoveButtonIfNecessary {
- if (browser_->profile()->IsOffTheRecord())
- return;
-
- BrowserWindowController* wc = base::mac::ObjCCast<BrowserWindowController>(
- [browser_->window()->GetNativeWindow() windowController]);
- if (!wc)
- return;
-
- [self.view setHidden:![wc shouldShowAvatar]];
-
- // If the avatar is being added or removed, then the Lion fullscreen button
- // needs to be adjusted. Since the fullscreen button is positioned by
- // FramedBrowserWindow using private APIs, the easiest way to update the
- // position of the button is through this private API. Resizing the window
- // also works, but invoking |-display| does not.
- NSView* themeFrame = [[[wc window] contentView] superview];
- if ([themeFrame respondsToSelector:@selector(_tileTitlebarAndRedisplay:)])
- [themeFrame _tileTitlebarAndRedisplay:YES];
-
- // This needs to be called after the fullscreen button is positioned, because
- // TabStripController's rightIndentForControls depends on it.
- [wc layoutSubviews];
-}
+- (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent {}
@end
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h ('k') | chrome/browser/ui/cocoa/profiles/avatar_label_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698