Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: chrome/browser/accessibility_events.h

Issue 7708025: Adds extension APIs of events on changing volume. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix (to be commited) Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ 5 #ifndef CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_
6 #define CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ 6 #define CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 class AccessibilityControlInfo; 11 class AccessibilityEventInfo;
12 class Profile; 12 class Profile;
13 13
14 namespace base { 14 namespace base {
15 class DictionaryValue; 15 class DictionaryValue;
16 } 16 }
17 17
18 // Use the NotificationService to post the given accessibility 18 // Use the NotificationService to post the given accessibility
19 // notification type with AccessibilityControlInfo details to any 19 // notification type with AccessibilityControlInfo details to any
Ben Olmstead 2011/08/30 18:12:18 AccessibilityControlInfo -> AccessibilityEventInfo
20 // listeners. Will not send if the profile's pause level is nonzero 20 // listeners. Will not send if the profile's pause level is nonzero
21 // (using profile->PauseAccessibilityEvents). 21 // (using profile->PauseAccessibilityEvents).
22 void SendAccessibilityNotification( 22 void SendAccessibilityNotification(
23 int type, AccessibilityControlInfo* info); 23 int type, AccessibilityEventInfo* info);
24 void SendAccessibilityVolumeNotification(double volume, bool is_muted);
25
26 // Abstract parent class for accessibility event information passed to event
27 // listeners.
28 class AccessibilityEventInfo {
29 public:
30 virtual ~AccessibilityEventInfo() {}
31
32 // Serialize this class as a DictionaryValue that can be converted to
33 // a JavaScript object.
34 virtual void SerializeToDict(base::DictionaryValue* dict) const = 0;
35
36 Profile* profile() const { return profile_; }
37
38 protected:
39 explicit AccessibilityEventInfo(Profile* profile) : profile_(profile) {}
40
41 // The profile this control belongs to.
42 Profile* profile_;
43 };
24 44
25 // Abstract parent class for accessibility information about a control 45 // Abstract parent class for accessibility information about a control
26 // passed to event listeners. 46 // passed to event listeners.
27 class AccessibilityControlInfo { 47 class AccessibilityControlInfo : public AccessibilityEventInfo {
28 public: 48 public:
29 virtual ~AccessibilityControlInfo(); 49 virtual ~AccessibilityControlInfo();
30 50
31 // Serialize this class as a DictionaryValue that can be converted to 51 // Serialize this class as a DictionaryValue that can be converted to
32 // a JavaScript object. 52 // a JavaScript object.
33 virtual void SerializeToDict(base::DictionaryValue* dict) const; 53 void SerializeToDict(base::DictionaryValue* dict) const;
Ben Olmstead 2011/08/30 18:12:18 OVERRIDE
34 54
35 // Return the specific type of this control, which will be one of the 55 // Return the specific type of this control, which will be one of the
36 // string constants defined in extension_accessibility_api_constants.h. 56 // string constants defined in extension_accessibility_api_constants.h.
37 virtual const char* type() const = 0; 57 virtual const char* type() const = 0;
38 58
39 Profile* profile() const { return profile_; }
40
41 const std::string& name() const { return name_; } 59 const std::string& name() const { return name_; }
42 60
43 protected: 61 protected:
44 AccessibilityControlInfo(Profile* profile, const std::string& control_name); 62 AccessibilityControlInfo(Profile* profile, const std::string& control_name);
45 63
46 // The profile this control belongs to.
47 Profile* profile_;
48
49 // The name of the control, like "OK" or "Password". 64 // The name of the control, like "OK" or "Password".
50 std::string name_; 65 std::string name_;
51 }; 66 };
52 67
53 // Accessibility information about a window passed to onWindowOpened 68 // Accessibility information about a window passed to onWindowOpened
54 // and onWindowClosed event listeners. 69 // and onWindowClosed event listeners.
55 class AccessibilityWindowInfo : public AccessibilityControlInfo { 70 class AccessibilityWindowInfo : public AccessibilityControlInfo {
56 public: 71 public:
57 AccessibilityWindowInfo(Profile* profile, const std::string& window_name); 72 AccessibilityWindowInfo(Profile* profile, const std::string& window_name);
58 73
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 263
249 // Accessibility information about a menu; this class is used by 264 // Accessibility information about a menu; this class is used by
250 // onMenuOpened, onMenuClosed, and onControlFocused event listeners. 265 // onMenuOpened, onMenuClosed, and onControlFocused event listeners.
251 class AccessibilityMenuInfo : public AccessibilityControlInfo { 266 class AccessibilityMenuInfo : public AccessibilityControlInfo {
252 public: 267 public:
253 AccessibilityMenuInfo(Profile* profile, const std::string& menu_name); 268 AccessibilityMenuInfo(Profile* profile, const std::string& menu_name);
254 269
255 virtual const char* type() const; 270 virtual const char* type() const;
256 }; 271 };
257 272
273 // Accessibility information about a volume; this class is used by
274 // onVolumeUp, onVolumeDown, and onVolumeMute event listeners.
275 class AccessibilityVolumeInfo : public AccessibilityEventInfo {
276 public:
277 // |volume| must range between 0 to 100.
278 AccessibilityVolumeInfo(Profile* profile, double volume, bool is_muted);
279
280 virtual void SerializeToDict(base::DictionaryValue* dict) const;
281
282 private:
283 double volume_;
284 bool is_muted_;
285 };
286
258 // Accessibility information about a menu item; this class is used by 287 // Accessibility information about a menu item; this class is used by
259 // onControlFocused event listeners. 288 // onControlFocused event listeners.
260 class AccessibilityMenuItemInfo : public AccessibilityControlInfo { 289 class AccessibilityMenuItemInfo : public AccessibilityControlInfo {
261 public: 290 public:
262 AccessibilityMenuItemInfo(Profile* profile, 291 AccessibilityMenuItemInfo(Profile* profile,
263 const std::string& name, 292 const std::string& name,
264 bool has_submenu, 293 bool has_submenu,
265 int item_index, 294 int item_index,
266 int item_count); 295 int item_count);
267 296
268 virtual const char* type() const; 297 virtual const char* type() const;
269 298
270 virtual void SerializeToDict(base::DictionaryValue* dict) const; 299 virtual void SerializeToDict(base::DictionaryValue* dict) const;
271 300
272 int item_index() const { return item_index_; } 301 int item_index() const { return item_index_; }
273 int item_count() const { return item_count_; } 302 int item_count() const { return item_count_; }
274 bool has_submenu() const { return has_submenu_; } 303 bool has_submenu() const { return has_submenu_; }
275 304
276 private: 305 private:
277 bool has_submenu_; 306 bool has_submenu_;
278 // The 0-based index of the current item and the number of total items. 307 // The 0-based index of the current item and the number of total items.
279 int item_index_; 308 int item_index_;
280 int item_count_; 309 int item_count_;
281 }; 310 };
282 311
283 #endif // CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_ 312 #endif // CHROME_BROWSER_ACCESSIBILITY_EVENTS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/accessibility_events.cc » ('j') | chrome/common/extensions/api/extension_api.json » ('J')

Powered by Google App Engine
This is Rietveld 408576698