| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/extensions/api/braille_display_private/braille_display_
private_api.h" | 5 #include "chrome/browser/extensions/api/braille_display_private/braille_display_
private_api.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "chrome/browser/extensions/api/braille_display_private/braille_controll
er.h" | 8 #include "chrome/browser/extensions/api/braille_display_private/braille_controll
er.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 LAZY_INSTANCE_INITIALIZER; | 55 LAZY_INSTANCE_INITIALIZER; |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 BrowserContextKeyedAPIFactory<BrailleDisplayPrivateAPI>* | 58 BrowserContextKeyedAPIFactory<BrailleDisplayPrivateAPI>* |
| 59 BrailleDisplayPrivateAPI::GetFactoryInstance() { | 59 BrailleDisplayPrivateAPI::GetFactoryInstance() { |
| 60 return g_factory.Pointer(); | 60 return g_factory.Pointer(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void BrailleDisplayPrivateAPI::OnBrailleDisplayStateChanged( | 63 void BrailleDisplayPrivateAPI::OnBrailleDisplayStateChanged( |
| 64 const DisplayState& display_state) { | 64 const DisplayState& display_state) { |
| 65 scoped_ptr<Event> event(new Event( | 65 scoped_ptr<Event> event( |
| 66 OnDisplayStateChanged::kEventName, | 66 new Event(events::UNKNOWN, OnDisplayStateChanged::kEventName, |
| 67 OnDisplayStateChanged::Create(display_state))); | 67 OnDisplayStateChanged::Create(display_state))); |
| 68 event_delegate_->BroadcastEvent(event.Pass()); | 68 event_delegate_->BroadcastEvent(event.Pass()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void BrailleDisplayPrivateAPI::OnBrailleKeyEvent(const KeyEvent& key_event) { | 71 void BrailleDisplayPrivateAPI::OnBrailleKeyEvent(const KeyEvent& key_event) { |
| 72 // Key events only go to extensions of the active profile. | 72 // Key events only go to extensions of the active profile. |
| 73 if (!IsProfileActive()) | 73 if (!IsProfileActive()) |
| 74 return; | 74 return; |
| 75 scoped_ptr<Event> event(new Event( | 75 scoped_ptr<Event> event(new Event(events::UNKNOWN, OnKeyEvent::kEventName, |
| 76 OnKeyEvent::kEventName, OnKeyEvent::Create(key_event))); | 76 OnKeyEvent::Create(key_event))); |
| 77 event_delegate_->BroadcastEvent(event.Pass()); | 77 event_delegate_->BroadcastEvent(event.Pass()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool BrailleDisplayPrivateAPI::IsProfileActive() { | 80 bool BrailleDisplayPrivateAPI::IsProfileActive() { |
| 81 #if defined(OS_CHROMEOS) | 81 #if defined(OS_CHROMEOS) |
| 82 Profile* active_profile; | 82 Profile* active_profile; |
| 83 chromeos::ScreenLocker* screen_locker = | 83 chromeos::ScreenLocker* screen_locker = |
| 84 chromeos::ScreenLocker::default_screen_locker(); | 84 chromeos::ScreenLocker::default_screen_locker(); |
| 85 if (screen_locker && screen_locker->locked()) { | 85 if (screen_locker && screen_locker->locked()) { |
| 86 active_profile = chromeos::ProfileHelper::GetSigninProfile(); | 86 active_profile = chromeos::ProfileHelper::GetSigninProfile(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 void BrailleDisplayPrivateWriteDotsFunction::Work() { | 171 void BrailleDisplayPrivateWriteDotsFunction::Work() { |
| 172 BrailleController::GetInstance()->WriteDots(params_->cells); | 172 BrailleController::GetInstance()->WriteDots(params_->cells); |
| 173 } | 173 } |
| 174 | 174 |
| 175 bool BrailleDisplayPrivateWriteDotsFunction::Respond() { | 175 bool BrailleDisplayPrivateWriteDotsFunction::Respond() { |
| 176 return true; | 176 return true; |
| 177 } | 177 } |
| 178 } // namespace api | 178 } // namespace api |
| 179 } // namespace extensions | 179 } // namespace extensions |
| OLD | NEW |