Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: chrome/browser/chromeos/profiles/profile_helper.cc

Issue 1012083002: Resolve new GAIA flow's infinite loop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clear storage partition in ProfileHelper::ClearSigninProfile. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/chromeos/profiles/profile_helper.h" 5 #include "chrome/browser/chromeos/profiles/profile_helper.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/browsing_data/browsing_data_helper.h" 10 #include "chrome/browser/browsing_data/browsing_data_helper.h"
11 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" 11 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/profiles/profiles_state.h" 14 #include "chrome/browser/profiles/profiles_state.h"
15 #include "chrome/common/chrome_constants.h" 15 #include "chrome/common/chrome_constants.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chromeos/chromeos_switches.h" 17 #include "chromeos/chromeos_switches.h"
18 #include "components/user_manager/user.h" 18 #include "components/user_manager/user.h"
19 #include "components/user_manager/user_manager.h" 19 #include "components/user_manager/user_manager.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/storage_partition.h"
22 #include "content/public/browser/web_contents.h"
23 #include "extensions/browser/guest_view/guest_view_base.h"
24 #include "extensions/browser/guest_view/guest_view_manager.h"
25 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
21 26
22 namespace chromeos { 27 namespace chromeos {
23 28
24 namespace { 29 namespace {
25 30
26 // As defined in /chromeos/dbus/cryptohome_client.cc. 31 // As defined in /chromeos/dbus/cryptohome_client.cc.
27 static const char kUserIdHashSuffix[] = "-hash"; 32 static const char kUserIdHashSuffix[] = "-hash";
28 33
29 bool ShouldAddProfileDirPrefix(const std::string& user_id_hash) { 34 bool ShouldAddProfileDirPrefix(const std::string& user_id_hash) {
30 // Do not add profile dir prefix for legacy profile dir and test 35 // Do not add profile dir prefix for legacy profile dir and test
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 195 }
191 196
192 base::FilePath ProfileHelper::GetActiveUserProfileDir() { 197 base::FilePath ProfileHelper::GetActiveUserProfileDir() {
193 return ProfileHelper::GetUserProfileDir(active_user_id_hash_); 198 return ProfileHelper::GetUserProfileDir(active_user_id_hash_);
194 } 199 }
195 200
196 void ProfileHelper::Initialize() { 201 void ProfileHelper::Initialize() {
197 user_manager::UserManager::Get()->AddSessionStateObserver(this); 202 user_manager::UserManager::Get()->AddSessionStateObserver(this);
198 } 203 }
199 204
200 void ProfileHelper::ClearSigninProfile(const base::Closure& on_clear_callback) { 205 static bool ClearWebViewData(const base::Closure& on_clear_callback,
201 on_clear_callbacks_.push_back(on_clear_callback); 206 content::WebContents* web_contents) {
207 extensions::GuestViewBase* guest_view =
208 extensions::GuestViewBase::FromWebContents(web_contents);
209 if (guest_view->GetViewType() == extensions::WebViewGuest::Type) {
Fady Samuel 2015/03/19 11:15:56 This is unnecessarily complex. All of this can be
Ivan Podogov 2015/03/19 11:56:32 This won't work: the WebContents that is passed he
Fady Samuel 2015/03/19 12:14:30 I'm confused. GuestViewBase::FromWebContents does
Ivan Podogov 2015/03/19 12:18:43 Ah, I thought you were talking about replacing the
Ivan Podogov 2015/03/19 12:29:21 Done.
210 extensions::WebViewGuest* view_guest =
211 static_cast<extensions::WebViewGuest*>(guest_view);
212 view_guest->ClearData(base::Time(),
213 content::StoragePartition::REMOVE_DATA_MASK_ALL,
214 on_clear_callback);
215 return true;
216 }
217 return false;
218 }
219
220 static void ClearContentsData(content::WebContents* web_contents,
221 const base::Closure& on_clear_callback) {
222 content::BrowserContext* context = web_contents->GetBrowserContext();
223 extensions::GuestViewManager* manager =
224 extensions::GuestViewManager::FromBrowserContext(context);
225 if (!manager->ForEachGuest(
226 web_contents, base::Bind(&ClearWebViewData, on_clear_callback))) {
227 on_clear_callback.Run();
228 }
229 }
230
231 void ProfileHelper::ClearSigninProfile(const base::Closure& on_clear_callback,
232 content::WebContents* webview_contents) {
233 on_clear_callbacks_.push_back(
234 webview_contents
235 ? base::Bind(&ClearContentsData, webview_contents, on_clear_callback)
236 : on_clear_callback);
202 if (signin_profile_clear_requested_) 237 if (signin_profile_clear_requested_)
203 return; 238 return;
204 ProfileManager* profile_manager = g_browser_process->profile_manager(); 239 ProfileManager* profile_manager = g_browser_process->profile_manager();
205 // Check if signin profile was loaded. 240 // Check if signin profile was loaded.
206 if (!profile_manager->GetProfileByPath(GetSigninProfileDir())) { 241 if (!profile_manager->GetProfileByPath(GetSigninProfileDir())) {
207 OnBrowsingDataRemoverDone(); 242 OnBrowsingDataRemoverDone();
208 return; 243 return;
209 } 244 }
210 signin_profile_clear_requested_ = true; 245 signin_profile_clear_requested_ = true;
211 BrowsingDataRemover* remover = 246 BrowsingDataRemover* remover =
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 void ProfileHelper::OnSessionRestoreStateChanged( 378 void ProfileHelper::OnSessionRestoreStateChanged(
344 Profile* user_profile, 379 Profile* user_profile,
345 OAuth2LoginManager::SessionRestoreState state) { 380 OAuth2LoginManager::SessionRestoreState state) {
346 if (state == OAuth2LoginManager::SESSION_RESTORE_DONE || 381 if (state == OAuth2LoginManager::SESSION_RESTORE_DONE ||
347 state == OAuth2LoginManager::SESSION_RESTORE_FAILED || 382 state == OAuth2LoginManager::SESSION_RESTORE_FAILED ||
348 state == OAuth2LoginManager::SESSION_RESTORE_CONNECTION_FAILED) { 383 state == OAuth2LoginManager::SESSION_RESTORE_CONNECTION_FAILED) {
349 chromeos::OAuth2LoginManager* login_manager = 384 chromeos::OAuth2LoginManager* login_manager =
350 chromeos::OAuth2LoginManagerFactory::GetInstance()-> 385 chromeos::OAuth2LoginManagerFactory::GetInstance()->
351 GetForProfile(user_profile); 386 GetForProfile(user_profile);
352 login_manager->RemoveObserver(this); 387 login_manager->RemoveObserver(this);
353 ClearSigninProfile(base::Closure()); 388 ClearSigninProfile(base::Closure(), nullptr);
354 } 389 }
355 } 390 }
356 391
357 //////////////////////////////////////////////////////////////////////////////// 392 ////////////////////////////////////////////////////////////////////////////////
358 // ProfileHelper, UserManager::UserSessionStateObserver implementation: 393 // ProfileHelper, UserManager::UserSessionStateObserver implementation:
359 394
360 void ProfileHelper::ActiveUserHashChanged(const std::string& hash) { 395 void ProfileHelper::ActiveUserHashChanged(const std::string& hash) {
361 active_user_id_hash_ = hash; 396 active_user_id_hash_ = hash;
362 } 397 }
363 398
(...skipping 19 matching lines...) Expand all
383 user_to_profile_for_testing_[user] = profile; 418 user_to_profile_for_testing_[user] = profile;
384 } 419 }
385 420
386 // static 421 // static
387 std::string ProfileHelper::GetUserIdHashByUserIdForTesting( 422 std::string ProfileHelper::GetUserIdHashByUserIdForTesting(
388 const std::string& user_id) { 423 const std::string& user_id) {
389 return user_id + kUserIdHashSuffix; 424 return user_id + kUserIdHashSuffix;
390 } 425 }
391 426
392 } // namespace chromeos 427 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/profiles/profile_helper.h ('k') | chrome/browser/resources/gaia_auth_host/authenticator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698