OLD | NEW |
---|---|
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" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
29 #include "chrome/browser/ui/browser_command_controller.h" | 29 #include "chrome/browser/ui/browser_command_controller.h" |
30 #include "chrome/browser/ui/browser_commands.h" | 30 #include "chrome/browser/ui/browser_commands.h" |
31 #include "chrome/browser/ui/browser_instant_controller.h" | 31 #include "chrome/browser/ui/browser_instant_controller.h" |
32 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
33 #include "chrome/browser/ui/browser_window_state.h" | 33 #include "chrome/browser/ui/browser_window_state.h" |
34 #import "chrome/browser/ui/cocoa/background_gradient_view.h" | 34 #import "chrome/browser/ui/cocoa/background_gradient_view.h" |
35 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 35 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
36 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" | 36 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" |
37 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" | 37 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" |
38 #import "chrome/browser/ui/cocoa/browser/avatar_label_controller.h" | |
38 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 39 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
39 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" | 40 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
40 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 41 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
41 #import "chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.h" | 42 #import "chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.h" |
42 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" | 43 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" |
43 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" | 44 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
44 #import "chrome/browser/ui/cocoa/event_utils.h" | 45 #import "chrome/browser/ui/cocoa/event_utils.h" |
45 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h" | 46 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h" |
46 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 47 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
47 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 48 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
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 #if defined(ENABLE_MANAGED_USERS) | |
sail
2013/05/31 17:25:11
Can we get rid of this ifdef from the codebase bef
Adrian Kuegel
2013/05/31 20:28:16
Yes. I removed it, and it looks like it also works
sail
2013/05/31 20:41:44
Can't we just kill this ifdef though?
| |
85 #include "chrome/browser/managed_mode/managed_user_service.h" | |
86 #endif | |
87 | |
83 using l10n_util::GetStringUTF16; | 88 using l10n_util::GetStringUTF16; |
84 using l10n_util::GetNSStringWithFixup; | 89 using l10n_util::GetNSStringWithFixup; |
85 using l10n_util::GetNSStringFWithFixup; | 90 using l10n_util::GetNSStringFWithFixup; |
86 | 91 |
87 // ORGANIZATION: This is a big file. It is (in principle) organized as follows | 92 // ORGANIZATION: This is a big file. It is (in principle) organized as follows |
88 // (in order): | 93 // (in order): |
89 // 1. Interfaces. Very short, one-time-use classes may include an implementation | 94 // 1. Interfaces. Very short, one-time-use classes may include an implementation |
90 // immediately after their interface. | 95 // immediately after their interface. |
91 // 2. The general implementation section, ordered as follows: | 96 // 2. The general implementation section, ordered as follows: |
92 // i. Public methods and overrides. | 97 // i. Public methods and overrides. |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 } | 526 } |
522 | 527 |
523 - (Profile*)profile { | 528 - (Profile*)profile { |
524 return browser_->profile(); | 529 return browser_->profile(); |
525 } | 530 } |
526 | 531 |
527 - (AvatarButtonController*)avatarButtonController { | 532 - (AvatarButtonController*)avatarButtonController { |
528 return avatarButtonController_.get(); | 533 return avatarButtonController_.get(); |
529 } | 534 } |
530 | 535 |
536 - (AvatarLabelController*)avatarLabelController { | |
537 return avatarLabelController_.get(); | |
538 } | |
539 | |
531 - (void)destroyBrowser { | 540 - (void)destroyBrowser { |
532 [NSApp removeWindowsItem:[self window]]; | 541 [NSApp removeWindowsItem:[self window]]; |
533 | 542 |
534 // We need the window to go away now. | 543 // We need the window to go away now. |
535 // We can't actually use |-autorelease| here because there's an embedded | 544 // We can't actually use |-autorelease| here because there's an embedded |
536 // run loop in the |-performClose:| which contains its own autorelease pool. | 545 // run loop in the |-performClose:| which contains its own autorelease pool. |
537 // Instead call it after a zero-length delay, which gets us back to the main | 546 // Instead call it after a zero-length delay, which gets us back to the main |
538 // event loop. | 547 // event loop. |
539 [self performSelector:@selector(autorelease) | 548 [self performSelector:@selector(autorelease) |
540 withObject:nil | 549 withObject:nil |
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1611 } | 1620 } |
1612 | 1621 |
1613 - (void)onTabDetachedWithContents:(WebContents*)contents { | 1622 - (void)onTabDetachedWithContents:(WebContents*)contents { |
1614 [infoBarContainerController_ tabDetachedWithContents:contents]; | 1623 [infoBarContainerController_ tabDetachedWithContents:contents]; |
1615 } | 1624 } |
1616 | 1625 |
1617 - (void)userChangedTheme { | 1626 - (void)userChangedTheme { |
1618 // TODO(dmaclach): Instead of redrawing the whole window, views that care | 1627 // TODO(dmaclach): Instead of redrawing the whole window, views that care |
1619 // about the active window state should be registering for notifications. | 1628 // about the active window state should be registering for notifications. |
1620 [[self window] setViewsNeedDisplay:YES]; | 1629 [[self window] setViewsNeedDisplay:YES]; |
1630 if (avatarLabelController_.get()) | |
1631 [avatarLabelController_ updateColors:[self themeProvider]]; | |
1621 } | 1632 } |
1622 | 1633 |
1623 - (ui::ThemeProvider*)themeProvider { | 1634 - (ui::ThemeProvider*)themeProvider { |
1624 return ThemeServiceFactory::GetForProfile(browser_->profile()); | 1635 return ThemeServiceFactory::GetForProfile(browser_->profile()); |
1625 } | 1636 } |
1626 | 1637 |
1627 - (ThemedWindowStyle)themedWindowStyle { | 1638 - (ThemedWindowStyle)themedWindowStyle { |
1628 ThemedWindowStyle style = 0; | 1639 ThemedWindowStyle style = 0; |
1629 if (browser_->profile()->IsOffTheRecord()) | 1640 if (browser_->profile()->IsOffTheRecord()) |
1630 style |= THEMED_INCOGNITO; | 1641 style |= THEMED_INCOGNITO; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1712 | 1723 |
1713 // 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 |
1714 // 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 |
1715 // coordinate as the tab strip. | 1726 // coordinate as the tab strip. |
1716 - (void)installAvatar { | 1727 - (void)installAvatar { |
1717 // 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 |
1718 // 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 |
1719 // image to display based on the browser. | 1730 // image to display based on the browser. |
1720 avatarButtonController_.reset( | 1731 avatarButtonController_.reset( |
1721 [[AvatarButtonController alloc] initWithBrowser:browser_.get()]); | 1732 [[AvatarButtonController alloc] initWithBrowser:browser_.get()]); |
1733 if (browser_.get() && | |
1734 ManagedUserService::ProfileIsManaged(browser_->profile())) { | |
1735 avatarLabelController_.reset( | |
1736 [[AvatarLabelController alloc] init]); | |
1737 [avatarLabelController_ updateColors:[self themeProvider]]; | |
1738 NSView* view = [avatarLabelController_ view]; | |
1739 [view setNeedsDisplay:YES]; | |
1740 [view setHidden:![self shouldShowAvatar]]; | |
1741 | |
1742 // Install the view. | |
1743 [[[[self window] contentView] superview] addSubview:view]; | |
1744 } | |
1745 | |
1722 NSView* view = [avatarButtonController_ view]; | 1746 NSView* view = [avatarButtonController_ view]; |
1723 [view setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; | 1747 [view setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; |
1724 [view setHidden:![self shouldShowAvatar]]; | 1748 [view setHidden:![self shouldShowAvatar]]; |
1725 | 1749 |
1726 // Install the view. | 1750 // Install the view. |
1727 [[[[self window] contentView] superview] addSubview:view]; | 1751 [[[[self window] contentView] superview] addSubview:view]; |
1728 } | 1752 } |
1729 | 1753 |
1730 // Called when we get a three-finger swipe. | 1754 // Called when we get a three-finger swipe. |
1731 - (void)swipeWithEvent:(NSEvent*)event { | 1755 - (void)swipeWithEvent:(NSEvent*)event { |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2228 | 2252 |
2229 - (BOOL)supportsBookmarkBar { | 2253 - (BOOL)supportsBookmarkBar { |
2230 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2254 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2231 } | 2255 } |
2232 | 2256 |
2233 - (BOOL)isTabbedWindow { | 2257 - (BOOL)isTabbedWindow { |
2234 return browser_->is_type_tabbed(); | 2258 return browser_->is_type_tabbed(); |
2235 } | 2259 } |
2236 | 2260 |
2237 @end // @implementation BrowserWindowController(WindowType) | 2261 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |