Skip to content

Commit

Permalink
chrome: Ozone Aura needs the newly global extension commands also.
Browse files Browse the repository at this point in the history
The offending CL https://codereview.chromium.org/23812010 has introduced
changes that break Ozone platform support. This CL make the necessary changes,
moving the Aura X11 specific code to be now compiled with generic Aura
solutions as well.

In particular, this brings back support for Chrome browser in Ozone-Wayland.

BUG=302437

Review URL: https://codereview.chromium.org/26539009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229865 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tiago.vignatti@intel.com committed Oct 21, 2013
1 parent 9aba6f6 commit 02a6a18
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
75 changes: 75 additions & 0 deletions chrome/browser/extensions/global_shortcut_listener_ozone.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright 2013 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/extensions/global_shortcut_listener_ozone.h"

#include "content/public/browser/browser_thread.h"

using content::BrowserThread;

namespace {

static base::LazyInstance<extensions::GlobalShortcutListenerOzone> instance =
LAZY_INSTANCE_INITIALIZER;

} // namespace

namespace extensions {

// static
GlobalShortcutListener* GlobalShortcutListener::GetInstance() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
return instance.Pointer();
}

GlobalShortcutListenerOzone::GlobalShortcutListenerOzone()
: is_listening_(false) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));

// TODO(implementor): Remove this.
LOG(ERROR) << "GlobalShortcutListenerOzone object created";
}

GlobalShortcutListenerOzone::~GlobalShortcutListenerOzone() {
if (is_listening_)
StopListening();
}

void GlobalShortcutListenerOzone::StartListening() {
DCHECK(!is_listening_); // Don't start twice.
NOTIMPLEMENTED();
is_listening_ = true;
}

void GlobalShortcutListenerOzone::StopListening() {
DCHECK(is_listening_); // No point if we are not already listening.
NOTIMPLEMENTED();
is_listening_ = false;
}

void GlobalShortcutListenerOzone::RegisterAccelerator(
const ui::Accelerator& accelerator,
GlobalShortcutListener::Observer* observer) {
NOTIMPLEMENTED();
// To implement:
// 1) Convert modifiers to platform specific modifiers.
// 2) Register for the hotkey.
// 3) If not successful, log why.
// 4) Else, call base class RegisterAccelerator.

GlobalShortcutListener::RegisterAccelerator(accelerator, observer);
}

void GlobalShortcutListenerOzone::UnregisterAccelerator(
const ui::Accelerator& accelerator,
GlobalShortcutListener::Observer* observer) {
NOTIMPLEMENTED();
// To implement:
// 1) Unregister for the hotkey.
// 2) Call base class UnregisterAccelerator.

GlobalShortcutListener::UnregisterAccelerator(accelerator, observer);
}

} // namespace extensions
45 changes: 45 additions & 0 deletions chrome/browser/extensions/global_shortcut_listener_ozone.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2013 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_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_OZONE_H_
#define CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_OZONE_H_

#include "base/lazy_instance.h"
#include "chrome/browser/extensions/global_shortcut_listener.h"

namespace extensions {

// Ozone-specific implementation of the GlobalShortcutListener class that
// listens for global shortcuts. Handles basic keyboard intercepting and
// forwards its output to the base class for processing.
class GlobalShortcutListenerOzone : public GlobalShortcutListener {
public:
virtual ~GlobalShortcutListenerOzone();

virtual void StartListening() OVERRIDE;
virtual void StopListening() OVERRIDE;

private:
friend struct base::DefaultLazyInstanceTraits<GlobalShortcutListenerOzone>;

GlobalShortcutListenerOzone();

// Register an |accelerator| with the particular |observer|.
virtual void RegisterAccelerator(
const ui::Accelerator& accelerator,
GlobalShortcutListener::Observer* observer) OVERRIDE;
// Unregister an |accelerator| with the particular |observer|.
virtual void UnregisterAccelerator(
const ui::Accelerator& accelerator,
GlobalShortcutListener::Observer* observer) OVERRIDE;

// Whether this object is listening for global shortcuts.
bool is_listening_;

DISALLOW_COPY_AND_ASSIGN(GlobalShortcutListenerOzone);
};

} // namespace extensions

#endif // CHROME_BROWSER_EXTENSIONS_GLOBAL_SHORTCUT_LISTENER_OZONE_H_
2 changes: 2 additions & 0 deletions chrome/chrome_browser_extensions.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,8 @@
'browser/extensions/global_shortcut_listener_chromeos.h',
'browser/extensions/global_shortcut_listener_mac.cc',
'browser/extensions/global_shortcut_listener_mac.h',
'browser/extensions/global_shortcut_listener_ozone.cc',
'browser/extensions/global_shortcut_listener_ozone.h',
'browser/extensions/global_shortcut_listener_win.cc',
'browser/extensions/global_shortcut_listener_win.h',
'browser/extensions/global_shortcut_listener_x11.cc',
Expand Down

0 comments on commit 02a6a18

Please sign in to comment.