summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/accessibility_events.cc14
-rw-r--r--chrome/browser/accessibility_events.h14
-rw-r--r--chrome/browser/chromeos/accessibility/system_event_observer.cc74
-rw-r--r--chrome/browser/chromeos/accessibility/system_event_observer.h54
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.cc5
-rw-r--r--chrome/browser/extensions/extension_accessibility_api.cc25
-rw-r--r--chrome/browser/extensions/extension_accessibility_api.h2
-rw-r--r--chrome/browser/extensions/extension_accessibility_api_constants.cc2
-rw-r--r--chrome/browser/extensions/extension_accessibility_api_constants.h2
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/common/chrome_notification_types.h10
-rw-r--r--chrome/common/extensions/api/extension_api.json12
12 files changed, 216 insertions, 0 deletions
diff --git a/chrome/browser/accessibility_events.cc b/chrome/browser/accessibility_events.cc
index a86f354..7eaee7e 100644
--- a/chrome/browser/accessibility_events.cc
+++ b/chrome/browser/accessibility_events.cc
@@ -213,6 +213,20 @@ void AccessibilityVolumeInfo::SerializeToDict(DictionaryValue *dict) const {
dict->SetBoolean(keys::kIsVolumeMutedKey, is_muted_);
}
+ScreenUnlockedEventInfo::ScreenUnlockedEventInfo(Profile* profile)
+ : AccessibilityEventInfo(profile) {
+}
+
+void ScreenUnlockedEventInfo::SerializeToDict(DictionaryValue *dict) const {
+}
+
+WokeUpEventInfo::WokeUpEventInfo(Profile* profile)
+ : AccessibilityEventInfo(profile) {
+}
+
+void WokeUpEventInfo::SerializeToDict(DictionaryValue *dict) const {
+}
+
AccessibilityMenuInfo::AccessibilityMenuInfo(Profile* profile,
const std::string& menu_name)
: AccessibilityControlInfo(profile, menu_name) {
diff --git a/chrome/browser/accessibility_events.h b/chrome/browser/accessibility_events.h
index 0b94f28..fcf54a9 100644
--- a/chrome/browser/accessibility_events.h
+++ b/chrome/browser/accessibility_events.h
@@ -285,6 +285,20 @@ class AccessibilityVolumeInfo : public AccessibilityEventInfo {
bool is_muted_;
};
+// Screen unlock event information; this class is used by onScreenUnlocked.
+class ScreenUnlockedEventInfo : public AccessibilityEventInfo {
+ public:
+ ScreenUnlockedEventInfo(Profile* profile);
+ virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
+};
+
+// Wake up event information; this class is used by onWokeUp.
+class WokeUpEventInfo : public AccessibilityEventInfo {
+ public:
+ WokeUpEventInfo(Profile* profile);
+ virtual void SerializeToDict(base::DictionaryValue* dict) const OVERRIDE;
+};
+
// Accessibility information about a menu item; this class is used by
// onControlFocused event listeners.
class AccessibilityMenuItemInfo : public AccessibilityControlInfo {
diff --git a/chrome/browser/chromeos/accessibility/system_event_observer.cc b/chrome/browser/chromeos/accessibility/system_event_observer.cc
new file mode 100644
index 0000000..9b16e7f
--- /dev/null
+++ b/chrome/browser/chromeos/accessibility/system_event_observer.cc
@@ -0,0 +1,74 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/accessibility/system_event_observer.h"
+
+#include "base/logging.h"
+#include "chrome/browser/accessibility_events.h"
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/chrome_notification_types.h"
+
+namespace chromeos {
+namespace accessibility {
+
+namespace {
+
+SystemEventObserver* g_system_event_observer = NULL;
+
+}
+
+SystemEventObserver::SystemEventObserver() {
+ CrosLibrary::Get()->GetPowerLibrary()->AddObserver(this);
+ CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this);
+}
+
+SystemEventObserver::~SystemEventObserver() {
+ CrosLibrary::Get()->GetScreenLockLibrary()->RemoveObserver(this);
+ CrosLibrary::Get()->GetPowerLibrary()->RemoveObserver(this);
+}
+
+void SystemEventObserver::SystemResumed() {
+ Profile* profile = ProfileManager::GetDefaultProfile();
+ WokeUpEventInfo info(profile);
+ SendAccessibilityNotification(
+ chrome::NOTIFICATION_ACCESSIBILITY_WOKE_UP, &info);
+}
+
+void SystemEventObserver::LockScreen(ScreenLockLibrary* screen_lock_library) {
+}
+
+void SystemEventObserver::UnlockScreen(ScreenLockLibrary* screen_lock_library) {
+ Profile* profile = ProfileManager::GetDefaultProfile();
+ ScreenUnlockedEventInfo info(profile);
+ SendAccessibilityNotification(
+ chrome::NOTIFICATION_ACCESSIBILITY_SCREEN_UNLOCKED, &info);
+}
+
+void SystemEventObserver::UnlockScreenFailed(
+ ScreenLockLibrary* screen_lock_library) {
+}
+
+// static
+void SystemEventObserver::Initialize() {
+ DCHECK(!g_system_event_observer);
+ g_system_event_observer = new SystemEventObserver();
+ VLOG(1) << "SystemEventObserver initialized";
+}
+
+// static
+SystemEventObserver* SystemEventObserver::GetInstance() {
+ return g_system_event_observer;
+}
+
+// static
+void SystemEventObserver::Shutdown() {
+ DCHECK(g_system_event_observer);
+ delete g_system_event_observer;
+ g_system_event_observer = NULL;
+ VLOG(1) << "SystemEventObserver Shutdown completed";
+}
+
+} // namespace accessibility
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/accessibility/system_event_observer.h b/chrome/browser/chromeos/accessibility/system_event_observer.h
new file mode 100644
index 0000000..82fcb6ea
--- /dev/null
+++ b/chrome/browser/chromeos/accessibility/system_event_observer.h
@@ -0,0 +1,54 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SYSTEM_EVENT_OBSERVER_H_
+#define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SYSTEM_EVENT_OBSERVER_H_
+#pragma once
+
+#include "chrome/browser/chromeos/cros/power_library.h"
+#include "chrome/browser/chromeos/cros/screen_lock_library.h"
+
+namespace chromeos {
+namespace accessibility {
+
+// A singleton class to observe system events like wake up from sleep and
+// screen unlock.
+class SystemEventObserver : public PowerLibrary::Observer,
+ public ScreenLockLibrary::Observer {
+ public:
+ virtual ~SystemEventObserver();
+
+ // PowerLibrary::Observer override.
+ virtual void SystemResumed() OVERRIDE;
+
+ // ScreenLockLibrary::Observer override.
+ virtual void LockScreen(ScreenLockLibrary* screen_lock_library) OVERRIDE;
+
+ // ScreenLockLibrary::Observer override.
+ virtual void UnlockScreen(ScreenLockLibrary* screen_lock_library) OVERRIDE;
+
+ // ScreenLockLibrary::Observer override.
+ virtual void UnlockScreenFailed(ScreenLockLibrary* screen_lock_library)
+ OVERRIDE;
+
+ // Creates the global SystemEventObserver instance.
+ static void Initialize();
+
+ // Returns a pointer to the global SystemEventObserver instance.
+ // Initialize() should already have been called.
+ static SystemEventObserver* GetInstance();
+
+ // Destroys the global SystemEventObserver Instance.
+ static void Shutdown();
+
+ private:
+ SystemEventObserver();
+
+ DISALLOW_COPY_AND_ASSIGN(SystemEventObserver);
+};
+
+} // namespace accessibility
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SYSTEM_EVENT_OBSERVER_H_
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index 5b737ac..002bf51 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/message_loop.h"
+#include "chrome/browser/chromeos/accessibility/system_event_observer.h"
#include "chrome/browser/chromeos/bluetooth/bluetooth_manager.h"
#include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/brightness_observer.h"
@@ -93,6 +94,8 @@ ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() {
chromeos::DBusThreadManager::Shutdown();
+ chromeos::accessibility::SystemEventObserver::Shutdown();
+
if (!parameters().ui_task && chromeos::CrosLibrary::Get())
chromeos::CrosLibrary::Shutdown();
@@ -126,6 +129,8 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() {
// implementation.
net::NetworkChangeNotifier::SetFactory(
new chromeos::CrosNetworkChangeNotifierFactory());
+
+ chromeos::accessibility::SystemEventObserver::Initialize();
}
void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() {
diff --git a/chrome/browser/extensions/extension_accessibility_api.cc b/chrome/browser/extensions/extension_accessibility_api.cc
index 731b81e..add11c0 100644
--- a/chrome/browser/extensions/extension_accessibility_api.cc
+++ b/chrome/browser/extensions/extension_accessibility_api.cc
@@ -65,6 +65,12 @@ ExtensionAccessibilityEventRouter::ExtensionAccessibilityEventRouter()
registrar_.Add(this,
chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_CHANGED,
content::NotificationService::AllSources());
+ registrar_.Add(this,
+ chrome::NOTIFICATION_ACCESSIBILITY_SCREEN_UNLOCKED,
+ content::NotificationService::AllSources());
+ registrar_.Add(this,
+ chrome::NOTIFICATION_ACCESSIBILITY_WOKE_UP,
+ content::NotificationService::AllSources());
}
ExtensionAccessibilityEventRouter::~ExtensionAccessibilityEventRouter() {
@@ -107,6 +113,14 @@ void ExtensionAccessibilityEventRouter::Observe(
OnVolumeChanged(
content::Details<const AccessibilityVolumeInfo>(details).ptr());
break;
+ case chrome::NOTIFICATION_ACCESSIBILITY_SCREEN_UNLOCKED:
+ OnScreenUnlocked(
+ content::Details<const ScreenUnlockedEventInfo>(details).ptr());
+ break;
+ case chrome::NOTIFICATION_ACCESSIBILITY_WOKE_UP:
+ OnWokeUp(
+ content::Details<const WokeUpEventInfo>(details).ptr());
+ break;
default:
NOTREACHED();
}
@@ -170,6 +184,17 @@ void ExtensionAccessibilityEventRouter::OnVolumeChanged(
DispatchEvent(info->profile(), keys::kOnVolumeChanged, json_args);
}
+void ExtensionAccessibilityEventRouter::OnScreenUnlocked(
+ const ScreenUnlockedEventInfo* info) {
+ std::string json_args = ControlInfoToJsonString(info);
+ DispatchEvent(info->profile(), keys::kOnScreenUnlocked, json_args);
+}
+
+void ExtensionAccessibilityEventRouter::OnWokeUp(const WokeUpEventInfo* info) {
+ std::string json_args = ControlInfoToJsonString(info);
+ DispatchEvent(info->profile(), keys::kOnWokeUp, json_args);
+}
+
void ExtensionAccessibilityEventRouter::DispatchEvent(
Profile* profile,
const char* event_name,
diff --git a/chrome/browser/extensions/extension_accessibility_api.h b/chrome/browser/extensions/extension_accessibility_api.h
index 2ead75b..3962703 100644
--- a/chrome/browser/extensions/extension_accessibility_api.h
+++ b/chrome/browser/extensions/extension_accessibility_api.h
@@ -55,6 +55,8 @@ class ExtensionAccessibilityEventRouter : public content::NotificationObserver {
void OnMenuOpened(const AccessibilityMenuInfo* details);
void OnMenuClosed(const AccessibilityMenuInfo* details);
void OnVolumeChanged(const AccessibilityVolumeInfo* details);
+ void OnScreenUnlocked(const ScreenUnlockedEventInfo* details);
+ void OnWokeUp(const WokeUpEventInfo* details);
void DispatchEvent(Profile* profile,
const char* event_name,
diff --git a/chrome/browser/extensions/extension_accessibility_api_constants.cc b/chrome/browser/extensions/extension_accessibility_api_constants.cc
index c51d32d..dac37f3 100644
--- a/chrome/browser/extensions/extension_accessibility_api_constants.cc
+++ b/chrome/browser/extensions/extension_accessibility_api_constants.cc
@@ -30,6 +30,8 @@ const char kOnTextChanged[] = "experimental.accessibility.onTextChanged";
const char kOnMenuOpened[] = "experimental.accessibility.onMenuOpened";
const char kOnMenuClosed[] = "experimental.accessibility.onMenuClosed";
const char kOnVolumeChanged[] = "experimental.accessibility.onVolumeChanged";
+const char kOnScreenUnlocked[] = "experimental.accessibility.onScreenUnlocked";
+const char kOnWokeUp[] = "experimental.accessibility.onWokeUp";
// Types of controls that can receive accessibility events.
const char kTypeButton[] = "button";
diff --git a/chrome/browser/extensions/extension_accessibility_api_constants.h b/chrome/browser/extensions/extension_accessibility_api_constants.h
index 098a286f..a8f8ba7 100644
--- a/chrome/browser/extensions/extension_accessibility_api_constants.h
+++ b/chrome/browser/extensions/extension_accessibility_api_constants.h
@@ -34,6 +34,8 @@ extern const char kOnTextChanged[];
extern const char kOnMenuOpened[];
extern const char kOnMenuClosed[];
extern const char kOnVolumeChanged[];
+extern const char kOnScreenUnlocked[];
+extern const char kOnWokeUp[];
// Types of controls that can receive accessibility events
extern const char kTypeButton[];
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 06c7a9f..c248603 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -375,6 +375,8 @@
'browser/chrome_quota_permission_context.h',
'browser/chromeos/accessibility_util.cc',
'browser/chromeos/accessibility_util.h',
+ 'browser/chromeos/accessibility/system_event_observer.cc',
+ 'browser/chromeos/accessibility/system_event_observer.h',
'browser/chromeos/audio_handler.cc',
'browser/chromeos/audio_handler.h',
'browser/chromeos/audio_mixer.h',
diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h
index e2467d8..e1ad04d 100644
--- a/chrome/common/chrome_notification_types.h
+++ b/chrome/common/chrome_notification_types.h
@@ -658,6 +658,16 @@ enum NotificationType {
// Details will be an AccessibilityVolumeInfo.
NOTIFICATION_ACCESSIBILITY_VOLUME_CHANGED,
+ // Notification that the screen is unlocked, for propagating to an
+ // accessibility extension.
+ // Details will be an AccessibilityEmptyEventInfo.
+ NOTIFICATION_ACCESSIBILITY_SCREEN_UNLOCKED,
+
+ // Notification that the system woke up from sleep, for propagating to an
+ // accessibility extension.
+ // Details will be an AccessibilityEmptyEventInfo.
+ NOTIFICATION_ACCESSIBILITY_WOKE_UP,
+
// Content Settings --------------------------------------------------------
// Sent when content settings change. The source is a HostContentSettings
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index 47fe937..2651843 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -509,6 +509,18 @@
"description": "Information about the current state of the system volume control, including whether it is muted."
}
]
+ },
+ {
+ "name": "onScreenUnlocked",
+ "type": "function",
+ "description": "Fired when the screen is unlocked.",
+ "parameters": []
+ },
+ {
+ "name": "onWokeUp",
+ "type": "function",
+ "description": "Fired when the device wakes up from sleep.",
+ "parameters": []
}
]
},