Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1478)

Unified Diff: chrome/browser/ui/views/browser_actions_container.cc

Issue 9402018: Experimental Extension Keybinding (first cut). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/browser_actions_container.h ('k') | chrome/browser/ui/views/dropdown_bar_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/browser_actions_container.cc
===================================================================
--- chrome/browser/ui/views/browser_actions_container.cc (revision 123221)
+++ chrome/browser/ui/views/browser_actions_container.cc (working copy)
@@ -23,6 +23,7 @@
#include "chrome/browser/ui/views/extensions/extension_popup.h"
#include "chrome/browser/ui/views/toolbar_view.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_action.h"
#include "chrome/common/extensions/extension_resource.h"
#include "chrome/common/pref_names.h"
@@ -83,6 +84,9 @@
}
void BrowserActionButton::Destroy() {
+ if (keybinding_.get() && panel_->GetFocusManager())
+ panel_->GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this);
+
if (context_menu_) {
context_menu_->Cancel();
MessageLoop::current()->DeleteSoon(FROM_HERE, this);
@@ -108,6 +112,20 @@
gfx::Size(Extension::kBrowserActionIconMaxSize,
Extension::kBrowserActionIconMaxSize),
ImageLoadingTracker::DONT_CACHE);
+
+ // Iterate through all the keybindings and see if one is assigned to the
+ // browserAction.
+ const std::vector<Extension::ExtensionKeybinding>& commands =
+ extension_->keybindings();
+ for (size_t i = 0; i < commands.size(); ++i) {
+ if (commands[i].command_name() ==
+ extension_manifest_values::kBrowserActionKeybindingEvent) {
+ keybinding_.reset(new ui::Accelerator(commands[i].accelerator()));
+ panel_->GetFocusManager()->RegisterAccelerator(
+ *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this);
+ break;
+ }
+ }
}
MenuButton::ViewHierarchyChanged(is_add, parent, child);
@@ -271,6 +289,12 @@
context_menu_ = NULL;
}
+bool BrowserActionButton::AcceleratorPressed(
+ const ui::Accelerator& accelerator) {
+ panel_->OnBrowserActionExecuted(this, false);
+ return true;
+}
+
void BrowserActionButton::SetButtonPushed() {
SetState(views::CustomButton::BS_PUSHED);
menu_visible_ = true;
@@ -359,6 +383,8 @@
container_width_(0),
chevron_(NULL),
overflow_menu_(NULL),
+ extension_keybinding_registry_(browser->profile(),
+ owner_view->GetFocusManager()),
suppress_chevron_(false),
resize_amount_(0),
animation_target_size_(0),
« no previous file with comments | « chrome/browser/ui/views/browser_actions_container.h ('k') | chrome/browser/ui/views/dropdown_bar_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698