OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/base/cocoa/appkit_utils.h" | 5 #import "ui/base/cocoa/appkit_utils.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 16 matching lines...) Expand all Loading... |
27 NSImage* GetImage(int image_id) { | 27 NSImage* GetImage(int image_id) { |
28 return ui::ResourceBundle::GetSharedInstance() | 28 return ui::ResourceBundle::GetSharedInstance() |
29 .GetNativeImageNamed(image_id) | 29 .GetNativeImageNamed(image_id) |
30 .ToNSImage(); | 30 .ToNSImage(); |
31 } | 31 } |
32 | 32 |
33 // The action to take when the user double-clicks in the window title bar. | 33 // The action to take when the user double-clicks in the window title bar. |
34 DoubleClickAction WindowTitleBarDoubleClickAction() { | 34 DoubleClickAction WindowTitleBarDoubleClickAction() { |
35 // El Capitan introduced a Dock preference to configure the window title bar | 35 // El Capitan introduced a Dock preference to configure the window title bar |
36 // double-click action (Minimize, Maximize, or nothing). | 36 // double-click action (Minimize, Maximize, or nothing). |
37 if (base::mac::IsOSElCapitanOrLater()) { | 37 if (base::mac::IsAtLeastOS10_11()) { |
38 NSString* doubleClickAction = [[NSUserDefaults standardUserDefaults] | 38 NSString* doubleClickAction = [[NSUserDefaults standardUserDefaults] |
39 objectForKey:@"AppleActionOnDoubleClick"]; | 39 objectForKey:@"AppleActionOnDoubleClick"]; |
40 | 40 |
41 if ([doubleClickAction isEqualToString:@"Minimize"]) { | 41 if ([doubleClickAction isEqualToString:@"Minimize"]) { |
42 return DoubleClickAction::MINIMIZE; | 42 return DoubleClickAction::MINIMIZE; |
43 } else if ([doubleClickAction isEqualToString:@"Maximize"]) { | 43 } else if ([doubleClickAction isEqualToString:@"Maximize"]) { |
44 return DoubleClickAction::MAXIMIZE; | 44 return DoubleClickAction::MAXIMIZE; |
45 } | 45 } |
46 | 46 |
47 return DoubleClickAction::NONE; | 47 return DoubleClickAction::NONE; |
48 } | 48 } |
49 | 49 |
50 // Determine minimize using an undocumented method in Cocoa. If we're | 50 // Determine minimize using an undocumented method in Cocoa. If we're |
51 // running on an earlier version of the OS that doesn't implement it, | 51 // running on an earlier version of the OS that doesn't implement it, |
52 // just default to the minimize action. | 52 // just default to the minimize action. |
53 BOOL methodImplemented = | 53 BOOL methodImplemented = |
54 [NSWindow respondsToSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; | 54 [NSWindow respondsToSelector:@selector(_shouldMiniaturizeOnDoubleClick)]; |
55 if (!methodImplemented || | 55 if (!methodImplemented || |
56 [NSWindow performSelector:@selector(_shouldMiniaturizeOnDoubleClick)]) { | 56 [NSWindow performSelector:@selector(_shouldMiniaturizeOnDoubleClick)]) { |
57 return DoubleClickAction::MINIMIZE; | 57 return DoubleClickAction::MINIMIZE; |
58 } | 58 } |
59 | 59 |
60 // At this point _shouldMiniaturizeOnDoubleClick has returned |NO|. On | 60 // At this point _shouldMiniaturizeOnDoubleClick has returned |NO|. On |
61 // Yosemite, that means a double-click should Maximize the window, and on | 61 // Yosemite, that means a double-click should Maximize the window, and on |
62 // all prior OSes a double-click should do nothing. | 62 // all prior OSes a double-click should do nothing. |
63 return base::mac::IsOSYosemite() ? DoubleClickAction::MAXIMIZE | 63 return base::mac::IsOS10_10() ? DoubleClickAction::MAXIMIZE |
64 : DoubleClickAction::NONE; | 64 : DoubleClickAction::NONE; |
65 } | 65 } |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 namespace ui { | 69 namespace ui { |
70 | 70 |
71 void DrawNinePartImage(NSRect frame, | 71 void DrawNinePartImage(NSRect frame, |
72 const NinePartImageIds& image_ids, | 72 const NinePartImageIds& image_ids, |
73 NSCompositingOperation operation, | 73 NSCompositingOperation operation, |
74 CGFloat alpha, | 74 CGFloat alpha, |
(...skipping 28 matching lines...) Expand all Loading... |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 bool ForceClickInvokesQuickLook() { | 106 bool ForceClickInvokesQuickLook() { |
107 return [[NSUserDefaults standardUserDefaults] | 107 return [[NSUserDefaults standardUserDefaults] |
108 integerForKey:@"com.apple.trackpad.forceClick"] == | 108 integerForKey:@"com.apple.trackpad.forceClick"] == |
109 static_cast<NSInteger>(ForceTouchAction::QUICK_LOOK); | 109 static_cast<NSInteger>(ForceTouchAction::QUICK_LOOK); |
110 } | 110 } |
111 | 111 |
112 } // namespace ui | 112 } // namespace ui |
OLD | NEW |