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

Side by Side Diff: chrome/browser/ui/views/browser_actions_container.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/browser_actions_container.h" 5 #include "chrome/browser/ui/views/browser_actions_container.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 gfx::Size(Extension::kBrowserActionIconMaxSize, 110 gfx::Size(Extension::kBrowserActionIconMaxSize,
111 Extension::kBrowserActionIconMaxSize), 111 Extension::kBrowserActionIconMaxSize),
112 ImageLoadingTracker::DONT_CACHE); 112 ImageLoadingTracker::DONT_CACHE);
113 } else { 113 } else {
114 // Set the icon to be the default extensions icon. 114 // Set the icon to be the default extensions icon.
115 default_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( 115 default_icon_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
116 IDR_EXTENSIONS_FAVICON).ToSkBitmap(); 116 IDR_EXTENSIONS_FAVICON).ToSkBitmap();
117 UpdateState(); 117 UpdateState();
118 } 118 }
119 119
120 // Iterate through all the keybindings and see if one is assigned to the 120 const Extension::ExtensionKeybinding* browser_action_command =
121 // browserAction. 121 extension_->browser_action_command();
122 const std::vector<Extension::ExtensionKeybinding>& commands = 122 if (browser_action_command) {
123 extension_->keybindings(); 123 keybinding_.reset(new ui::Accelerator(
124 for (size_t i = 0; i < commands.size(); ++i) { 124 browser_action_command->accelerator()));
125 if (commands[i].command_name() == 125 panel_->GetFocusManager()->RegisterAccelerator(
126 extension_manifest_values::kBrowserActionKeybindingEvent) { 126 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this);
127 keybinding_.reset(new ui::Accelerator(commands[i].accelerator()));
128 panel_->GetFocusManager()->RegisterAccelerator(
129 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this);
130 break;
131 }
132 } 127 }
133 } 128 }
134 129
135 MenuButton::ViewHierarchyChanged(is_add, parent, child); 130 MenuButton::ViewHierarchyChanged(is_add, parent, child);
136 } 131 }
137 132
138 void BrowserActionButton::ButtonPressed(views::Button* sender, 133 void BrowserActionButton::ButtonPressed(views::Button* sender,
139 const views::Event& event) { 134 const views::Event& event) {
140 panel_->OnBrowserActionExecuted(this, false); 135 panel_->OnBrowserActionExecuted(this, false);
141 } 136 }
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 } 1126 }
1132 } 1127 }
1133 1128
1134 bool BrowserActionsContainer::ShouldDisplayBrowserAction( 1129 bool BrowserActionsContainer::ShouldDisplayBrowserAction(
1135 const Extension* extension) { 1130 const Extension* extension) {
1136 // Only display incognito-enabled extensions while in incognito mode. 1131 // Only display incognito-enabled extensions while in incognito mode.
1137 return 1132 return
1138 (!profile_->IsOffTheRecord() || 1133 (!profile_->IsOffTheRecord() ||
1139 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); 1134 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id()));
1140 } 1135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698