| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/framed_browser_window.h" | 5 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <objc/runtime.h> | 8 #include <objc/runtime.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/mac/foundation_util.h" |
| 12 #include "base/mac/sdk_forward_declarations.h" | 13 #include "base/mac/sdk_forward_declarations.h" |
| 13 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 14 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
| 14 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 15 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 15 #include "chrome/browser/themes/theme_properties.h" | 16 #include "chrome/browser/themes/theme_properties.h" |
| 16 #include "chrome/browser/themes/theme_service.h" | 17 #include "chrome/browser/themes/theme_service.h" |
| 17 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 18 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 18 #import "chrome/browser/ui/cocoa/browser_window_layout.h" | 19 #import "chrome/browser/ui/cocoa/browser_window_layout.h" |
| 20 #import "chrome/browser/ui/cocoa/browser_window_touch_bar.h" |
| 19 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 21 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
| 20 #include "chrome/browser/ui/cocoa/l10n_util.h" | 22 #include "chrome/browser/ui/cocoa/l10n_util.h" |
| 21 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 23 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 22 #import "chrome/browser/ui/cocoa/themed_window.h" | 24 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 23 #include "chrome/grit/theme_resources.h" | 25 #include "chrome/grit/theme_resources.h" |
| 24 #include "ui/base/cocoa/cocoa_base_utils.h" | 26 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 25 #include "ui/base/cocoa/nsgraphics_context_additions.h" | 27 #include "ui/base/cocoa/nsgraphics_context_additions.h" |
| 26 #import "ui/base/cocoa/nsview_additions.h" | 28 #import "ui/base/cocoa/nsview_additions.h" |
| 27 #include "ui/base/material_design/material_design_controller.h" | 29 #import "ui/base/cocoa/touch_bar_forward_declarations.h" |
| 28 | 30 |
| 29 // Implementer's note: Moving the window controls is tricky. When altering the | 31 // Implementer's note: Moving the window controls is tricky. When altering the |
| 30 // code, ensure that: | 32 // code, ensure that: |
| 31 // - accessibility hit testing works | 33 // - accessibility hit testing works |
| 32 // - the accessibility hierarchy is correct | 34 // - the accessibility hierarchy is correct |
| 33 // - close/min in the background don't bring the window forward | 35 // - close/min in the background don't bring the window forward |
| 34 // - rollover effects work correctly | 36 // - rollover effects work correctly |
| 35 | 37 |
| 36 // The NSLayoutConstraint class hierarchy only exists in the 10.11 SDK. When | 38 // The NSLayoutConstraint class hierarchy only exists in the 10.11 SDK. When |
| 37 // targeting something lower, constraintEqualToAnchor:constant: needs to be | 39 // targeting something lower, constraintEqualToAnchor:constant: needs to be |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 if (!hasTabStrip_) | 403 if (!hasTabStrip_) |
| 402 return NSZeroPoint; | 404 return NSZeroPoint; |
| 403 | 405 |
| 404 // Vertically center the button. | 406 // Vertically center the button. |
| 405 NSPoint origin = NSMakePoint(0, -6); | 407 NSPoint origin = NSMakePoint(0, -6); |
| 406 | 408 |
| 407 // If there is a profile avatar icon present, shift the button over by its | 409 // If there is a profile avatar icon present, shift the button over by its |
| 408 // width and some padding. The new avatar button is displayed to the right | 410 // width and some padding. The new avatar button is displayed to the right |
| 409 // of the fullscreen icon, so it doesn't need to be shifted. | 411 // of the fullscreen icon, so it doesn't need to be shifted. |
| 410 BrowserWindowController* bwc = | 412 BrowserWindowController* bwc = |
| 411 static_cast<BrowserWindowController*>([self windowController]); | 413 base::mac::ObjCCastStrict<BrowserWindowController>( |
| 414 [self windowController]); |
| 412 if ([bwc shouldShowAvatar] && ![bwc shouldUseNewAvatarButton]) { | 415 if ([bwc shouldShowAvatar] && ![bwc shouldUseNewAvatarButton]) { |
| 413 NSView* avatarButton = [[bwc avatarButtonController] view]; | 416 NSView* avatarButton = [[bwc avatarButtonController] view]; |
| 414 origin.x = -(NSWidth([avatarButton frame]) + 3); | 417 origin.x = -(NSWidth([avatarButton frame]) + 3); |
| 415 } else { | 418 } else { |
| 416 origin.x -= 6; | 419 origin.x -= 6; |
| 417 } | 420 } |
| 418 | 421 |
| 419 return origin; | 422 return origin; |
| 420 } | 423 } |
| 421 | 424 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 [overlayImage drawAtPoint:NSMakePoint(position.x, | 496 [overlayImage drawAtPoint:NSMakePoint(position.x, |
| 494 position.y - overlaySize.height) | 497 position.y - overlaySize.height) |
| 495 fromRect:imageFrame | 498 fromRect:imageFrame |
| 496 operation:NSCompositeSourceOver | 499 operation:NSCompositeSourceOver |
| 497 fraction:1.0]; | 500 fraction:1.0]; |
| 498 } | 501 } |
| 499 | 502 |
| 500 return themed; | 503 return themed; |
| 501 } | 504 } |
| 502 | 505 |
| 506 - (NSTouchBar*)makeTouchBar { |
| 507 BrowserWindowController* bwc = |
| 508 base::mac::ObjCCastStrict<BrowserWindowController>( |
| 509 [self windowController]); |
| 510 return [[bwc browserWindowTouchBar] makeTouchBar]; |
| 511 } |
| 512 |
| 503 - (NSColor*)titleColor { | 513 - (NSColor*)titleColor { |
| 504 const ui::ThemeProvider* themeProvider = [self themeProvider]; | 514 const ui::ThemeProvider* themeProvider = [self themeProvider]; |
| 505 if (!themeProvider) | 515 if (!themeProvider) |
| 506 return [NSColor windowFrameTextColor]; | 516 return [NSColor windowFrameTextColor]; |
| 507 | 517 |
| 508 ThemedWindowStyle windowStyle = [self themedWindowStyle]; | 518 ThemedWindowStyle windowStyle = [self themedWindowStyle]; |
| 509 BOOL incognito = windowStyle & THEMED_INCOGNITO; | 519 BOOL incognito = windowStyle & THEMED_INCOGNITO; |
| 510 | 520 |
| 511 if (incognito) | 521 if (incognito) |
| 512 return [NSColor whiteColor]; | 522 return [NSColor whiteColor]; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 525 [self childWindowsDidChange]; | 535 [self childWindowsDidChange]; |
| 526 } | 536 } |
| 527 | 537 |
| 528 - (void)childWindowsDidChange { | 538 - (void)childWindowsDidChange { |
| 529 id delegate = [self delegate]; | 539 id delegate = [self delegate]; |
| 530 if ([delegate respondsToSelector:@selector(childWindowsDidChange)]) | 540 if ([delegate respondsToSelector:@selector(childWindowsDidChange)]) |
| 531 [delegate childWindowsDidChange]; | 541 [delegate childWindowsDidChange]; |
| 532 } | 542 } |
| 533 | 543 |
| 534 @end | 544 @end |
| OLD | NEW |