Home | History | Annotate | Download | only in accessibility
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef UI_BASE_ACCESSIBILITY_ACCESSIBLE_VIEW_STATE_H_
      6 #define UI_BASE_ACCESSIBILITY_ACCESSIBLE_VIEW_STATE_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/callback.h"
     10 #include "base/strings/string16.h"
     11 #include "ui/base/accessibility/accessibility_types.h"
     12 #include "ui/base/ui_export.h"
     13 
     14 namespace ui {
     15 
     16 ////////////////////////////////////////////////////////////////////////////////
     17 //
     18 // AccessibleViewState
     19 //
     20 //   A cross-platform struct for storing the core accessibility information
     21 //   that should be provided about any UI view to assistive technology (AT).
     22 //
     23 ////////////////////////////////////////////////////////////////////////////////
     24 struct UI_EXPORT AccessibleViewState {
     25  public:
     26   AccessibleViewState();
     27   ~AccessibleViewState();
     28 
     29   // The view's role, like button or list box.
     30   AccessibilityTypes::Role role;
     31 
     32   // The view's state, a bitmask containing fields such as checked
     33   // (for a checkbox) and protected (for a password text box).
     34   AccessibilityTypes::State state;
     35 
     36   // The view's name / label.
     37   string16 name;
     38 
     39   // The view's value, for example the text content.
     40   string16 value;
     41 
     42   // The name of the default action if the user clicks on this view.
     43   string16 default_action;
     44 
     45   // The keyboard shortcut to activate this view, if any.
     46   string16 keyboard_shortcut;
     47 
     48   // The selection start and end. Only applies to views with text content,
     49   // such as a text box or combo box; start and end should be -1 otherwise.
     50   int selection_start;
     51   int selection_end;
     52 
     53   // The selected item's index and the count of the number of items.
     54   // Only applies to views with multiple choices like a listbox; both
     55   // index and count should be -1 otherwise.
     56   int index;
     57   int count;
     58 
     59   // An optional callback that can be used by accessibility clients to
     60   // set the string value of this view. This only applies to roles where
     61   // setting the value makes sense, like a text box. Not often used by
     62   // screen readers, but often used by automation software to script
     63   // things like logging into portals or filling forms.
     64   //
     65   // This callback is only valid for the lifetime of the view, and should
     66   // be a safe no-op if the view is deleted. Typically, accessible views
     67   // should use a WeakPtr when binding the callback.
     68   base::Callback<void(const base::string16&)> set_value_callback;
     69 };
     70 
     71 }  // namespace ui
     72 
     73 #endif  // UI_BASE_ACCESSIBILITY_ACCESSIBLE_VIEW_STATE_H_
     74