Created
August 12, 2012 23:42
-
-
Save ajakubek/3335417 to your computer and use it in GitHub Desktop.
Chrome focus stealing prevention.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 6e59bfbc45983b8680f023ac07a34cabe80985e5 | |
Author: Adam Jakubek <[email protected]> | |
Date: Mon Aug 13 01:24:39 2012 +0200 | |
Prevent focus stealing when opening diverted URLs | |
This patch allows to override current Chrome's behavior, where opening a | |
link from an external application (e.g. mail client) causes Chrome's | |
window to steal focus. | |
It works by introducing a new command line switch | |
"--disable-focus-stealing". If this flag is present in a command line | |
with URL, existing Chrome window will stay in the backround while | |
opening the page. | |
Fixes #58107 from Chromium's bug tracker. | |
diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc | |
index f143d25..0cb033f 100644 | |
--- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc | |
+++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc | |
@@ -770,7 +770,9 @@ Browser* StartupBrowserCreatorImpl::OpenTabsInBrowser(Browser* browser, | |
chrome::ActivateTabAt(browser, 0, false); | |
} | |
- browser->window()->Show(); | |
+ if (!command_line_.HasSwitch(switches::kDisableFocusStealing)) | |
+ browser->window()->Show(); | |
+ | |
// TODO(jcampan): http://crbug.com/8123 we should not need to set the initial | |
// focus explicitly. | |
chrome::GetActiveWebContents(browser)->GetView()->SetInitialFocus(); | |
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc | |
index 43af00e..5a7c6dd 100644 | |
--- a/chrome/common/chrome_switches.cc | |
+++ b/chrome/common/chrome_switches.cc | |
@@ -328,6 +328,9 @@ const char kDisableExtensionsResourceWhitelist[] = | |
// Disables the sandbox for the built-in flash player. | |
const char kDisableFlashSandbox[] = "disable-flash-sandbox"; | |
+// Disables focus stealing when opening a URL from command line. | |
+const char kDisableFocusStealing[] = "disable-focus-stealing"; | |
+ | |
// Disables improved SafeBrowsing download protection. | |
const char kDisableImprovedDownloadProtection[] = | |
"disable-improved-download-protection"; | |
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h | |
index 93af339..996c3f12 100644 | |
--- a/chrome/common/chrome_switches.h | |
+++ b/chrome/common/chrome_switches.h | |
@@ -96,6 +96,7 @@ extern const char kDisableExtensionsHttpThrottling[]; | |
extern const char kDisableExtensionsResourceWhitelist[]; | |
extern const char kDisableExtensions[]; | |
extern const char kDisableFlashSandbox[]; | |
+extern const char kDisableFocusStealing[]; | |
extern const char kDisableImprovedDownloadProtection[]; | |
extern const char kDisableInBrowserThumbnailing[]; | |
extern const char kDisableInternalFlash[]; |
Hello, how do you apply this patch?
I'd love to know how to install this as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Google is not interested in fixing this bug.
Patch works correctly with Chrome version 21.