18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file.
48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/extensions/global_shortcut_listener_ozone.h"
68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "content/public/browser/browser_thread.h"
88bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)using content::BrowserThread;
108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace extensions {
128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// static
148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)GlobalShortcutListener* GlobalShortcutListener::GetInstance() {
158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static GlobalShortcutListenerOzone* instance =
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      new GlobalShortcutListenerOzone();
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return instance;
198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)GlobalShortcutListenerOzone::GlobalShortcutListenerOzone()
228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    : is_listening_(false) {
238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // TODO(implementor): Remove this.
268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  LOG(ERROR) << "GlobalShortcutListenerOzone object created";
278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)GlobalShortcutListenerOzone::~GlobalShortcutListenerOzone() {
308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  if (is_listening_)
318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    StopListening();
328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)void GlobalShortcutListenerOzone::StartListening() {
358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  DCHECK(!is_listening_);  // Don't start twice.
368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  NOTIMPLEMENTED();
378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  is_listening_ = true;
388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)void GlobalShortcutListenerOzone::StopListening() {
418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  DCHECK(is_listening_);  // No point if we are not already listening.
428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  NOTIMPLEMENTED();
438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  is_listening_ = false;
448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool GlobalShortcutListenerOzone::RegisterAcceleratorImpl(
475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const ui::Accelerator& accelerator) {
488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  NOTIMPLEMENTED();
498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // To implement:
508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // 1) Convert modifiers to platform specific modifiers.
518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  // 2) Register for the hotkey.
525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // 3) If not successful, return false.
535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // 4) Else, return true.
548bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return false;
568bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void GlobalShortcutListenerOzone::UnregisterAcceleratorImpl(
595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const ui::Accelerator& accelerator) {
608bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  NOTIMPLEMENTED();
615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // To implement: Unregister for the hotkey.
628bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
638bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
648bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}  // namespace extensions
65