Commit 1805c4c5 authored by noms's avatar noms Committed by Commit bot

Unload the ScopedGaiaAuthExtension asynchronously.

If we don't do this, then we have a race condition between unloading
this extension, and trying to use it because we have manually
navigated to it.

BUG=460431

Review URL: https://codereview.chromium.org/961443003

Cr-Commit-Position: refs/heads/master@{#318140}
parent ed2b7441
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
#include "chrome/browser/extensions/signin/scoped_gaia_auth_extension.h" #include "chrome/browser/extensions/signin/scoped_gaia_auth_extension.h"
#include "base/bind.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
...@@ -19,6 +23,15 @@ ScopedGaiaAuthExtension::ScopedGaiaAuthExtension( ...@@ -19,6 +23,15 @@ ScopedGaiaAuthExtension::ScopedGaiaAuthExtension(
ScopedGaiaAuthExtension::~ScopedGaiaAuthExtension() { ScopedGaiaAuthExtension::~ScopedGaiaAuthExtension() {
extensions::GaiaAuthExtensionLoader* loader = extensions::GaiaAuthExtensionLoader* loader =
extensions::GaiaAuthExtensionLoader::Get(browser_context_); extensions::GaiaAuthExtensionLoader::Get(browser_context_);
if (loader) if (loader) {
loader->UnloadIfNeeded(); // Post this instead of calling it directly, to ensure that the
// RenderFrameHost is not used after being destroyed. This would happen,
// for example, if we tried to manually navigate to the extension while
// the <webview> containing the Gaia sign in page (and therefore the
// extension) was the active tab. See crbug.com/460431.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&extensions::GaiaAuthExtensionLoader::UnloadIfNeeded,
base::Unretained(loader)));
}
} }
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