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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_actions_container.cc

Issue 553243002: Track the active ExtensionKeybindingRegistry and make it available to EventRewriter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Fix bool vs BOOL. Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/toolbar/browser_actions_container.h" 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/extensions/extension_action_manager.h" 9 #include "chrome/browser/extensions/extension_action_manager.h"
10 #include "chrome/browser/extensions/extension_commands_global_registry.h"
10 #include "chrome/browser/extensions/extension_util.h" 11 #include "chrome/browser/extensions/extension_util.h"
11 #include "chrome/browser/extensions/extension_view_host.h" 12 #include "chrome/browser/extensions/extension_view_host.h"
12 #include "chrome/browser/extensions/tab_helper.h" 13 #include "chrome/browser/extensions/tab_helper.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/browser/ui/view_ids.h" 18 #include "chrome/browser/ui/view_ids.h"
18 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" 19 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
19 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" 20 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 void BrowserActionsContainer::ExecuteExtensionCommand( 263 void BrowserActionsContainer::ExecuteExtensionCommand(
263 const extensions::Extension* extension, 264 const extensions::Extension* extension,
264 const extensions::Command& command) { 265 const extensions::Command& command) {
265 // Global commands are handled by the ExtensionCommandsGlobalRegistry 266 // Global commands are handled by the ExtensionCommandsGlobalRegistry
266 // instance. 267 // instance.
267 DCHECK(!command.global()); 268 DCHECK(!command.global());
268 extension_keybinding_registry_->ExecuteCommand(extension->id(), 269 extension_keybinding_registry_->ExecuteCommand(extension->id(),
269 command.accelerator()); 270 command.accelerator());
270 } 271 }
271 272
273 bool BrowserActionsContainer::IsExtensionCommandRegistered(
274 const ui::Accelerator& accelerator) {
275 return extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile())
276 ->IsAcceleratorRegistered(accelerator) ||
277 extension_keybinding_registry_->IsAcceleratorRegistered(accelerator);
278 }
279
272 bool BrowserActionsContainer::ShownInsideMenu() const { 280 bool BrowserActionsContainer::ShownInsideMenu() const {
273 return in_overflow_mode(); 281 return in_overflow_mode();
274 } 282 }
275 283
276 void BrowserActionsContainer::OnBrowserActionViewDragDone() { 284 void BrowserActionsContainer::OnBrowserActionViewDragDone() {
277 // We notify here as well as in OnPerformDrop because the dragged view is 285 // We notify here as well as in OnPerformDrop because the dragged view is
278 // removed in OnPerformDrop, so it will never get its OnDragDone() call. 286 // removed in OnPerformDrop, so it will never get its OnDragDone() call.
279 // TODO(devlin): we should see about fixing that. 287 // TODO(devlin): we should see about fixing that.
280 FOR_EACH_OBSERVER(BrowserActionsContainerObserver, 288 FOR_EACH_OBSERVER(BrowserActionsContainerObserver,
281 observers_, 289 observers_,
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 size_t absolute_model_size = 1082 size_t absolute_model_size =
1075 model_size == -1 ? extensions.size() : model_size; 1083 model_size == -1 ? extensions.size() : model_size;
1076 1084
1077 // The main container will try to show |model_size| icons, but reduce if there 1085 // The main container will try to show |model_size| icons, but reduce if there
1078 // aren't enough displayable icons to do so. 1086 // aren't enough displayable icons to do so.
1079 size_t main_displayed = std::min(displayable_icon_count, absolute_model_size); 1087 size_t main_displayed = std::min(displayable_icon_count, absolute_model_size);
1080 // The overflow will display the extras, if any. 1088 // The overflow will display the extras, if any.
1081 return in_overflow_mode() ? 1089 return in_overflow_mode() ?
1082 displayable_icon_count - main_displayed : main_displayed; 1090 displayable_icon_count - main_displayed : main_displayed;
1083 } 1091 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698