diff options
author | scottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-28 02:18:10 +0000 |
---|---|---|
committer | scottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-28 02:18:10 +0000 |
commit | ed8ce0bc0322185f641ac9fe0b89e1578235f6d4 (patch) | |
tree | 84c4bd8abc1b875bf3ae30bc39962d8075a6f523 | |
parent | b9612a5860f84d95563b2a50a39b799cbbd1cb36 (diff) | |
download | chromium_src-ed8ce0bc0322185f641ac9fe0b89e1578235f6d4.zip chromium_src-ed8ce0bc0322185f641ac9fe0b89e1578235f6d4.tar.gz chromium_src-ed8ce0bc0322185f641ac9fe0b89e1578235f6d4.tar.bz2 |
Revert revert of 146149 - Don't pass the connector check policy along.
Continuation of http://codereview.chromium.org/10692178/
If a browser is running, and the service process is running the connector, the
connector will occasionally start up a chromium process to check the connector
enablement policy. The flag to do so would get passed to a running browser, if
present, and there is a path through the policy check code that could cause the
browser to quit.
This patch prevents the policy check flag from being passed on; the started
process will be very short lived and does a silent launch.
Original Review URL: https://chromiumcodereview.appspot.com/10666010
Second Review URL: http://codereview.chromium.org/10692178/
BUG=134252
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10823059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148872 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chrome_browser_main.cc | 15 | ||||
-rw-r--r-- | chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc | 77 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 5 | ||||
-rw-r--r-- | chrome/common/chrome_result_codes.h | 6 |
4 files changed, 98 insertions, 5 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 60f105a..6369faf 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -1550,13 +1550,22 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; } + bool pass_command_line = true; + #if !defined(OS_MACOSX) // In environments other than Mac OS X we support import of settings // from other browsers. In case this process is a short-lived "import" // process that another browser runs just to import the settings, we // don't want to be checking for another browser process, by design. - if (!HasImportSwitch(parsed_command_line())) { + pass_command_line = !HasImportSwitch(parsed_command_line()); #endif + + // If we're being launched just to check the connector policy, we are + // short-lived and don't want to be passing that switch off. + pass_command_line = pass_command_line && !parsed_command_line().HasSwitch( + switches::kCheckCloudPrintConnectorPolicy); + + if (pass_command_line) { // When another process is running, use that process instead of starting a // new one. NotifyOtherProcess will currently give the other process up to // 20 seconds to respond. Note that this needs to be done before we attempt @@ -1573,7 +1582,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); #endif - return content::RESULT_CODE_NORMAL_EXIT; + return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; case ProcessSingleton::PROFILE_IN_USE: return chrome::RESULT_CODE_PROFILE_IN_USE; @@ -1589,9 +1598,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { default: NOTREACHED(); } -#if !defined(OS_MACOSX) // closing brace for if } -#endif #if defined(USE_X11) SetBrowserX11ErrorHandlers(); diff --git a/chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc b/chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc new file mode 100644 index 0000000..8ce63b4 --- /dev/null +++ b/chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc @@ -0,0 +1,77 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/command_line.h" +#include "base/file_util.h" +#include "base/path_service.h" +#include "base/process_util.h" +#include "base/test/test_timeouts.h" +#include "chrome/common/chrome_notification_types.h" +#include "chrome/common/chrome_result_codes.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "chrome/test/base/ui_test_utils.h" +#include "content/public/browser/notification_service.h" +#include "content/public/common/result_codes.h" + +// These tests don't apply to the Mac version; see GetCommandLineForRelaunch +// for details. +#if defined(OS_MACOSX) +#error This test file should not be part of the Mac build. +#endif + +namespace { + +class CloudPrintPolicyTest : public InProcessBrowserTest { + public: + CloudPrintPolicyTest() {} +}; + +IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, NormalPassedFlag) { + FilePath test_file_path = ui_test_utils::GetTestFilePath( + FilePath(), FilePath().AppendASCII("empty.html")); + CommandLine new_command_line(GetCommandLineForRelaunch()); + new_command_line.AppendArgPath(test_file_path); + + content::WindowedNotificationObserver observer( + chrome::NOTIFICATION_TAB_ADDED, + content::NotificationService::AllSources()); + + base::ProcessHandle handle; + bool launched = + base::LaunchProcess(new_command_line, base::LaunchOptions(), &handle); + EXPECT_TRUE(launched); + + observer.Wait(); + + int exit_code = -100; + bool exited = + base::WaitForExitCodeWithTimeout(handle, &exit_code, + TestTimeouts::action_timeout()); + + EXPECT_TRUE(exited); + EXPECT_EQ(chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED, exit_code); + base::CloseProcessHandle(handle); +} + +IN_PROC_BROWSER_TEST_F(CloudPrintPolicyTest, CloudPrintPolicyFlag) { + CommandLine new_command_line(GetCommandLineForRelaunch()); + new_command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); + + base::ProcessHandle handle; + bool launched = + base::LaunchProcess(new_command_line, base::LaunchOptions(), &handle); + EXPECT_TRUE(launched); + + int exit_code = -100; + bool exited = + base::WaitForExitCodeWithTimeout(handle, &exit_code, + TestTimeouts::action_timeout()); + + EXPECT_TRUE(exited); + EXPECT_EQ(content::RESULT_CODE_NORMAL_EXIT, exit_code); + base::CloseProcessHandle(handle); +} + +} // namespace diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 97ca848..c3734677 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2844,6 +2844,7 @@ 'browser/prefs/pref_service_browsertest.cc', 'browser/prerender/prefetch_browsertest.cc', 'browser/prerender/prerender_browsertest.cc', + 'browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc', 'browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc', 'browser/printing/printing_layout_browsertest.cc', 'browser/printing/print_preview_tab_controller_browsertest.cc', @@ -3079,6 +3080,7 @@ ], 'sources!': [ 'browser/notifications/desktop_notifications_unittest.cc', + 'browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc', 'browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc', 'browser/service/service_process_control_browsertest.cc', # chromeos does not use cross-platform panels @@ -3228,6 +3230,9 @@ 'browser/spellchecker/spellcheck_host_browsertest.cc', # ProcessSingletonMac doesn't do anything. 'browser/process_singleton_browsertest.cc', + # This test depends on GetCommandLineForRelaunch, which is not + # available on Mac. + 'browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc', ], }], ['os_posix == 0 or chromeos == 1', { diff --git a/chrome/common/chrome_result_codes.h b/chrome/common/chrome_result_codes.h index 79886a878..8d9077a 100644 --- a/chrome/common/chrome_result_codes.h +++ b/chrome/common/chrome_result_codes.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -68,6 +68,10 @@ enum ResultCode { // Failed to silently uninstall an extension. RESULT_CODE_UNINSTALL_EXTENSION_ERROR, + // The browser process exited early by passing the command line to another + // running browser. + RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED, + // Last return code (keep this last). RESULT_CODE_CHROME_LAST_CODE, }; |