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/bind.h" | |
8 #include "base/location.h" | |
9 #include "base/single_thread_task_runner.h" | |
10 #include "base/thread_task_runner_handle.h" | |
7 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" | 11 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" |
8 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
9 | 13 |
10 ScopedGaiaAuthExtension::ScopedGaiaAuthExtension( | 14 ScopedGaiaAuthExtension::ScopedGaiaAuthExtension( |
11 content::BrowserContext* context) | 15 content::BrowserContext* context) |
12 : browser_context_(context) { | 16 : browser_context_(context) { |
13 extensions::GaiaAuthExtensionLoader* loader = | 17 extensions::GaiaAuthExtensionLoader* loader = |
14 extensions::GaiaAuthExtensionLoader::Get(browser_context_); | 18 extensions::GaiaAuthExtensionLoader::Get(browser_context_); |
15 if (loader) | 19 if (loader) |
16 loader->LoadIfNeeded(); | 20 loader->LoadIfNeeded(); |
17 } | 21 } |
18 | 22 |
19 ScopedGaiaAuthExtension::~ScopedGaiaAuthExtension() { | 23 ScopedGaiaAuthExtension::~ScopedGaiaAuthExtension() { |
20 extensions::GaiaAuthExtensionLoader* loader = | 24 extensions::GaiaAuthExtensionLoader* loader = |
21 extensions::GaiaAuthExtensionLoader::Get(browser_context_); | 25 extensions::GaiaAuthExtensionLoader::Get(browser_context_); |
22 if (loader) | 26 if (loader) { |
23 loader->UnloadIfNeeded(); | 27 // Post this instead of calling it directly, to ensure that the |
28 // RenderFrameHost is not used after being destroyed. This would happen, | |
29 // for example, if we tried to manually navigate to the extension while | |
30 // the <webview> containing the Gaia sign in page (and therefore the | |
31 // extension) was the active tab. See crbug.com/460431. | |
32 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
33 FROM_HERE, | |
34 base::Bind(&extensions::GaiaAuthExtensionLoader::UnloadIfNeeded, | |
35 base::Unretained(loader))); | |
Alexei Svitkine (slow)
2015/03/05 16:11:38
Why is it safe to use base::Unretained() here?
Wh
noms (inactive)
2015/03/16 15:57:42
Done.
| |
36 } | |
24 } | 37 } |
OLD | NEW |