Index: ui/views/view.cc |
diff --git a/ui/views/view.cc b/ui/views/view.cc |
index 4c62a000f61882cf5115a2f541ba8e7b86fb8af5..05892f1320f571f36c69046786fca7a41bedbe6f 100644 |
--- a/ui/views/view.cc |
+++ b/ui/views/view.cc |
@@ -1201,6 +1201,34 @@ void View::SetNextFocusableView(View* view) { |
next_focusable_view_ = view; |
} |
+void View::SetFocusBehavior(FocusBehavior focus_behavior) { |
+ if (focus_behavior == FocusBehavior::CONTROL) { |
+#if defined(OS_MACOSX) |
+ focus_behavior = FocusBehavior::ACCESSIBLE_ONLY; |
+#else |
+ focus_behavior = FocusBehavior::ALWAYS; |
+#endif |
+ } |
+ |
+ switch (focus_behavior) { |
+ case FocusBehavior::ALWAYS: |
+ SetFocusable(true); |
+ SetAccessibilityFocusable(true); |
+ break; |
+ case FocusBehavior::NEVER: |
+ SetFocusable(false); |
+ SetAccessibilityFocusable(false); |
+ break; |
+ case FocusBehavior::ACCESSIBLE_ONLY: |
+ SetFocusable(false); |
+ SetAccessibilityFocusable(true); |
+ break; |
+ case FocusBehavior::CONTROL: |
+ NOTREACHED(); |
+ break; |
+ } |
+} |
+ |
void View::SetFocusable(bool focusable) { |
if (focusable_ == focusable) |
return; |