diff options
author | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 00:13:25 +0000 |
---|---|---|
committer | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 00:13:25 +0000 |
commit | 5832ff87058de4a6eec25fd2abb183134e834124 (patch) | |
tree | 3966720a33620d9346b828145ddf4447f8e8c3f8 /chrome/service | |
parent | ff8b37511ce0a3a07e416ab5ee8842fdcaa04dfe (diff) | |
download | chromium_src-5832ff87058de4a6eec25fd2abb183134e834124.zip chromium_src-5832ff87058de4a6eec25fd2abb183134e834124.tar.gz chromium_src-5832ff87058de4a6eec25fd2abb183134e834124.tar.bz2 |
Added code to restart the service process in the event of a crash.
BUG=None.
TEST=A crash in the cloud print proxy should prompt the user for a restart.
Review URL: http://codereview.chromium.org/6474030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service')
-rw-r--r-- | chrome/service/service_process.cc | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc index be3e48e..f490fb5 100644 --- a/chrome/service/service_process.cc +++ b/chrome/service/service_process.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 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. @@ -8,6 +8,8 @@ #include "base/basictypes.h" #include "base/command_line.h" +#include "base/environment.h" +#include "base/i18n/rtl.h" #include "base/path_service.h" #include "base/singleton.h" #include "base/string16.h" @@ -16,13 +18,17 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/env_vars.h" #include "chrome/common/net/url_fetcher.h" #include "chrome/common/pref_names.h" #include "chrome/common/service_process_util.h" #include "chrome/service/cloud_print/cloud_print_proxy.h" #include "chrome/service/service_ipc_server.h" #include "chrome/service/service_process_prefs.h" +#include "grit/chromium_strings.h" +#include "grit/generated_resources.h" #include "net/base/network_change_notifier.h" +#include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_switches.h" @@ -63,6 +69,41 @@ void ServiceIOThread::CleanUp() { URLFetcher::CancelAll(); } +// Prepares the localized strings that are going to be displayed to +// the user if the service process dies. These strings are stored in the +// environment block so they are accessible in the early stages of the +// chrome executable's lifetime. +void PrepareRestartOnCrashEnviroment( + const CommandLine &parsed_command_line) { + scoped_ptr<base::Environment> env(base::Environment::Create()); + // Clear this var so child processes don't show the dialog by default. + env->UnSetVar(env_vars::kShowRestart); + + // For non-interactive tests we don't restart on crash. + if (env->HasVar(env_vars::kHeadless)) + return; + + // If the known command-line test options are used we don't create the + // environment block which means we don't get the restart dialog. + if (parsed_command_line.HasSwitch(switches::kNoErrorDialogs)) + return; + + // The encoding we use for the info is "title|context|direction" where + // direction is either env_vars::kRtlLocale or env_vars::kLtrLocale depending + // on the current locale. + string16 dlg_strings(l10n_util::GetStringUTF16(IDS_CRASH_RECOVERY_TITLE)); + dlg_strings.push_back('|'); + string16 adjusted_string( + l10n_util::GetStringUTF16(IDS_SERVICE_CRASH_RECOVERY_CONTENT)); + base::i18n::AdjustStringForLocaleDirection(&adjusted_string); + dlg_strings.append(adjusted_string); + dlg_strings.push_back('|'); + dlg_strings.append(ASCIIToUTF16( + base::i18n::IsRTL() ? env_vars::kRtlLocale : env_vars::kLtrLocale)); + + env->SetVar(env_vars::kRestartInfo, UTF16ToUTF8(dlg_strings)); +} + } // namespace ServiceProcess::ServiceProcess() @@ -116,6 +157,8 @@ bool ServiceProcess::Initialize(MessageLoop* message_loop, } ResourceBundle::InitSharedInstance(locale); + PrepareRestartOnCrashEnviroment(command_line); + #if defined(ENABLE_REMOTING) // Initialize chromoting host manager. remoting_host_manager_ = new remoting::ChromotingHostManager(this); |