| 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" |
| 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 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1618 } | 1619 } |
| 1619 | 1620 |
| 1620 - (void)onTabDetachedWithContents:(WebContents*)contents { | 1621 - (void)onTabDetachedWithContents:(WebContents*)contents { |
| 1621 [infoBarContainerController_ tabDetachedWithContents:contents]; | 1622 [infoBarContainerController_ tabDetachedWithContents:contents]; |
| 1622 } | 1623 } |
| 1623 | 1624 |
| 1624 - (void)userChangedTheme { | 1625 - (void)userChangedTheme { |
| 1625 // TODO(dmaclach): Instead of redrawing the whole window, views that care | 1626 // TODO(dmaclach): Instead of redrawing the whole window, views that care |
| 1626 // about the active window state should be registering for notifications. | 1627 // about the active window state should be registering for notifications. |
| 1627 [[self window] setViewsNeedDisplay:YES]; | 1628 [[self window] setViewsNeedDisplay:YES]; |
| 1629 if (avatarButtonController_.get()) |
| 1630 [avatarButtonController_ updateColors:[self themeProvider]]; |
| 1628 } | 1631 } |
| 1629 | 1632 |
| 1630 - (ui::ThemeProvider*)themeProvider { | 1633 - (ui::ThemeProvider*)themeProvider { |
| 1631 return ThemeServiceFactory::GetForProfile(browser_->profile()); | 1634 return ThemeServiceFactory::GetForProfile(browser_->profile()); |
| 1632 } | 1635 } |
| 1633 | 1636 |
| 1634 - (ThemedWindowStyle)themedWindowStyle { | 1637 - (ThemedWindowStyle)themedWindowStyle { |
| 1635 ThemedWindowStyle style = 0; | 1638 ThemedWindowStyle style = 0; |
| 1636 if (browser_->profile()->IsOffTheRecord()) | 1639 if (browser_->profile()->IsOffTheRecord()) |
| 1637 style |= THEMED_INCOGNITO; | 1640 style |= THEMED_INCOGNITO; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 | 1722 |
| 1720 // If the browser is in incognito mode or has multi-profiles, install the image | 1723 // 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 | 1724 // view to decorate the window at the upper right. Use the same base y |
| 1722 // coordinate as the tab strip. | 1725 // coordinate as the tab strip. |
| 1723 - (void)installAvatar { | 1726 - (void)installAvatar { |
| 1724 // Install the image into the badge view. Hide it for now; positioning and | 1727 // 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 | 1728 // sizing will be done by the layout code. The AvatarButton will choose which |
| 1726 // image to display based on the browser. | 1729 // image to display based on the browser. |
| 1727 avatarButtonController_.reset( | 1730 avatarButtonController_.reset( |
| 1728 [[AvatarButtonController alloc] initWithBrowser:browser_.get()]); | 1731 [[AvatarButtonController alloc] initWithBrowser:browser_.get()]); |
| 1732 if ([avatarButtonController_ labelView]) { |
| 1733 [avatarButtonController_ updateColors:[self themeProvider]]; |
| 1734 NSTextField* label = [avatarButtonController_ labelView]; |
| 1735 [label setNeedsDisplay:YES]; |
| 1736 [label setHidden:![self shouldShowAvatar]]; |
| 1737 |
| 1738 // Install the view. |
| 1739 [[avatarButtonController_ view] addSubview:label]; |
| 1740 } |
| 1741 |
| 1729 NSView* view = [avatarButtonController_ view]; | 1742 NSView* view = [avatarButtonController_ view]; |
| 1730 [view setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; | 1743 [view setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; |
| 1731 [view setHidden:![self shouldShowAvatar]]; | 1744 [view setHidden:![self shouldShowAvatar]]; |
| 1732 | 1745 |
| 1733 // Install the view. | 1746 // Install the view. |
| 1734 [[[[self window] contentView] superview] addSubview:view]; | 1747 [[[[self window] contentView] superview] addSubview:view]; |
| 1735 } | 1748 } |
| 1736 | 1749 |
| 1737 // Called when we get a three-finger swipe. | 1750 // Called when we get a three-finger swipe. |
| 1738 - (void)swipeWithEvent:(NSEvent*)event { | 1751 - (void)swipeWithEvent:(NSEvent*)event { |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2232 | 2245 |
| 2233 - (BOOL)supportsBookmarkBar { | 2246 - (BOOL)supportsBookmarkBar { |
| 2234 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2247 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2235 } | 2248 } |
| 2236 | 2249 |
| 2237 - (BOOL)isTabbedWindow { | 2250 - (BOOL)isTabbedWindow { |
| 2238 return browser_->is_type_tabbed(); | 2251 return browser_->is_type_tabbed(); |
| 2239 } | 2252 } |
| 2240 | 2253 |
| 2241 @end // @implementation BrowserWindowController(WindowType) | 2254 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |