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

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

Issue 360423002: Allow WebContents key handling to supplant extension overrides of the bookmark shortcut (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: address comments Created 6 years, 5 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_action_view.h" 5 #include "chrome/browser/ui/views/toolbar/browser_action_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/extensions/api/commands/command_service.h" 9 #include "chrome/browser/extensions/api/commands/command_service.h"
10 #include "chrome/browser/extensions/extension_action.h" 10 #include "chrome/browser/extensions/extension_action.h"
11 #include "chrome/browser/extensions/extension_action_manager.h" 11 #include "chrome/browser/extensions/extension_action_manager.h"
12 #include "chrome/browser/extensions/extension_context_menu_model.h" 12 #include "chrome/browser/extensions/extension_context_menu_model.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/themes/theme_service.h" 15 #include "chrome/browser/themes/theme_service.h"
16 #include "chrome/browser/themes/theme_service_factory.h" 16 #include "chrome/browser/themes/theme_service_factory.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/extensions/accelerator_priority.h"
18 #include "chrome/browser/ui/view_ids.h" 19 #include "chrome/browser/ui/view_ids.h"
19 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" 20 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 21 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
21 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
22 #include "extensions/common/manifest_constants.h" 23 #include "extensions/common/manifest_constants.h"
23 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
24 #include "grit/theme_resources.h" 25 #include "grit/theme_resources.h"
25 #include "ui/accessibility/ax_view_state.h" 26 #include "ui/accessibility/ax_view_state.h"
26 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/resource/resource_bundle.h" 28 #include "ui/base/resource/resource_bundle.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 340
340 void BrowserActionButton::OnGestureEvent(ui::GestureEvent* event) { 341 void BrowserActionButton::OnGestureEvent(ui::GestureEvent* event) {
341 if (IsPopup()) 342 if (IsPopup())
342 MenuButton::OnGestureEvent(event); 343 MenuButton::OnGestureEvent(event);
343 else 344 else
344 LabelButton::OnGestureEvent(event); 345 LabelButton::OnGestureEvent(event);
345 } 346 }
346 347
347 bool BrowserActionButton::AcceleratorPressed( 348 bool BrowserActionButton::AcceleratorPressed(
348 const ui::Accelerator& accelerator) { 349 const ui::Accelerator& accelerator) {
350 // Normal priority shortcuts must be handled via the standard browser command
351 // processing to be effective.
352 if (GetAcceleratorPriority(accelerator, extension_) ==
353 ui::AcceleratorManager::kNormalPriority)
354 return false;
355
349 delegate_->OnBrowserActionExecuted(this); 356 delegate_->OnBrowserActionExecuted(this);
350 return true; 357 return true;
351 } 358 }
352 359
353 void BrowserActionButton::SetButtonPushed() { 360 void BrowserActionButton::SetButtonPushed() {
354 SetState(views::CustomButton::STATE_PRESSED); 361 SetState(views::CustomButton::STATE_PRESSED);
355 menu_visible_ = true; 362 menu_visible_ = true;
356 } 363 }
357 364
358 void BrowserActionButton::SetButtonNotPushed() { 365 void BrowserActionButton::SetButtonNotPushed() {
(...skipping 26 matching lines...) Expand all
385 extensions::CommandService::Get(browser_->profile()); 392 extensions::CommandService::Get(browser_->profile());
386 extensions::Command browser_action_command; 393 extensions::Command browser_action_command;
387 if (command_service->GetBrowserActionCommand( 394 if (command_service->GetBrowserActionCommand(
388 extension_->id(), 395 extension_->id(),
389 extensions::CommandService::ACTIVE_ONLY, 396 extensions::CommandService::ACTIVE_ONLY,
390 &browser_action_command, 397 &browser_action_command,
391 NULL)) { 398 NULL)) {
392 keybinding_.reset(new ui::Accelerator( 399 keybinding_.reset(new ui::Accelerator(
393 browser_action_command.accelerator())); 400 browser_action_command.accelerator()));
394 GetFocusManager()->RegisterAccelerator( 401 GetFocusManager()->RegisterAccelerator(
395 *keybinding_.get(), ui::AcceleratorManager::kHighPriority, this); 402 *keybinding_.get(),
403 GetAcceleratorPriority(browser_action_command.accelerator(),
404 extension_),
405 this);
396 } 406 }
397 } 407 }
398 408
399 void BrowserActionButton::MaybeUnregisterExtensionCommand(bool only_if_active) { 409 void BrowserActionButton::MaybeUnregisterExtensionCommand(bool only_if_active) {
400 if (!keybinding_.get() || !GetFocusManager()) 410 if (!keybinding_.get() || !GetFocusManager())
401 return; 411 return;
402 412
403 extensions::CommandService* command_service = 413 extensions::CommandService* command_service =
404 extensions::CommandService::Get(browser_->profile()); 414 extensions::CommandService::Get(browser_->profile());
405 415
406 extensions::Command browser_action_command; 416 extensions::Command browser_action_command;
407 if (!only_if_active || !command_service->GetBrowserActionCommand( 417 if (!only_if_active || !command_service->GetBrowserActionCommand(
408 extension_->id(), 418 extension_->id(),
409 extensions::CommandService::ACTIVE_ONLY, 419 extensions::CommandService::ACTIVE_ONLY,
410 &browser_action_command, 420 &browser_action_command,
411 NULL)) { 421 NULL)) {
412 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); 422 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this);
413 keybinding_.reset(NULL); 423 keybinding_.reset(NULL);
414 } 424 }
415 } 425 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698