Index: ui/views/cocoa/bridged_content_view.mm |
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm |
index 6d72fef5cf7ece1d35262f4b7b1a572622710f05..5203e098d5b5861347fb431e5433bf4b390753d7 100644 |
--- a/ui/views/cocoa/bridged_content_view.mm |
+++ b/ui/views/cocoa/bridged_content_view.mm |
@@ -32,6 +32,9 @@ using views::MenuController; |
namespace { |
+NSString* const kFullKeyboardAccessChangedNotification = |
+ @"com.apple.KeyboardUIModeDidChange"; |
+ |
// Returns true if all four corners of |rect| are contained inside |path|. |
bool IsRectInsidePath(NSRect rect, NSBezierPath* path) { |
return [path containsPoint:rect.origin] && |
@@ -185,6 +188,9 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
domCode:(ui::DomCode)domCode |
eventFlags:(int)eventFlags; |
+// Notification handler invoked when the Full Keyboard Access mode is changed. |
+- (void)onFullKeyboardAccessModeChanged:(NSNotification*)notification; |
+ |
// Menu action handlers. |
- (void)undo:(id)sender; |
- (void)redo:(id)sender; |
@@ -221,6 +227,17 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
owner:self |
userInfo:nil]); |
[self addTrackingArea:cursorTrackingArea_.get()]; |
+ |
+ // Get notified whenever Full Keyboard Access mode is changed. |
+ [[NSDistributedNotificationCenter defaultCenter] |
+ addObserver:self |
+ selector:@selector(onFullKeyboardAccessModeChanged:) |
+ name:kFullKeyboardAccessChangedNotification |
+ object:nil]; |
+ |
+ // Initialize the focus manager with the correct keyboard accessibility |
+ // setting. |
+ [self updateFullKeyboardAccess]; |
} |
return self; |
} |
@@ -230,6 +247,7 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
hostedView_ = nullptr; |
[cursorTrackingArea_.get() clearOwner]; |
[self removeTrackingArea:cursorTrackingArea_.get()]; |
+ [[NSDistributedNotificationCenter defaultCenter] removeObserver:self]; |
tapted
2016/04/20 06:05:57
nit: move up before [cursorTrackingArea_.get() cle
karandeepb
2016/05/03 02:54:12
Done.
|
} |
- (void)processCapturedMouseEvent:(NSEvent*)theEvent { |
@@ -293,6 +311,15 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
[windowMask_ transformUsingAffineTransform:flipTransform]; |
} |
+- (void)updateFullKeyboardAccess { |
+ if (!hostedView_) |
+ return; |
+ |
+ if (hostedView_->GetWidget()->GetFocusManager()) |
tapted
2016/04/20 06:05:57
nit: needs curlies, but also, the FocusManager sho
karandeepb
2016/05/03 02:54:12
Done.
|
+ hostedView_->GetWidget()->GetFocusManager()->SetKeyboardAccessible( |
+ [NSApp isFullKeyboardAccessEnabled]); |
+} |
+ |
// BridgedContentView private implementation. |
- (void)handleKeyEvent:(NSEvent*)theEvent { |
@@ -328,6 +355,12 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
hostedView_->GetWidget()->GetInputMethod()->DispatchKeyEvent(&event); |
} |
+- (void)onFullKeyboardAccessModeChanged:(NSNotification*)notification { |
+ DCHECK([[notification name] |
+ isEqualToString:kFullKeyboardAccessChangedNotification]); |
+ [self updateFullKeyboardAccess]; |
+} |
+ |
- (void)undo:(id)sender { |
// This DCHECK is more strict than a similar check in handleAction:. It can be |
// done here because the actors sending these actions should be calling |