Merge to M86: Disable caret browsing toggle on Mac when web contents isn't focused.
This is a follow-up to http://crrev.com/c/2472897 - it turns
out that it's not sufficient to make the caret browsing toggle
do nothing, we have to actually disable the command in order for
it not to interfere with Japanese IMEs.
This required a bit of extra work to ensure that the command
enabled status is updated when focus changes.
Test in follow-up: https://crrev.com/c/2476910
(cherry picked from commit 14aea1a8a4defbfb4c40351c9fce4fb6ceb744d2)
Bug: 1138475
AX-Relnotes: Pressing F7 to toggle caret browsing no longer interferes with Japanese IMEs
Change-Id: I0497b377ee74f1916e0dd2ca9a5c4f1d24f1d332
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2476906
Commit-Queue: Dominic Mazzoni <[email protected]>
Reviewed-by: Elly Fong-Jones <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#817814}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485137
Reviewed-by: Dominic Mazzoni <[email protected]>
Cr-Commit-Position: refs/branch-heads/4240@{#1281}
Cr-Branched-From: f297677702651916bbf65e59c0d4bbd4ce57d1ee-refs/heads/master@{#800218}
diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc
index b17423f..e60b5135 100644
--- a/chrome/browser/ui/browser_command_controller.cc
+++ b/chrome/browser/ui/browser_command_controller.cc
@@ -265,6 +265,7 @@
void BrowserCommandController::TabStateChanged() {
UpdateCommandsForTabState();
+ UpdateCommandsForWebContentsFocus();
}
void BrowserCommandController::ZoomStateChanged() {
@@ -310,6 +311,10 @@
UpdateCommandsForTabKeyboardFocus(index);
}
+void BrowserCommandController::WebContentsFocusChanged() {
+ UpdateCommandsForWebContentsFocus();
+}
+
////////////////////////////////////////////////////////////////////////////////
// BrowserCommandController, CommandUpdater implementation:
@@ -1057,6 +1062,7 @@
UpdateCommandsForBookmarkEditing();
UpdateCommandsForIncognitoAvailability();
UpdateCommandsForTabKeyboardFocus(GetKeyboardFocusedTabIndex(browser_));
+ UpdateCommandsForWebContentsFocus();
}
// static
@@ -1487,6 +1493,15 @@
IDC_GROUP_TARGET_TAB, normal_window && target_index.has_value());
}
+void BrowserCommandController::UpdateCommandsForWebContentsFocus() {
+#if defined(OS_MAC)
+ // On Mac, toggling caret browsing changes whether it's enabled or not
+ // based on web contents focus.
+ command_updater_.UpdateCommandEnabled(IDC_CARET_BROWSING_TOGGLE,
+ CanToggleCaretBrowsing(browser_));
+#endif // defined(OS_MAC)
+}
+
BrowserWindow* BrowserCommandController::window() {
return browser_->window();
}