| OLD | NEW |
| 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/bookmarks/bookmark_bar_folder_window.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" |
| 6 | 6 |
| 7 #import "base/logging.h" | 7 #import "base/logging.h" |
| 8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" |
| 11 #include "chrome/grit/generated_resources.h" |
| 11 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h" | 12 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h" |
| 13 #include "ui/base/l10n/l10n_util_mac.h" |
| 12 #include "ui/base/material_design/material_design_controller.h" | 14 #include "ui/base/material_design/material_design_controller.h" |
| 13 | 15 |
| 14 using bookmarks::kBookmarkBarMenuCornerRadius; | 16 using bookmarks::kBookmarkBarMenuCornerRadius; |
| 15 | 17 |
| 16 namespace { | 18 namespace { |
| 17 | 19 |
| 18 // Material Design bookmark folder window background white. | 20 // Material Design bookmark folder window background white. |
| 19 const CGFloat kMDFolderWindowBackgroundColor = 237. / 255.; | 21 const CGFloat kMDFolderWindowBackgroundColor = 237. / 255.; |
| 20 | 22 |
| 21 } // namespace | 23 } // namespace |
| 22 | 24 |
| 25 @interface BookmarkBarFolderWindow (Accessibility) |
| 26 |
| 27 - (NSString*)accessibilityTitle; |
| 28 |
| 29 @end |
| 30 |
| 23 @implementation BookmarkBarFolderWindow | 31 @implementation BookmarkBarFolderWindow |
| 24 | 32 |
| 25 - (id)initWithContentRect:(NSRect)contentRect | 33 - (id)initWithContentRect:(NSRect)contentRect |
| 26 styleMask:(NSUInteger)windowStyle | 34 styleMask:(NSUInteger)windowStyle |
| 27 backing:(NSBackingStoreType)bufferingType | 35 backing:(NSBackingStoreType)bufferingType |
| 28 defer:(BOOL)deferCreation { | 36 defer:(BOOL)deferCreation { |
| 29 if ((self = [super initWithContentRect:contentRect | 37 if ((self = [super initWithContentRect:contentRect |
| 30 styleMask:NSBorderlessWindowMask // override | 38 styleMask:NSBorderlessWindowMask // override |
| 31 backing:bufferingType | 39 backing:bufferingType |
| 32 defer:deferCreation])) { | 40 defer:deferCreation])) { |
| 33 [self setBackgroundColor:[NSColor clearColor]]; | 41 [self setBackgroundColor:[NSColor clearColor]]; |
| 34 [self setOpaque:NO]; | 42 [self setOpaque:NO]; |
| 35 } | 43 } |
| 36 return self; | 44 return self; |
| 37 } | 45 } |
| 38 | 46 |
| 39 - (BOOL)canBecomeKeyWindow { | 47 - (BOOL)canBecomeKeyWindow { |
| 40 return YES; | 48 return YES; |
| 41 } | 49 } |
| 42 | 50 |
| 43 - (BOOL)canBecomeMainWindow { | 51 - (BOOL)canBecomeMainWindow { |
| 44 return NO; | 52 return NO; |
| 45 } | 53 } |
| 46 | 54 |
| 47 // Override of keyDown as the NSWindow default implementation beeps. | 55 // Override of keyDown as the NSWindow default implementation beeps. |
| 48 - (void)keyDown:(NSEvent *)theEvent { | 56 - (void)keyDown:(NSEvent *)theEvent { |
| 49 } | 57 } |
| 50 | 58 |
| 59 // If the menu doesn't have a separate accessibleTitle, it will get announced as |
| 60 // its normal window title, which is "BmbPopUpWindow". |
| 61 - (NSString*)accessibilityTitle { |
| 62 return l10n_util::GetNSString(IDS_ACCNAME_BOOKMARKS_MENU); |
| 63 } |
| 64 |
| 51 @end | 65 @end |
| 52 | 66 |
| 53 | 67 |
| 54 @implementation BookmarkBarFolderWindowContentView | 68 @implementation BookmarkBarFolderWindowContentView |
| 55 | 69 |
| 56 + (NSColor*)backgroundColor { | 70 + (NSColor*)backgroundColor { |
| 57 DCHECK(ui::MaterialDesignController::IsModeMaterial()); | 71 DCHECK(ui::MaterialDesignController::IsModeMaterial()); |
| 58 static NSColor* backgroundColor = | 72 static NSColor* backgroundColor = |
| 59 [[NSColor colorWithGenericGamma22White:kMDFolderWindowBackgroundColor | 73 [[NSColor colorWithGenericGamma22White:kMDFolderWindowBackgroundColor |
| 60 alpha:1.0] retain]; | 74 alpha:1.0] retain]; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // window. However that also allows some scrollWheel: events to leak | 112 // window. However that also allows some scrollWheel: events to leak |
| 99 // into the NSWindow behind it (even in a different application). | 113 // into the NSWindow behind it (even in a different application). |
| 100 // Better to plug the scroll leak than to round corners for M5. | 114 // Better to plug the scroll leak than to round corners for M5. |
| 101 - (void)scrollWheel:(NSEvent *)theEvent { | 115 - (void)scrollWheel:(NSEvent *)theEvent { |
| 102 DCHECK([[[self window] windowController] | 116 DCHECK([[[self window] windowController] |
| 103 respondsToSelector:@selector(scrollWheel:)]); | 117 respondsToSelector:@selector(scrollWheel:)]); |
| 104 [[[self window] windowController] scrollWheel:theEvent]; | 118 [[[self window] windowController] scrollWheel:theEvent]; |
| 105 } | 119 } |
| 106 | 120 |
| 107 @end | 121 @end |
| OLD | NEW |