diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-11 00:33:38 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-11 00:33:38 +0000 |
commit | f4acfae80866fff2e2fc760c396ba89db57de522 (patch) | |
tree | ccdd618b0d16fb94e8c10d11218b689df8cd9083 /chrome | |
parent | 33521502aee91e668255810164fd122b7b47bd89 (diff) | |
download | chromium_src-f4acfae80866fff2e2fc760c396ba89db57de522.zip chromium_src-f4acfae80866fff2e2fc760c396ba89db57de522.tar.gz chromium_src-f4acfae80866fff2e2fc760c396ba89db57de522.tar.bz2 |
Add command line switch --activate-on-launch to help Selenium.
Implemented for Mac; behavior implicit on Windows.
If you do NOT get an "activate on launch" behavior on Windows, it is
because Selenium is not the current foreground app. See
http://msdn.microsoft.com/en-us/library/ms633539(VS.85).aspx
for details on foreground behavior. This isn't something we can fix
in Chrome on Windows.
BUG=http://crbug.com/20935
TEST=Launch Chrome from the command line.
E.g. "..../Chromium.app/Contents/MacOS/Chromium". See it NOT gain
foreground. Add --activate-on-launch. DO see it gain foreground.
Review URL: http://codereview.chromium.org/202053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25958 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/app_controller_mac.mm | 12 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 4 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 2 |
3 files changed, 18 insertions, 0 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index be11db3..e3f88e9 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -30,6 +30,7 @@ #include "chrome/browser/download/download_manager.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/sessions/tab_restore_service.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/browser/profile_manager.h" @@ -108,6 +109,17 @@ // Set up the command updater for when there are no windows open [self initMenuState]; + + // Activate (bring to foreground) if asked to do so. On + // Windows this logic isn't necessary since + // BrowserWindow::Activate() calls ::SetForegroundWindow() which is + // adequate. On Mac, BrowserWindow::Activate() calls -[NSWindow + // makeKeyAndOrderFront:] which does not activate the application + // itself. + const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); + if (parsed_command_line.HasSwitch(switches::kActivateOnLaunch)) { + [NSApp activateIgnoringOtherApps:YES]; + } } // Checks if there are any tabs with sheets open, and if so, raises one of diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 90cd98f..db5219c 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -604,4 +604,8 @@ const wchar_t kEnableByteRangeSupport[] = L"enable-byte-range-support"; // numbers. const wchar_t kExplicitlyAllowedPorts[] = L"explicitly-allowed-ports"; +// Activate (make foreground) myself on launch. Helpful when Chrome +// is launched on the command line (e.g. by Selenium). Only needed on Mac. +const wchar_t kActivateOnLaunch[] = L"activate-on-launch"; + } // namespace switches diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 959b0b3..fe51017 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -244,6 +244,8 @@ extern const wchar_t kEnableByteRangeSupport[]; extern const wchar_t kExplicitlyAllowedPorts[]; +extern const wchar_t kActivateOnLaunch[]; + } // namespace switches #endif // CHROME_COMMON_CHROME_SWITCHES_H_ |