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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 2128243003: Make most browser accelerators not repeat. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 1991 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 2002
2003 /////////////////////////////////////////////////////////////////////////////// 2003 ///////////////////////////////////////////////////////////////////////////////
2004 // BrowserView, ui::AcceleratorTarget overrides: 2004 // BrowserView, ui::AcceleratorTarget overrides:
2005 2005
2006 bool BrowserView::AcceleratorPressed(const ui::Accelerator& accelerator) { 2006 bool BrowserView::AcceleratorPressed(const ui::Accelerator& accelerator) {
2007 std::map<ui::Accelerator, int>::const_iterator iter = 2007 std::map<ui::Accelerator, int>::const_iterator iter =
2008 accelerator_table_.find(accelerator); 2008 accelerator_table_.find(accelerator);
2009 DCHECK(iter != accelerator_table_.end()); 2009 DCHECK(iter != accelerator_table_.end());
2010 int command_id = iter->second; 2010 int command_id = iter->second;
2011 2011
2012 if (accelerator.IsRepeat() && !repeatable_command_ids_.count(command_id))
2013 return false;
2014
2012 chrome::BrowserCommandController* controller = browser_->command_controller(); 2015 chrome::BrowserCommandController* controller = browser_->command_controller();
2013 if (!controller->block_command_execution()) 2016 if (!controller->block_command_execution())
2014 UpdateAcceleratorMetrics(accelerator, command_id); 2017 UpdateAcceleratorMetrics(accelerator, command_id);
2015 return chrome::ExecuteCommand(browser_.get(), command_id); 2018 return chrome::ExecuteCommand(browser_.get(), command_id);
2016 } 2019 }
2017 2020
2018 /////////////////////////////////////////////////////////////////////////////// 2021 ///////////////////////////////////////////////////////////////////////////////
2019 // BrowserView, OmniboxPopupModelObserver overrides: 2022 // BrowserView, OmniboxPopupModelObserver overrides:
2020 void BrowserView::OnOmniboxPopupShownOrHidden() { 2023 void BrowserView::OnOmniboxPopupShownOrHidden() {
2021 SetMaxTopArrowHeight(GetMaxTopInfoBarArrowHeight(), infobar_container_); 2024 SetMaxTopArrowHeight(GetMaxTopInfoBarArrowHeight(), infobar_container_);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
2391 if (is_app_mode && !chrome::IsCommandAllowedInAppMode(it->command_id)) 2394 if (is_app_mode && !chrome::IsCommandAllowedInAppMode(it->command_id))
2392 continue; 2395 continue;
2393 2396
2394 ui::Accelerator accelerator(it->keycode, it->modifiers); 2397 ui::Accelerator accelerator(it->keycode, it->modifiers);
2395 accelerator_table_[accelerator] = it->command_id; 2398 accelerator_table_[accelerator] = it->command_id;
2396 2399
2397 // Also register with the focus manager. 2400 // Also register with the focus manager.
2398 focus_manager->RegisterAccelerator( 2401 focus_manager->RegisterAccelerator(
2399 accelerator, ui::AcceleratorManager::kNormalPriority, this); 2402 accelerator, ui::AcceleratorManager::kNormalPriority, this);
2400 } 2403 }
2404
2405 const std::vector<int> command_ids(chrome::GetRepeatableCommandIds());
2406 repeatable_command_ids_ =
2407 std::set<int>(command_ids.begin(), command_ids.end());
2401 } 2408 }
2402 2409
2403 int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const { 2410 int BrowserView::GetCommandIDForAppCommandID(int app_command_id) const {
2404 #if defined(OS_WIN) 2411 #if defined(OS_WIN)
2405 switch (app_command_id) { 2412 switch (app_command_id) {
2406 // NOTE: The order here matches the APPCOMMAND declaration order in the 2413 // NOTE: The order here matches the APPCOMMAND declaration order in the
2407 // Windows headers. 2414 // Windows headers.
2408 case APPCOMMAND_BROWSER_BACKWARD: return IDC_BACK; 2415 case APPCOMMAND_BROWSER_BACKWARD: return IDC_BACK;
2409 case APPCOMMAND_BROWSER_FORWARD: return IDC_FORWARD; 2416 case APPCOMMAND_BROWSER_FORWARD: return IDC_FORWARD;
2410 case APPCOMMAND_BROWSER_REFRESH: return IDC_RELOAD; 2417 case APPCOMMAND_BROWSER_REFRESH: return IDC_RELOAD;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
2653 } 2660 }
2654 2661
2655 extensions::ActiveTabPermissionGranter* 2662 extensions::ActiveTabPermissionGranter*
2656 BrowserView::GetActiveTabPermissionGranter() { 2663 BrowserView::GetActiveTabPermissionGranter() {
2657 content::WebContents* web_contents = GetActiveWebContents(); 2664 content::WebContents* web_contents = GetActiveWebContents();
2658 if (!web_contents) 2665 if (!web_contents)
2659 return nullptr; 2666 return nullptr;
2660 return extensions::TabHelper::FromWebContents(web_contents) 2667 return extensions::TabHelper::FromWebContents(web_contents)
2661 ->active_tab_permission_granter(); 2668 ->active_tab_permission_granter();
2662 } 2669 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698