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

Side by Side Diff: chrome/browser/extensions/extension_accessibility_api.h

Issue 6961027: Change event routers from singletons to being owned by the ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: all is built on sand Created 9 years, 7 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_EXTENSIONS_EXTENSION_ACCESSIBILITY_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACCESSIBILITY_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACCESSIBILITY_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACCESSIBILITY_API_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_old.h" 12 #include "base/callback_old.h"
13 #include "base/memory/singleton.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "chrome/browser/accessibility_events.h" 14 #include "chrome/browser/accessibility_events.h"
16 #include "chrome/browser/extensions/extension_function.h" 15 #include "chrome/browser/extensions/extension_function.h"
17 #include "content/common/notification_observer.h" 16 #include "content/common/notification_observer.h"
18 #include "content/common/notification_registrar.h" 17 #include "content/common/notification_registrar.h"
19 18
20 // Observes the profile and routes accessibility notifications as events 19 // Observes the profile and routes accessibility notifications as events
21 // to the extension system. 20 // to the extension system.
22 class ExtensionAccessibilityEventRouter : public NotificationObserver { 21 class ExtensionAccessibilityEventRouter : public NotificationObserver {
23 public: 22 public:
24 // Single instance of the event router. 23 explicit ExtensionAccessibilityEventRouter();
25 static ExtensionAccessibilityEventRouter* GetInstance(); 24 virtual ~ExtensionAccessibilityEventRouter();
26 25
27 // Safe to call multiple times. 26 void Init();
28 void ObserveProfile(Profile* profile);
29 27
30 // Get the dict representing the last control that received an 28 // Get the dict representing the last control that received an
31 // OnControlFocus event. 29 // OnControlFocus event.
32 DictionaryValue* last_focused_control_dict() { 30 DictionaryValue* last_focused_control_dict() {
33 return &last_focused_control_dict_; 31 return &last_focused_control_dict_;
34 } 32 }
35 33
36 // Accessibility support is disabled until an extension expicitly enables 34 // Accessibility support is disabled until an extension expicitly enables
37 // it, so that this extension api has no impact on Chrome's performance 35 // it, so that this extension api has no impact on Chrome's performance
38 // otherwise. These methods handle enabling, disabling, querying the 36 // otherwise. These methods handle enabling, disabling, querying the
39 // status, and installing callbacks to execute when accessibility support 37 // status, and installing callbacks to execute when accessibility support
40 // is enabled or disabled. 38 // is enabled or disabled.
41 void SetAccessibilityEnabled(bool enabled); 39 void SetAccessibilityEnabled(bool enabled);
42 bool IsAccessibilityEnabled() const; 40 bool IsAccessibilityEnabled() const;
43 typedef Callback0::Type Callback; 41 typedef Callback0::Type Callback;
44 void AddOnEnabledListener(Callback* callback); 42 void AddOnEnabledListener(Callback* callback);
45 void AddOnDisabledListener(Callback* callback); 43 void AddOnDisabledListener(Callback* callback);
46 44
47 private: 45 private:
48 friend struct DefaultSingletonTraits<ExtensionAccessibilityEventRouter>;
49
50 ExtensionAccessibilityEventRouter();
51 virtual ~ExtensionAccessibilityEventRouter();
52
53 // NotificationObserver::Observe. 46 // NotificationObserver::Observe.
54 virtual void Observe(NotificationType type, 47 virtual void Observe(NotificationType type,
55 const NotificationSource& source, 48 const NotificationSource& source,
56 const NotificationDetails& details); 49 const NotificationDetails& details);
57 50
58 void OnWindowOpened(const AccessibilityWindowInfo* details); 51 void OnWindowOpened(const AccessibilityWindowInfo* details);
59 void OnWindowClosed(const AccessibilityWindowInfo* details); 52 void OnWindowClosed(const AccessibilityWindowInfo* details);
60 void OnControlFocused(const AccessibilityControlInfo* details); 53 void OnControlFocused(const AccessibilityControlInfo* details);
61 void OnControlAction(const AccessibilityControlInfo* details); 54 void OnControlAction(const AccessibilityControlInfo* details);
62 void OnTextChanged(const AccessibilityControlInfo* details); 55 void OnTextChanged(const AccessibilityControlInfo* details);
(...skipping 28 matching lines...) Expand all
91 84
92 // API function that returns the most recent focused control. 85 // API function that returns the most recent focused control.
93 class GetFocusedControlFunction : public SyncExtensionFunction { 86 class GetFocusedControlFunction : public SyncExtensionFunction {
94 virtual ~GetFocusedControlFunction() {} 87 virtual ~GetFocusedControlFunction() {}
95 virtual bool RunImpl(); 88 virtual bool RunImpl();
96 DECLARE_EXTENSION_FUNCTION_NAME( 89 DECLARE_EXTENSION_FUNCTION_NAME(
97 "experimental.accessibility.getFocusedControl") 90 "experimental.accessibility.getFocusedControl")
98 }; 91 };
99 92
100 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACCESSIBILITY_API_H_ 93 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACCESSIBILITY_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/wizard_accessibility_helper.cc ('k') | chrome/browser/extensions/extension_accessibility_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698