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 // This is a little icky. If the menu doesn't have a separate accessibleTitle, | |
60 // it will get announced as its normal window title, which is "BmbPopUpWindow". | |
61 // Instead, reuse the bookmark chevron's label for the menu that it spawns. | |
62 - (NSString*)accessibilityTitle { | |
63 return l10n_util::GetNSString(IDS_ACCNAME_BOOKMARKS_CHEVRON); | |
Avi (use Gerrit)
2016/09/08 14:43:30
But this is "Menu containing hidden bookmarks", wh
| |
64 } | |
65 | |
51 @end | 66 @end |
52 | 67 |
53 | 68 |
54 @implementation BookmarkBarFolderWindowContentView | 69 @implementation BookmarkBarFolderWindowContentView |
55 | 70 |
56 + (NSColor*)backgroundColor { | 71 + (NSColor*)backgroundColor { |
57 DCHECK(ui::MaterialDesignController::IsModeMaterial()); | 72 DCHECK(ui::MaterialDesignController::IsModeMaterial()); |
58 static NSColor* backgroundColor = | 73 static NSColor* backgroundColor = |
59 [[NSColor colorWithGenericGamma22White:kMDFolderWindowBackgroundColor | 74 [[NSColor colorWithGenericGamma22White:kMDFolderWindowBackgroundColor |
60 alpha:1.0] retain]; | 75 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 | 113 // window. However that also allows some scrollWheel: events to leak |
99 // into the NSWindow behind it (even in a different application). | 114 // into the NSWindow behind it (even in a different application). |
100 // Better to plug the scroll leak than to round corners for M5. | 115 // Better to plug the scroll leak than to round corners for M5. |
101 - (void)scrollWheel:(NSEvent *)theEvent { | 116 - (void)scrollWheel:(NSEvent *)theEvent { |
102 DCHECK([[[self window] windowController] | 117 DCHECK([[[self window] windowController] |
103 respondsToSelector:@selector(scrollWheel:)]); | 118 respondsToSelector:@selector(scrollWheel:)]); |
104 [[[self window] windowController] scrollWheel:theEvent]; | 119 [[[self window] windowController] scrollWheel:theEvent]; |
105 } | 120 } |
106 | 121 |
107 @end | 122 @end |
OLD | NEW |