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
parent b9612a58
...@@ -1550,13 +1550,22 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { ...@@ -1550,13 +1550,22 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; return chrome::RESULT_CODE_PACK_EXTENSION_ERROR;
} }
bool pass_command_line = true;
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
// In environments other than Mac OS X we support import of settings // In environments other than Mac OS X we support import of settings
// from other browsers. In case this process is a short-lived "import" // from other browsers. In case this process is a short-lived "import"
// process that another browser runs just to import the settings, we // process that another browser runs just to import the settings, we
// don't want to be checking for another browser process, by design. // 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 #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 // When another process is running, use that process instead of starting a
// new one. NotifyOtherProcess will currently give the other process up to // 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 // 20 seconds to respond. Note that this needs to be done before we attempt
...@@ -1573,7 +1582,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { ...@@ -1573,7 +1582,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( printf("%s\n", base::SysWideToNativeMB(UTF16ToWide(
l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str());
#endif #endif
return content::RESULT_CODE_NORMAL_EXIT; return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED;
case ProcessSingleton::PROFILE_IN_USE: case ProcessSingleton::PROFILE_IN_USE:
return chrome::RESULT_CODE_PROFILE_IN_USE; return chrome::RESULT_CODE_PROFILE_IN_USE;
...@@ -1589,9 +1598,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { ...@@ -1589,9 +1598,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
default: default:
NOTREACHED(); NOTREACHED();
} }
#if !defined(OS_MACOSX) // closing brace for if
} }
#endif
#if defined(USE_X11) #if defined(USE_X11)
SetBrowserX11ErrorHandlers(); SetBrowserX11ErrorHandlers();
......
// 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
...@@ -2844,6 +2844,7 @@ ...@@ -2844,6 +2844,7 @@
'browser/prefs/pref_service_browsertest.cc', 'browser/prefs/pref_service_browsertest.cc',
'browser/prerender/prefetch_browsertest.cc', 'browser/prerender/prefetch_browsertest.cc',
'browser/prerender/prerender_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/cloud_print/test/cloud_print_proxy_process_browsertest.cc',
'browser/printing/printing_layout_browsertest.cc', 'browser/printing/printing_layout_browsertest.cc',
'browser/printing/print_preview_tab_controller_browsertest.cc', 'browser/printing/print_preview_tab_controller_browsertest.cc',
...@@ -3079,6 +3080,7 @@ ...@@ -3079,6 +3080,7 @@
], ],
'sources!': [ 'sources!': [
'browser/notifications/desktop_notifications_unittest.cc', '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/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc',
'browser/service/service_process_control_browsertest.cc', 'browser/service/service_process_control_browsertest.cc',
# chromeos does not use cross-platform panels # chromeos does not use cross-platform panels
...@@ -3228,6 +3230,9 @@ ...@@ -3228,6 +3230,9 @@
'browser/spellchecker/spellcheck_host_browsertest.cc', 'browser/spellchecker/spellcheck_host_browsertest.cc',
# ProcessSingletonMac doesn't do anything. # ProcessSingletonMac doesn't do anything.
'browser/process_singleton_browsertest.cc', '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', { ['os_posix == 0 or chromeos == 1', {
......
// 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -68,6 +68,10 @@ enum ResultCode { ...@@ -68,6 +68,10 @@ enum ResultCode {
// Failed to silently uninstall an extension. // Failed to silently uninstall an extension.
RESULT_CODE_UNINSTALL_EXTENSION_ERROR, 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). // Last return code (keep this last).
RESULT_CODE_CHROME_LAST_CODE, RESULT_CODE_CHROME_LAST_CODE,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment