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

Side by Side Diff: chrome/browser/ui/views/location_bar/page_action_image_view.cc

Issue 9812008: Polish the keybinding implementation a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 5 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_browser_event_router.h" 8 #include "chrome/browser/extensions/extension_browser_event_router.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_tab_util.h" 10 #include "chrome/browser/extensions/extension_tab_util.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 Extension::kPageActionIconMaxSize), 53 Extension::kPageActionIconMaxSize),
54 ImageLoadingTracker::DONT_CACHE); 54 ImageLoadingTracker::DONT_CACHE);
55 } 55 }
56 56
57 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 57 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
58 content::Source<Profile>( 58 content::Source<Profile>(
59 owner_->profile()->GetOriginalProfile())); 59 owner_->profile()->GetOriginalProfile()));
60 60
61 set_accessibility_focusable(true); 61 set_accessibility_focusable(true);
62 62
63 // Iterate through all the keybindings and see if one is assigned to the 63 std::vector<Extension::ExtensionKeybinding> page_action_command;
64 // pageAction. 64 extension->GetCommandByType(Extension::ExtensionKeybinding::PAGE_ACTION,
65 const std::vector<Extension::ExtensionKeybinding>& commands = 65 &page_action_command);
66 extension->keybindings(); 66 if (!page_action_command.empty()) {
67 for (size_t i = 0; i < commands.size(); ++i) { 67 Extension::ExtensionKeybinding* command = &page_action_command[0];
68 if (commands[i].command_name() == 68 keybinding_.reset(new ui::Accelerator(command->accelerator()));
69 extension_manifest_values::kPageActionKeybindingEvent) { 69 owner_->GetFocusManager()->RegisterAccelerator(
70 keybinding_.reset(new ui::Accelerator(commands[i].accelerator())); 70 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this);
71 owner_->GetFocusManager()->RegisterAccelerator(
72 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this);
73 break;
74 }
75 } 71 }
76 } 72 }
77 73
78 PageActionImageView::~PageActionImageView() { 74 PageActionImageView::~PageActionImageView() {
79 if (keybinding_.get() && owner_->GetFocusManager()) 75 if (keybinding_.get() && owner_->GetFocusManager())
80 owner_->GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); 76 owner_->GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this);
81 77
82 if (popup_) 78 if (popup_)
83 popup_->GetWidget()->RemoveObserver(this); 79 popup_->GetWidget()->RemoveObserver(this);
84 HidePopup(); 80 HidePopup();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 const Extension* unloaded_extension = 277 const Extension* unloaded_extension =
282 content::Details<UnloadedExtensionInfo>(details)->extension; 278 content::Details<UnloadedExtensionInfo>(details)->extension;
283 if (page_action_ == unloaded_extension ->page_action()) 279 if (page_action_ == unloaded_extension ->page_action())
284 owner_->UpdatePageActions(); 280 owner_->UpdatePageActions();
285 } 281 }
286 282
287 void PageActionImageView::HidePopup() { 283 void PageActionImageView::HidePopup() {
288 if (popup_) 284 if (popup_)
289 popup_->GetWidget()->Close(); 285 popup_->GetWidget()->Close();
290 } 286 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698