Index: chrome/browser/extensions/api/braille_display_private/braille_display_private_api.cc |
diff --git a/chrome/browser/extensions/api/braille_display_private/braille_display_private_api.cc b/chrome/browser/extensions/api/braille_display_private/braille_display_private_api.cc |
index 6e947eb4460f9d2fb273d14482b5e35edef27c23..33be1795598b981ad89e57ab95348c23f1d95f0b 100644 |
--- a/chrome/browser/extensions/api/braille_display_private/braille_display_private_api.cc |
+++ b/chrome/browser/extensions/api/braille_display_private/braille_display_private_api.cc |
@@ -5,19 +5,25 @@ |
#include "chrome/browser/extensions/api/braille_display_private/braille_display_private_api.h" |
#include "base/lazy_instance.h" |
+#include "chrome/browser/extensions/api/braille_display_private/braille_controller.h" |
#include "chrome/browser/extensions/event_router.h" |
#include "chrome/browser/extensions/extension_system.h" |
namespace OnKeyEvent = extensions::api::braille_display_private::OnKeyEvent; |
namespace WriteDots = extensions::api::braille_display_private::WriteDots; |
using extensions::api::braille_display_private::KeyEvent; |
+using extensions::api::braille_display_private::BrailleController; |
namespace extensions { |
BrailleDisplayPrivateAPI::BrailleDisplayPrivateAPI(Profile* profile) |
: profile_(profile) { |
+ // TODO(plundblad): Consider defering this until someone actually uses the |
+ // API so that we only watch for braille displays if cvox is enabled. |
+ BrailleController::GetInstance()->AddObserver(this); |
} |
BrailleDisplayPrivateAPI::~BrailleDisplayPrivateAPI() { |
+ BrailleController::GetInstance()->RemoveObserver(this); |
} |
void BrailleDisplayPrivateAPI::Shutdown() { |
@@ -32,17 +38,25 @@ BrailleDisplayPrivateAPI::GetFactoryInstance() { |
return &g_factory.Get(); |
} |
+void BrailleDisplayPrivateAPI::OnKeyEvent( |
+ const KeyEvent& keyEvent) { |
+ // TODO(plundblad): Only send the event to the active profile. |
+ scoped_ptr<Event> event(new Event( |
+ OnKeyEvent::kEventName, OnKeyEvent::Create(keyEvent))); |
+ ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(event.Pass()); |
+} |
+ |
namespace api { |
bool BrailleDisplayPrivateGetDisplayStateFunction::Prepare() { |
return true; |
} |
void BrailleDisplayPrivateGetDisplayStateFunction::Work() { |
- // TODO(plundblad): implement. |
+ SetResult(BrailleController::GetInstance()->GetDisplayState().release()); |
} |
bool BrailleDisplayPrivateGetDisplayStateFunction::Respond() { |
- return false; |
+ return true; |
} |
BrailleDisplayPrivateWriteDotsFunction:: |
@@ -60,7 +74,7 @@ bool BrailleDisplayPrivateWriteDotsFunction::Prepare() { |
} |
void BrailleDisplayPrivateWriteDotsFunction::Work() { |
- // TODO(plundblad): Implement. |
+ BrailleController::GetInstance()->WriteDots(params_->cells); |
} |
bool BrailleDisplayPrivateWriteDotsFunction::Respond() { |