blob: 0747ce659f877f4cf145deadf4439e043a966e78 [file] [log] [blame]
// Copyright (c) 2012 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_EXTENSION_KEYBINDING_REGISTRY_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_
#pragma once
#include <string>
#include "base/compiler_specific.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_source.h"
class Extension;
class Profile;
namespace extensions {
// The ExtensionKeybindingRegistry is a class that handles the cross-platform
// logic for keyboard accelerators. See platform-specific implementations for
// implementation details for each platform.
class ExtensionKeybindingRegistry : public content::NotificationObserver {
public:
explicit ExtensionKeybindingRegistry(Profile* profile);
virtual ~ExtensionKeybindingRegistry();
// Overridden from content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
protected:
// Add extension keybinding for the events defined by the |extension|.
virtual void AddExtensionKeybinding(const Extension* extension) = 0;
// Remove extension bindings for |extension|.
virtual void RemoveExtensionKeybinding(const Extension* extension) = 0;
// Make sure all extensions registered have keybindings added.
void Init();
// Whether to ignore this command. Only browserAction commands and pageAction
// commands are currently ignored, since they are handled elsewhere.
bool ShouldIgnoreCommand(const std::string& command) const;
private:
// The content notification registrar for listening to extension events.
content::NotificationRegistrar registrar_;
// Weak pointer to the our profile. Not owned by us.
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(ExtensionKeybindingRegistry);
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_KEYBINDING_REGISTRY_H_