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

Unified Diff: chrome/browser/ui/views/location_bar/page_action_image_view.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/location_bar/page_action_image_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/location_bar/page_action_image_view.cc
===================================================================
--- chrome/browser/ui/views/location_bar/page_action_image_view.cc (revision 123221)
+++ chrome/browser/ui/views/location_bar/page_action_image_view.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -58,9 +58,26 @@
owner_->browser()->profile()->GetOriginalProfile()));
set_accessibility_focusable(true);
+
+ // Iterate through all the keybindings and see if one is assigned to the
+ // pageAction.
+ 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::kPageActionKeybindingEvent) {
+ keybinding_.reset(new ui::Accelerator(commands[i].accelerator()));
+ owner_->GetFocusManager()->RegisterAccelerator(
+ *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this);
+ break;
+ }
+ }
}
PageActionImageView::~PageActionImageView() {
+ if (keybinding_.get() && owner_->GetFocusManager())
+ owner_->GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this);
+
if (popup_)
popup_->GetWidget()->RemoveObserver(this);
HidePopup();
@@ -185,6 +202,20 @@
owner_->UpdatePageActions();
}
+bool PageActionImageView::AcceleratorPressed(
+ const ui::Accelerator& accelerator) {
+ DCHECK(visible()); // Should not have happened due to CanHandleAccelerator.
+
+ ExecuteAction(1, false); // 1 means left-click, false means "don't inspect".
+ return true;
+}
+
+bool PageActionImageView::CanHandleAccelerators() const {
+ // While visible, we don't handle accelerators and while so we also don't
+ // count as a priority accelerator handler.
+ return visible();
+}
+
void PageActionImageView::UpdateVisibility(WebContents* contents,
const GURL& url) {
// Save this off so we can pass it back to the extension when the action gets
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698