Chromium Code Reviews| Index: chrome/browser/chromeos/profiles/profile_helper.cc |
| diff --git a/chrome/browser/chromeos/profiles/profile_helper.cc b/chrome/browser/chromeos/profiles/profile_helper.cc |
| index 7e69cc750886fc814ae7e2e144f78d17462ec4ef..f8df9e4b85bdfc7859930eff5a18f15d7d7e365b 100644 |
| --- a/chrome/browser/chromeos/profiles/profile_helper.cc |
| +++ b/chrome/browser/chromeos/profiles/profile_helper.cc |
| @@ -18,6 +18,10 @@ |
| #include "components/user_manager/user.h" |
| #include "components/user_manager/user_manager.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/storage_partition.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "extensions/browser/guest_view/guest_view_manager.h" |
| +#include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| namespace chromeos { |
| @@ -48,6 +52,28 @@ class UsernameHashMatcher { |
| const std::string& username_hash; |
| }; |
| +bool ClearWebViewData(const base::Closure& on_clear_callback, |
| + content::WebContents* web_contents) { |
| + extensions::WebViewGuest* view_guest = |
| + extensions::WebViewGuest::FromWebContents(web_contents); |
| + if (!view_guest) |
| + return false; |
| + return view_guest->ClearData(base::Time(), |
| + content::StoragePartition::REMOVE_DATA_MASK_ALL, |
| + on_clear_callback); |
| +} |
| + |
| +void ClearContentsData(content::WebContents* web_contents, |
| + const base::Closure& on_clear_callback) { |
| + content::BrowserContext* context = web_contents->GetBrowserContext(); |
| + extensions::GuestViewManager* manager = |
| + extensions::GuestViewManager::FromBrowserContext(context); |
| + if (!manager->ForEachGuest( |
| + web_contents, base::Bind(&ClearWebViewData, on_clear_callback))) { |
|
xiyuan
2015/03/19 16:33:31
This could cause the |on_clear_callback| be called
Ivan Podogov
2015/03/19 16:59:06
In fact, it cannot: ForEachGuest will stop iterati
xiyuan
2015/03/19 18:22:19
You are right about the callback is invoked just o
Ivan Podogov
2015/03/19 18:42:43
It is correct as long as ClearSigninProfile is cal
xiyuan
2015/03/19 19:49:28
It will not be correct when we add webviews for en
|
| + on_clear_callback.Run(); |
| + } |
| +} |
| + |
| } // anonymous namespace |
| // static |
| @@ -197,8 +223,12 @@ void ProfileHelper::Initialize() { |
| user_manager::UserManager::Get()->AddSessionStateObserver(this); |
| } |
| -void ProfileHelper::ClearSigninProfile(const base::Closure& on_clear_callback) { |
| - on_clear_callbacks_.push_back(on_clear_callback); |
| +void ProfileHelper::ClearSigninProfile(const base::Closure& on_clear_callback, |
| + content::WebContents* webview_contents) { |
| + on_clear_callbacks_.push_back( |
| + webview_contents |
| + ? base::Bind(&ClearContentsData, webview_contents, on_clear_callback) |
| + : on_clear_callback); |
| if (signin_profile_clear_requested_) |
| return; |
| ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| @@ -350,7 +380,7 @@ void ProfileHelper::OnSessionRestoreStateChanged( |
| chromeos::OAuth2LoginManagerFactory::GetInstance()-> |
| GetForProfile(user_profile); |
| login_manager->RemoveObserver(this); |
| - ClearSigninProfile(base::Closure()); |
| + ClearSigninProfile(base::Closure(), nullptr); |
|
xiyuan
2015/03/19 16:33:31
Could you double check whether passing nullptr is
Ivan Podogov
2015/03/19 16:59:06
I'm afraid that I see no easy way to do it: it wou
xiyuan
2015/03/19 18:22:19
I was asking to verify this is only called on brow
|
| } |
| } |