15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#ifndef UI_ACCESSIBILITY_AX_VIEW_STATE_H_
6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define UI_ACCESSIBILITY_AX_VIEW_STATE_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "base/callback.h"
105e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)#include "base/strings/string16.h"
11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/accessibility/ax_enums.h"
12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/accessibility/ax_export.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)////////////////////////////////////////////////////////////////////////////////
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// AXViewState
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   A cross-platform struct for storing the core accessibility information
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//   that should be provided about any UI view to assistive technology (AT).
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)////////////////////////////////////////////////////////////////////////////////
24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)struct AX_EXPORT AXViewState {
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  AXViewState();
27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  ~AXViewState();
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
29effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // Set or check bits in |state_|.
30effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  void AddStateFlag(ui::AXState state);
31effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  bool HasStateFlag(ui::AXState state) const;
32effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
335c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // The view's state, a bitmask containing fields such as checked
345c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // (for a checkbox) and protected (for a password text box). This "state"
355c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // should not be confused with the class's name.
365c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  uint32 state() { return state_; }
375c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The view's role, like button or list box.
39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  AXRole role;
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The view's name / label.
423551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  base::string16 name;
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The view's value, for example the text content.
453551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  base::string16 value;
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The name of the default action if the user clicks on this view.
483551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  base::string16 default_action;
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The keyboard shortcut to activate this view, if any.
513551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  base::string16 keyboard_shortcut;
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The selection start and end. Only applies to views with text content,
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // such as a text box or combo box; start and end should be -1 otherwise.
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int selection_start;
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int selection_end;
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The selected item's index and the count of the number of items.
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Only applies to views with multiple choices like a listbox; both
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // index and count should be -1 otherwise.
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int index;
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int count;
6358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
6458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // An optional callback that can be used by accessibility clients to
6558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // set the string value of this view. This only applies to roles where
6658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // setting the value makes sense, like a text box. Not often used by
6758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // screen readers, but often used by automation software to script
6858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // things like logging into portals or filling forms.
6958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  //
7058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // This callback is only valid for the lifetime of the view, and should
7158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // be a safe no-op if the view is deleted. Typically, accessible views
7258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // should use a WeakPtr when binding the callback.
7358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  base::Callback<void(const base::string16&)> set_value_callback;
74effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
75effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch private:
76effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  uint32 state_;
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace ui
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
81a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif  // UI_ACCESSIBILITY_AX_VIEW_STATE_H_
82