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

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

Issue 117533002: [Mac] Redesign of the avatar menu button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 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/mac/sdk_forward_declarations.h" 13 #import "base/mac/sdk_forward_declarations.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/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_model_factory.h" 17 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/devtools/devtools_window.h" 19 #include "chrome/browser/devtools/devtools_window.h"
20 #include "chrome/browser/fullscreen.h" 20 #include "chrome/browser/fullscreen.h"
21 #include "chrome/browser/profiles/avatar_menu.h" 21 #include "chrome/browser/profiles/avatar_menu.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/profiles/profile_info_cache.h" 23 #include "chrome/browser/profiles/profile_info_cache.h"
24 #include "chrome/browser/profiles/profile_manager.h" 24 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/profiles/profiles_state.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/bookmarks/bookmark_editor.h" 29 #include "chrome/browser/ui/bookmarks/bookmark_editor.h"
29 #include "chrome/browser/ui/browser.h" 30 #include "chrome/browser/ui/browser.h"
30 #include "chrome/browser/ui/browser_command_controller.h" 31 #include "chrome/browser/ui/browser_command_controller.h"
31 #include "chrome/browser/ui/browser_commands.h" 32 #include "chrome/browser/ui/browser_commands.h"
32 #include "chrome/browser/ui/browser_instant_controller.h" 33 #include "chrome/browser/ui/browser_instant_controller.h"
33 #include "chrome/browser/ui/browser_list.h" 34 #include "chrome/browser/ui/browser_list.h"
34 #include "chrome/browser/ui/browser_window_state.h" 35 #include "chrome/browser/ui/browser_window_state.h"
35 #import "chrome/browser/ui/cocoa/background_gradient_view.h" 36 #import "chrome/browser/ui/cocoa/background_gradient_view.h"
36 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 37 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
37 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" 38 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h"
38 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" 39 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h"
40 #import "chrome/browser/ui/cocoa/browser/avatar_icon_controller.h"
39 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" 41 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
40 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 42 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
41 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 43 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
42 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" 44 #import "chrome/browser/ui/cocoa/dev_tools_controller.h"
43 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" 45 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"
44 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h" 46 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h"
45 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 47 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
46 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" 48 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
47 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" 49 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
48 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 50 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
(...skipping 12 matching lines...) Expand all
61 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 63 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
62 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 64 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
63 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 65 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
64 #include "chrome/browser/ui/omnibox/location_bar.h" 66 #include "chrome/browser/ui/omnibox/location_bar.h"
65 #include "chrome/browser/ui/tabs/dock_info.h" 67 #include "chrome/browser/ui/tabs/dock_info.h"
66 #include "chrome/browser/ui/tabs/tab_strip_model.h" 68 #include "chrome/browser/ui/tabs/tab_strip_model.h"
67 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" 69 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
68 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 70 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
69 #include "chrome/browser/ui/window_sizer/window_sizer.h" 71 #include "chrome/browser/ui/window_sizer/window_sizer.h"
70 #include "chrome/common/chrome_switches.h" 72 #include "chrome/common/chrome_switches.h"
73 #include "chrome/common/profile_management_switches.h"
71 #include "chrome/common/url_constants.h" 74 #include "chrome/common/url_constants.h"
72 #include "components/web_modal/web_contents_modal_dialog_manager.h" 75 #include "components/web_modal/web_contents_modal_dialog_manager.h"
73 #include "content/public/browser/render_view_host.h" 76 #include "content/public/browser/render_view_host.h"
74 #include "content/public/browser/render_widget_host_view.h" 77 #include "content/public/browser/render_widget_host_view.h"
75 #include "content/public/browser/web_contents.h" 78 #include "content/public/browser/web_contents.h"
76 #include "content/public/browser/web_contents_view.h" 79 #include "content/public/browser/web_contents_view.h"
77 #include "content/public/common/content_switches.h" 80 #include "content/public/common/content_switches.h"
78 #include "grit/chromium_strings.h" 81 #include "grit/chromium_strings.h"
79 #include "grit/generated_resources.h" 82 #include "grit/generated_resources.h"
80 #include "grit/locale_settings.h" 83 #include "grit/locale_settings.h"
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 ProfileInfoCache& cache = 1493 ProfileInfoCache& cache =
1491 g_browser_process->profile_manager()->GetProfileInfoCache(); 1494 g_browser_process->profile_manager()->GetProfileInfoCache();
1492 if (cache.GetIndexOfProfileWithPath(browser_->profile()->GetPath()) == 1495 if (cache.GetIndexOfProfileWithPath(browser_->profile()->GetPath()) ==
1493 std::string::npos) { 1496 std::string::npos) {
1494 return NO; 1497 return NO;
1495 } 1498 }
1496 1499
1497 return AvatarMenu::ShouldShowAvatarMenu(); 1500 return AvatarMenu::ShouldShowAvatarMenu();
1498 } 1501 }
1499 1502
1503 - (BOOL)shouldUseNewAvatarButton {
1504 return switches::IsNewProfileManagement() &&
1505 profiles::IsRegularOrGuestSession(browser_.get());
1506 }
1507
1500 - (BOOL)isBookmarkBarVisible { 1508 - (BOOL)isBookmarkBarVisible {
1501 return [bookmarkBarController_ isVisible]; 1509 return [bookmarkBarController_ isVisible];
1502 } 1510 }
1503 1511
1504 - (BOOL)isBookmarkBarAnimating { 1512 - (BOOL)isBookmarkBarAnimating {
1505 return [bookmarkBarController_ isAnimationRunning]; 1513 return [bookmarkBarController_ isAnimationRunning];
1506 } 1514 }
1507 1515
1508 - (BookmarkBarController*)bookmarkBarController { 1516 - (BookmarkBarController*)bookmarkBarController {
1509 return bookmarkBarController_; 1517 return bookmarkBarController_;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 BookmarkEditor::EditDetails::EditNode(node), 1711 BookmarkEditor::EditDetails::EditNode(node),
1704 BookmarkEditor::SHOW_TREE); 1712 BookmarkEditor::SHOW_TREE);
1705 } 1713 }
1706 } 1714 }
1707 1715
1708 // If the browser is in incognito mode or has multi-profiles, install the image 1716 // If the browser is in incognito mode or has multi-profiles, install the image
1709 // view to decorate the window at the upper right. Use the same base y 1717 // view to decorate the window at the upper right. Use the same base y
1710 // coordinate as the tab strip. 1718 // coordinate as the tab strip.
1711 - (void)installAvatar { 1719 - (void)installAvatar {
1712 // Install the image into the badge view. Hide it for now; positioning and 1720 // Install the image into the badge view. Hide it for now; positioning and
1713 // sizing will be done by the layout code. The AvatarButton will choose which 1721 // sizing will be done by the layout code. The AvatarIcon will choose which
1714 // image to display based on the browser. 1722 // image to display based on the browser. The AvatarButton will display
1715 avatarButtonController_.reset( 1723 // the browser profile's name unless the browser is incognito.
1724 NSView* view;
1725 if ([self shouldUseNewAvatarButton]) {
1726 avatarButtonController_.reset(
1716 [[AvatarButtonController alloc] initWithBrowser:browser_.get()]); 1727 [[AvatarButtonController alloc] initWithBrowser:browser_.get()]);
1717 1728 } else {
1718 NSView* view = [avatarButtonController_ view]; 1729 avatarButtonController_.reset(
1730 [[AvatarIconController alloc] initWithBrowser:browser_.get()]);
1731 }
1732 view = [avatarButtonController_ view];
1719 [view setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; 1733 [view setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin];
1720 [view setHidden:![self shouldShowAvatar]]; 1734 [view setHidden:![self shouldShowAvatar]];
1721 1735
1722 // Install the view. 1736 // Install the view.
1723 [[[[self window] contentView] superview] addSubview:view]; 1737 [[[[self window] contentView] superview] addSubview:view];
1724 } 1738 }
1725 1739
1726 // Called when we get a three-finger swipe. 1740 // Called when we get a three-finger swipe.
1727 - (void)swipeWithEvent:(NSEvent*)event { 1741 - (void)swipeWithEvent:(NSEvent*)event {
1728 CGFloat deltaX = [event deltaX]; 1742 CGFloat deltaX = [event deltaX];
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 2242
2229 - (BOOL)supportsBookmarkBar { 2243 - (BOOL)supportsBookmarkBar {
2230 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2244 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2231 } 2245 }
2232 2246
2233 - (BOOL)isTabbedWindow { 2247 - (BOOL)isTabbedWindow {
2234 return browser_->is_type_tabbed(); 2248 return browser_->is_type_tabbed();
2235 } 2249 }
2236 2250
2237 @end // @implementation BrowserWindowController(WindowType) 2251 @end // @implementation BrowserWindowController(WindowType)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698