OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/signin/scoped_gaia_auth_extension.h" | 5 #include "chrome/browser/extensions/signin/scoped_gaia_auth_extension.h" |
6 | 6 |
7 #include "base/task_runner.h" | |
7 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" | 8 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" |
8 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
10 #include "content/public/browser/browser_thread.h" | |
9 | 11 |
10 ScopedGaiaAuthExtension::ScopedGaiaAuthExtension( | 12 ScopedGaiaAuthExtension::ScopedGaiaAuthExtension( |
11 content::BrowserContext* context) | 13 content::BrowserContext* context) |
12 : browser_context_(context) { | 14 : browser_context_(context) { |
13 extensions::GaiaAuthExtensionLoader* loader = | 15 extensions::GaiaAuthExtensionLoader* loader = |
14 extensions::GaiaAuthExtensionLoader::Get(browser_context_); | 16 extensions::GaiaAuthExtensionLoader::Get(browser_context_); |
15 if (loader) | 17 if (loader) |
16 loader->LoadIfNeeded(); | 18 loader->LoadIfNeeded(); |
17 } | 19 } |
18 | 20 |
19 ScopedGaiaAuthExtension::~ScopedGaiaAuthExtension() { | 21 ScopedGaiaAuthExtension::~ScopedGaiaAuthExtension() { |
20 extensions::GaiaAuthExtensionLoader* loader = | 22 extensions::GaiaAuthExtensionLoader* loader = |
21 extensions::GaiaAuthExtensionLoader::Get(browser_context_); | 23 extensions::GaiaAuthExtensionLoader::Get(browser_context_); |
22 if (loader) | 24 if (loader) { |
23 loader->UnloadIfNeeded(); | 25 // Post this instead of calling it directly, to ensure that the |
26 // RenderFrameHost is not used after being destroyed. This would happen, | |
27 // for example, if we tried to manually navigate to the extension while | |
28 // the <webview> containing the Gaia sign in page (and therefore the | |
29 // extension) was the active tab. See crbug.com/460431. | |
30 content::BrowserThread::PostTask( | |
xiyuan
2015/02/25 21:17:30
nit: Slightly prefer to use base::ThreadTaskRunner
noms
2015/02/25 22:19:27
Done.
| |
31 content::BrowserThread::UI, FROM_HERE, | |
32 base::Bind(&extensions::GaiaAuthExtensionLoader::UnloadIfNeeded, | |
33 base::Unretained(loader))); | |
34 } | |
24 } | 35 } |
OLD | NEW |