Chromium Code Reviews| Index: chrome/browser/chrome_browser_main.cc |
| diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc |
| index 97de7c0c1f46bc0231da17fcf72d7a6ee4554932..c4c5b75c9c0ea103f12d0b8c72583133d51ee07d 100644 |
| --- a/chrome/browser/chrome_browser_main.cc |
| +++ b/chrome/browser/chrome_browser_main.cc |
| @@ -31,6 +31,7 @@ |
| #include "chrome/browser/about_flags.h" |
| #include "chrome/browser/auto_launch_trial.h" |
| #include "chrome/browser/autocomplete/autocomplete_field_trial.h" |
| +#include "chrome/browser/browser_process.h" |
| #include "chrome/browser/browser_process_impl.h" |
| #include "chrome/browser/browser_shutdown.h" |
| #include "chrome/browser/chrome_browser_main_extra_parts.h" |
| @@ -538,6 +539,52 @@ void AddPreReadHistogramTime(const char* name, base::TimeDelta time) { |
| counter->AddTime(time); |
| } |
| +bool ProcessSingletonNotificationCallback(const CommandLine& command_line, |
| + const FilePath& current_directory) { |
| + // Drop the request if the browser process is already in shutdown path. |
| + if (!g_browser_process || g_browser_process->IsShuttingDown()) |
| + return false; |
| + |
| + PrefService* prefs = g_browser_process->local_state(); |
|
jam
2012/04/04 00:44:44
nit: this isn't used
erikwright (departed)
2012/04/04 02:51:48
This is migrated here from process_singleton_linux
erikwright (departed)
2012/04/04 14:51:28
Actually, it was in both the linux and windows ver
|
| + DCHECK(prefs); |
| + |
| + // Handle the --uninstall-extension startup action. This needs to done here |
| + // in the process that is running with the target profile, otherwise the |
| + // uninstall will fail to unload and remove all components. |
| + if (command_line.HasSwitch(switches::kUninstallExtension)) { |
| + // The uninstall extension switch can't be combined with the profile |
| + // directory switch. |
| + DCHECK(!command_line.HasSwitch(switches::kProfileDirectory)); |
| + |
| + Profile* profile = ProfileManager::GetLastUsedProfile(); |
| + if (!profile) { |
| + // We should only be able to get here if the profile already exists and |
| + // has been created. |
|
robertshield
2012/04/04 01:07:15
I'm curious about this comment: does the profile a
erikwright (departed)
2012/04/04 02:51:48
This comment may be misleading. I believe "here" r
|
| + NOTREACHED(); |
| + return true; |
| + } |
| + |
| + ExtensionsStartupUtil ext_startup_util; |
| + ext_startup_util.UninstallExtension(command_line, profile); |
| + return true; |
| + } |
| + |
| + // Ignore the request if the process was passed the --product-version flag. |
| + // Normally we wouldn't get here if that flag had been passed, but it can |
| + // happen if it is passed to an older version of chrome. Since newer versions |
| + // of chrome do this in the background, we want to avoid spawning extra |
| + // windows. |
| + if (command_line.HasSwitch(switches::kProductVersion)) { |
| + DLOG(WARNING) << "Remote process was passed product version flag, " |
| + << "but ignored it. Doing nothing."; |
| + return true; |
| + } |
| + |
| + BrowserInit::ProcessCommandLineAlreadyRunning( |
| + command_line, current_directory); |
| + return true; |
| +} |
| + |
| } // namespace |
| namespace chrome_browser { |
| @@ -1465,7 +1512,8 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
| // 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 |
| // to read the profile. |
| - notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); |
| + notify_result_ = process_singleton_->NotifyOtherProcessOrCreate( |
| + base::Bind(&ProcessSingletonNotificationCallback)); |
| switch (notify_result_) { |
| case ProcessSingleton::PROCESS_NONE: |
| // No process already running, fall through to starting a new one. |