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

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

Issue 8172011: [Mac] Properly show and hide the avatar button for the one-profile case. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 9 years, 2 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/sync/sync_ui_util_mac.h" 23 #include "chrome/browser/sync/sync_ui_util_mac.h"
24 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" 24 #include "chrome/browser/tab_contents/tab_contents_view_mac.h"
25 #include "chrome/browser/tabs/tab_strip_model.h" 25 #include "chrome/browser/tabs/tab_strip_model.h"
26 #include "chrome/browser/themes/theme_service.h" 26 #include "chrome/browser/themes/theme_service.h"
27 #include "chrome/browser/themes/theme_service_factory.h" 27 #include "chrome/browser/themes/theme_service_factory.h"
28 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_list.h" 29 #include "chrome/browser/ui/browser_list.h"
30 #import "chrome/browser/ui/cocoa/background_gradient_view.h" 30 #import "chrome/browser/ui/cocoa/background_gradient_view.h"
31 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 31 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
32 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" 32 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h"
33 #import "chrome/browser/ui/cocoa/browser/avatar_button.h" 33 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h"
34 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" 34 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
35 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 35 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
36 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 36 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
37 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" 37 #import "chrome/browser/ui/cocoa/dev_tools_controller.h"
38 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" 38 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"
39 #import "chrome/browser/ui/cocoa/event_utils.h" 39 #import "chrome/browser/ui/cocoa/event_utils.h"
40 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 40 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
41 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" 41 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
42 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" 42 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
43 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 43 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 configuration:BookmarkEditor::SHOW_TREE] 1630 configuration:BookmarkEditor::SHOW_TREE]
1631 runAsModalSheet]; 1631 runAsModalSheet];
1632 } 1632 }
1633 } 1633 }
1634 } 1634 }
1635 1635
1636 // If the browser is in incognito mode or has multi-profiles, install the image 1636 // If the browser is in incognito mode or has multi-profiles, install the image
1637 // view to decorate the window at the upper right. Use the same base y 1637 // view to decorate the window at the upper right. Use the same base y
1638 // coordinate as the tab strip. 1638 // coordinate as the tab strip.
1639 - (void)installAvatar { 1639 - (void)installAvatar {
1640 // Only install if this browser window is OTR and has a tab strip. 1640 // Install the image into the badge view. Hide it for now; positioning and
1641 if (![self shouldShowAvatar]) 1641 // sizing will be done by the layout code. The AvatarButton will choose which
1642 return; 1642 // image to display based on the browser.
1643 1643 avatarButtonController_.reset(
1644 // Install the image into the badge view. Hide it for now; positioning, 1644 [[AvatarButtonController alloc] initWithBrowser:browser_.get()]);
1645 // sizing, and showing will be done by the layout code. The AvatarButton will 1645 NSView* view = [avatarButtonController_ view];
1646 // choose which image to display based on the browser. 1646 [view setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin];
1647 avatarButton_.reset([[AvatarButton alloc] initWithBrowser:browser_.get()]); 1647 [view setHidden:![self shouldShowAvatar]];
1648 [avatarButton_ setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin];
1649 [avatarButton_ setHidden:YES];
1650 // The button shouldn't do anything in incognito.
1651 [avatarButton_ setOpenMenuOnClick:!browser_->profile()->IsOffTheRecord()];
1652 1648
1653 // Install the view. 1649 // Install the view.
1654 [[[[self window] contentView] superview] addSubview:avatarButton_]; 1650 [[[[self window] contentView] superview] addSubview:view];
1655 } 1651 }
1656 1652
1657 // Documented in 10.6+, but present starting in 10.5. Called when we get a 1653 // Documented in 10.6+, but present starting in 10.5. Called when we get a
1658 // three-finger swipe. 1654 // three-finger swipe.
1659 - (void)swipeWithEvent:(NSEvent*)event { 1655 - (void)swipeWithEvent:(NSEvent*)event {
1660 CGFloat deltaX = [event deltaX]; 1656 CGFloat deltaX = [event deltaX];
1661 CGFloat deltaY = [event deltaY]; 1657 CGFloat deltaY = [event deltaY];
1662 1658
1663 // Map forwards and backwards to history; left is positive, right is negative. 1659 // Map forwards and backwards to history; left is positive, right is negative.
1664 unsigned int command = 0; 1660 unsigned int command = 0;
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 2133
2138 - (BOOL)supportsBookmarkBar { 2134 - (BOOL)supportsBookmarkBar {
2139 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2135 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2140 } 2136 }
2141 2137
2142 - (BOOL)isTabbedWindow { 2138 - (BOOL)isTabbedWindow {
2143 return browser_->is_type_tabbed(); 2139 return browser_->is_type_tabbed();
2144 } 2140 }
2145 2141
2146 @end // @implementation BrowserWindowController(WindowType) 2142 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | chrome/browser/ui/cocoa/browser_window_controller_private.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698