From 743a68cec4b21eb7bfaa27f236f1c7a25b274b7a Mon Sep 17 00:00:00 2001 From: "scottbyer@chromium.org" Date: Thu, 12 Jul 2012 00:26:45 +0000 Subject: Revert 146149 - Don't pass the connector check policy flag along. 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. BUG=134252 TEST=None Review URL: https://chromiumcodereview.appspot.com/10666010 TBR=scottbyer@chromium.org Review URL: https://chromiumcodereview.appspot.com/10703157 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146248 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/chrome_browser_main.cc | 15 ++--- .../test/cloud_print_policy_browsertest.cc | 77 ---------------------- chrome/chrome_tests.gypi | 4 -- chrome/common/chrome_result_codes.h | 6 +- 4 files changed, 5 insertions(+), 97 deletions(-) delete mode 100644 chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 915be8e..6f4e57c 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -1555,22 +1555,13 @@ 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. - pass_command_line = !HasImportSwitch(parsed_command_line()); + if (!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 @@ -1587,7 +1578,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); #endif - return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; + return content::RESULT_CODE_NORMAL_EXIT; case ProcessSingleton::PROFILE_IN_USE: return chrome::RESULT_CODE_PROFILE_IN_USE; @@ -1603,7 +1594,9 @@ 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 deleted file mode 100644 index fb6a3dd..0000000 --- a/chrome/browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc +++ /dev/null @@ -1,77 +0,0 @@ -// 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); - - ui_test_utils::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_ms()); - - 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_ms()); - - 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 0fa1c5b..f118bb6 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2866,7 +2866,6 @@ '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', @@ -3298,9 +3297,6 @@ '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 8d9077a..79886a878 100644 --- a/chrome/common/chrome_result_codes.h +++ b/chrome/common/chrome_result_codes.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,10 +68,6 @@ 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, }; -- cgit v1.1