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

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, 8 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 Extension::kPageActionIconMaxSize), 54 Extension::kPageActionIconMaxSize),
55 ImageLoadingTracker::DONT_CACHE); 55 ImageLoadingTracker::DONT_CACHE);
56 } 56 }
57 57
58 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 58 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
59 content::Source<Profile>( 59 content::Source<Profile>(
60 owner_->profile()->GetOriginalProfile())); 60 owner_->profile()->GetOriginalProfile()));
61 61
62 set_accessibility_focusable(true); 62 set_accessibility_focusable(true);
63 63
64 // Iterate through all the keybindings and see if one is assigned to the 64 const Extension::ExtensionKeybinding* page_action_command =
65 // pageAction. 65 extension->page_action_command();
66 const std::vector<Extension::ExtensionKeybinding>& commands = 66 if (page_action_command) {
67 extension->keybindings(); 67 keybinding_.reset(new ui::Accelerator(page_action_command->accelerator()));
68 for (size_t i = 0; i < commands.size(); ++i) { 68 owner_->GetFocusManager()->RegisterAccelerator(
69 if (commands[i].command_name() == 69 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this);
70 extension_manifest_values::kPageActionKeybindingEvent) {
71 keybinding_.reset(new ui::Accelerator(commands[i].accelerator()));
72 owner_->GetFocusManager()->RegisterAccelerator(
73 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this);
74 break;
75 }
76 } 70 }
77 } 71 }
78 72
79 PageActionImageView::~PageActionImageView() { 73 PageActionImageView::~PageActionImageView() {
80 if (keybinding_.get() && owner_->GetFocusManager()) 74 if (keybinding_.get() && owner_->GetFocusManager())
81 owner_->GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); 75 owner_->GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this);
82 76
83 if (popup_) 77 if (popup_)
84 popup_->GetWidget()->RemoveObserver(this); 78 popup_->GetWidget()->RemoveObserver(this);
85 HidePopup(); 79 HidePopup();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 const Extension* unloaded_extension = 276 const Extension* unloaded_extension =
283 content::Details<UnloadedExtensionInfo>(details)->extension; 277 content::Details<UnloadedExtensionInfo>(details)->extension;
284 if (page_action_ == unloaded_extension ->page_action()) 278 if (page_action_ == unloaded_extension ->page_action())
285 owner_->UpdatePageActions(); 279 owner_->UpdatePageActions();
286 } 280 }
287 281
288 void PageActionImageView::HidePopup() { 282 void PageActionImageView::HidePopup() {
289 if (popup_) 283 if (popup_)
290 popup_->GetWidget()->Close(); 284 popup_->GetWidget()->Close();
291 } 285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698