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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

Issue 15932008: Add managed user avatar menu for mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <numeric> 8 #include <numeric>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/mac/bundle_locations.h" 11 #include "base/mac/bundle_locations.h"
12 #include "base/mac/mac_util.h" 12 #include "base/mac/mac_util.h"
13 #import "base/memory/scoped_nsobject.h" 13 #import "base/memory/scoped_nsobject.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/app/chrome_command_ids.h" // IDC_* 16 #include "chrome/app/chrome_command_ids.h" // IDC_*
17 #include "chrome/browser/bookmarks/bookmark_editor.h" 17 #include "chrome/browser/bookmarks/bookmark_editor.h"
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/devtools/devtools_window.h" 20 #include "chrome/browser/devtools/devtools_window.h"
21 #include "chrome/browser/managed_mode/managed_user_service.h"
21 #include "chrome/browser/profiles/avatar_menu_model.h" 22 #include "chrome/browser/profiles/avatar_menu_model.h"
22 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/profiles/profile_info_cache.h" 24 #include "chrome/browser/profiles/profile_info_cache.h"
24 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/signin/signin_ui_util.h" 26 #include "chrome/browser/signin/signin_ui_util.h"
26 #include "chrome/browser/themes/theme_service.h" 27 #include "chrome/browser/themes/theme_service.h"
27 #include "chrome/browser/themes/theme_service_factory.h" 28 #include "chrome/browser/themes/theme_service_factory.h"
28 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_command_controller.h" 30 #include "chrome/browser/ui/browser_command_controller.h"
30 #include "chrome/browser/ui/browser_commands.h" 31 #include "chrome/browser/ui/browser_commands.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 #include "content/public/browser/render_view_host.h" 74 #include "content/public/browser/render_view_host.h"
74 #include "content/public/browser/render_widget_host_view.h" 75 #include "content/public/browser/render_widget_host_view.h"
75 #include "content/public/browser/web_contents.h" 76 #include "content/public/browser/web_contents.h"
76 #include "grit/chromium_strings.h" 77 #include "grit/chromium_strings.h"
77 #include "grit/generated_resources.h" 78 #include "grit/generated_resources.h"
78 #include "grit/locale_settings.h" 79 #include "grit/locale_settings.h"
79 #include "ui/base/l10n/l10n_util.h" 80 #include "ui/base/l10n/l10n_util.h"
80 #include "ui/base/l10n/l10n_util_mac.h" 81 #include "ui/base/l10n/l10n_util_mac.h"
81 #include "ui/gfx/mac/scoped_ns_disable_screen_updates.h" 82 #include "ui/gfx/mac/scoped_ns_disable_screen_updates.h"
82 83
84
Robert Sesek 2013/06/04 20:59:10 nit: extra blank line
Adrian Kuegel 2013/06/05 16:01:38 Removed.
83 using l10n_util::GetStringUTF16; 85 using l10n_util::GetStringUTF16;
84 using l10n_util::GetNSStringWithFixup; 86 using l10n_util::GetNSStringWithFixup;
85 using l10n_util::GetNSStringFWithFixup; 87 using l10n_util::GetNSStringFWithFixup;
86 88
87 // ORGANIZATION: This is a big file. It is (in principle) organized as follows 89 // ORGANIZATION: This is a big file. It is (in principle) organized as follows
88 // (in order): 90 // (in order):
89 // 1. Interfaces. Very short, one-time-use classes may include an implementation 91 // 1. Interfaces. Very short, one-time-use classes may include an implementation
90 // immediately after their interface. 92 // immediately after their interface.
91 // 2. The general implementation section, ordered as follows: 93 // 2. The general implementation section, ordered as follows:
92 // i. Public methods and overrides. 94 // i. Public methods and overrides.
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 } 1620 }
1619 1621
1620 - (void)onTabDetachedWithContents:(WebContents*)contents { 1622 - (void)onTabDetachedWithContents:(WebContents*)contents {
1621 [infoBarContainerController_ tabDetachedWithContents:contents]; 1623 [infoBarContainerController_ tabDetachedWithContents:contents];
1622 } 1624 }
1623 1625
1624 - (void)userChangedTheme { 1626 - (void)userChangedTheme {
1625 // TODO(dmaclach): Instead of redrawing the whole window, views that care 1627 // TODO(dmaclach): Instead of redrawing the whole window, views that care
1626 // about the active window state should be registering for notifications. 1628 // about the active window state should be registering for notifications.
1627 [[self window] setViewsNeedDisplay:YES]; 1629 [[self window] setViewsNeedDisplay:YES];
1630 if (avatarButtonController_.get())
1631 [avatarButtonController_ updateColors:[self themeProvider]];
1628 } 1632 }
1629 1633
1630 - (ui::ThemeProvider*)themeProvider { 1634 - (ui::ThemeProvider*)themeProvider {
1631 return ThemeServiceFactory::GetForProfile(browser_->profile()); 1635 return ThemeServiceFactory::GetForProfile(browser_->profile());
1632 } 1636 }
1633 1637
1634 - (ThemedWindowStyle)themedWindowStyle { 1638 - (ThemedWindowStyle)themedWindowStyle {
1635 ThemedWindowStyle style = 0; 1639 ThemedWindowStyle style = 0;
1636 if (browser_->profile()->IsOffTheRecord()) 1640 if (browser_->profile()->IsOffTheRecord())
1637 style |= THEMED_INCOGNITO; 1641 style |= THEMED_INCOGNITO;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 1723
1720 // If the browser is in incognito mode or has multi-profiles, install the image 1724 // If the browser is in incognito mode or has multi-profiles, install the image
1721 // view to decorate the window at the upper right. Use the same base y 1725 // view to decorate the window at the upper right. Use the same base y
1722 // coordinate as the tab strip. 1726 // coordinate as the tab strip.
1723 - (void)installAvatar { 1727 - (void)installAvatar {
1724 // Install the image into the badge view. Hide it for now; positioning and 1728 // Install the image into the badge view. Hide it for now; positioning and
1725 // sizing will be done by the layout code. The AvatarButton will choose which 1729 // sizing will be done by the layout code. The AvatarButton will choose which
1726 // image to display based on the browser. 1730 // image to display based on the browser.
1727 avatarButtonController_.reset( 1731 avatarButtonController_.reset(
1728 [[AvatarButtonController alloc] initWithBrowser:browser_.get()]); 1732 [[AvatarButtonController alloc] initWithBrowser:browser_.get()]);
1733 if ([avatarButtonController_ labelView]) {
1734 [avatarButtonController_ updateColors:[self themeProvider]];
1735 NSTextField* label = [avatarButtonController_ labelView];
1736 [label setNeedsDisplay:YES];
1737 [label setHidden:![self shouldShowAvatar]];
1738
1739 // Install the view.
1740 [[[[self window] contentView] superview] addSubview:label];
Robert Sesek 2013/06/04 20:59:10 Why not just have this be in the view that AvatarB
Adrian Kuegel 2013/06/05 16:01:38 Done.
Robert Sesek 2013/06/05 20:59:17 Not sure this was actually done.
Adrian Kuegel 2013/06/07 15:31:26 Yes, you are right, this was not working so far. T
1741 }
1742
1729 NSView* view = [avatarButtonController_ view]; 1743 NSView* view = [avatarButtonController_ view];
1730 [view setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; 1744 [view setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin];
1731 [view setHidden:![self shouldShowAvatar]]; 1745 [view setHidden:![self shouldShowAvatar]];
1732 1746
1733 // Install the view. 1747 // Install the view.
1734 [[[[self window] contentView] superview] addSubview:view]; 1748 [[[[self window] contentView] superview] addSubview:view];
1735 } 1749 }
1736 1750
1737 // Called when we get a three-finger swipe. 1751 // Called when we get a three-finger swipe.
1738 - (void)swipeWithEvent:(NSEvent*)event { 1752 - (void)swipeWithEvent:(NSEvent*)event {
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 2246
2233 - (BOOL)supportsBookmarkBar { 2247 - (BOOL)supportsBookmarkBar {
2234 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2248 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2235 } 2249 }
2236 2250
2237 - (BOOL)isTabbedWindow { 2251 - (BOOL)isTabbedWindow {
2238 return browser_->is_type_tabbed(); 2252 return browser_->is_type_tabbed();
2239 } 2253 }
2240 2254
2241 @end // @implementation BrowserWindowController(WindowType) 2255 @end // @implementation BrowserWindowController(WindowType)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698