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

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 const Extension::ExtensionKeybinding* page_action_command =
64 // pageAction. 64 extension->page_action_command();
65 const std::vector<Extension::ExtensionKeybinding>& commands = 65 if (page_action_command) {
66 extension->keybindings(); 66 keybinding_.reset(new ui::Accelerator(page_action_command->accelerator()));
67 for (size_t i = 0; i < commands.size(); ++i) { 67 owner_->GetFocusManager()->RegisterAccelerator(
68 if (commands[i].command_name() == 68 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this);
69 extension_manifest_values::kPageActionKeybindingEvent) {
70 keybinding_.reset(new ui::Accelerator(commands[i].accelerator()));
71 owner_->GetFocusManager()->RegisterAccelerator(
72 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this);
73 break;
74 }
75 } 69 }
76 } 70 }
77 71
78 PageActionImageView::~PageActionImageView() { 72 PageActionImageView::~PageActionImageView() {
79 if (keybinding_.get() && owner_->GetFocusManager()) 73 if (keybinding_.get() && owner_->GetFocusManager())
80 owner_->GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); 74 owner_->GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this);
81 75
82 if (popup_) 76 if (popup_)
83 popup_->GetWidget()->RemoveObserver(this); 77 popup_->GetWidget()->RemoveObserver(this);
84 HidePopup(); 78 HidePopup();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 const Extension* unloaded_extension = 275 const Extension* unloaded_extension =
282 content::Details<UnloadedExtensionInfo>(details)->extension; 276 content::Details<UnloadedExtensionInfo>(details)->extension;
283 if (page_action_ == unloaded_extension ->page_action()) 277 if (page_action_ == unloaded_extension ->page_action())
284 owner_->UpdatePageActions(); 278 owner_->UpdatePageActions();
285 } 279 }
286 280
287 void PageActionImageView::HidePopup() { 281 void PageActionImageView::HidePopup() {
288 if (popup_) 282 if (popup_)
289 popup_->GetWidget()->Close(); 283 popup_->GetWidget()->Close();
290 } 284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698