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

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 2712883005: Sign out profile when local_state file has been changed. (Closed)
Patch Set: Merge from master Created 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/profiles/profile_manager.h" 5 #include "chrome/browser/profiles/profile_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "chrome/browser/profiles/profile_destroyer.h" 44 #include "chrome/browser/profiles/profile_destroyer.h"
45 #include "chrome/browser/profiles/profile_info_cache.h" 45 #include "chrome/browser/profiles/profile_info_cache.h"
46 #include "chrome/browser/profiles/profile_metrics.h" 46 #include "chrome/browser/profiles/profile_metrics.h"
47 #include "chrome/browser/profiles/profiles_state.h" 47 #include "chrome/browser/profiles/profiles_state.h"
48 #include "chrome/browser/sessions/session_service_factory.h" 48 #include "chrome/browser/sessions/session_service_factory.h"
49 #include "chrome/browser/signin/account_fetcher_service_factory.h" 49 #include "chrome/browser/signin/account_fetcher_service_factory.h"
50 #include "chrome/browser/signin/account_reconcilor_factory.h" 50 #include "chrome/browser/signin/account_reconcilor_factory.h"
51 #include "chrome/browser/signin/account_tracker_service_factory.h" 51 #include "chrome/browser/signin/account_tracker_service_factory.h"
52 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" 52 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
53 #include "chrome/browser/signin/signin_manager_factory.h" 53 #include "chrome/browser/signin/signin_manager_factory.h"
54 #include "chrome/browser/signin/signin_util.h"
54 #include "chrome/browser/sync/profile_sync_service_factory.h" 55 #include "chrome/browser/sync/profile_sync_service_factory.h"
55 #include "chrome/browser/ui/browser.h" 56 #include "chrome/browser/ui/browser.h"
56 #include "chrome/browser/ui/browser_finder.h" 57 #include "chrome/browser/ui/browser_finder.h"
57 #include "chrome/browser/ui/browser_list.h" 58 #include "chrome/browser/ui/browser_list.h"
58 #include "chrome/browser/ui/sync/sync_promo_ui.h" 59 #include "chrome/browser/ui/sync/sync_promo_ui.h"
59 #include "chrome/common/chrome_constants.h" 60 #include "chrome/common/chrome_constants.h"
60 #include "chrome/common/chrome_paths_internal.h" 61 #include "chrome/common/chrome_paths_internal.h"
61 #include "chrome/common/chrome_switches.h" 62 #include "chrome/common/chrome_switches.h"
62 #include "chrome/common/features.h" 63 #include "chrome/common/features.h"
63 #include "chrome/common/logging_chrome.h" 64 #include "chrome/common/logging_chrome.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 #if !defined(OS_ANDROID) 330 #if !defined(OS_ANDROID)
330 // Helper function for ScheduleForcedEphemeralProfileForDeletion. 331 // Helper function for ScheduleForcedEphemeralProfileForDeletion.
331 bool IsProfileEphemeral(ProfileAttributesStorage* storage, 332 bool IsProfileEphemeral(ProfileAttributesStorage* storage,
332 const base::FilePath& profile_dir) { 333 const base::FilePath& profile_dir) {
333 ProfileAttributesEntry* entry = nullptr; 334 ProfileAttributesEntry* entry = nullptr;
334 return storage->GetProfileAttributesWithPath(profile_dir, &entry) && 335 return storage->GetProfileAttributesWithPath(profile_dir, &entry) &&
335 entry->IsEphemeral(); 336 entry->IsEphemeral();
336 } 337 }
337 #endif 338 #endif
338 339
340 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
341 void SignOut(SigninManager* signin_manager) {
342 signin_manager->SignOut(
343 signin_metrics::AUTHENTICATION_FAILED_WITH_FORCE_SIGNIN,
344 signin_metrics::SignoutDelete::IGNORE_METRIC);
345 }
346 #endif
347
339 } // namespace 348 } // namespace
340 349
341 ProfileManager::ProfileManager(const base::FilePath& user_data_dir) 350 ProfileManager::ProfileManager(const base::FilePath& user_data_dir)
342 : user_data_dir_(user_data_dir), 351 : user_data_dir_(user_data_dir),
343 logged_in_(false), 352 logged_in_(false),
344 #if !defined(OS_ANDROID) 353 #if !defined(OS_ANDROID)
345 browser_list_observer_(this), 354 browser_list_observer_(this),
346 #endif 355 #endif
347 closing_all_browsers_(false) { 356 closing_all_browsers_(false) {
348 #if defined(OS_CHROMEOS) 357 #if defined(OS_CHROMEOS)
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 base::string16 username = base::UTF8ToUTF16(account_info.email); 1566 base::string16 username = base::UTF8ToUTF16(account_info.email);
1558 1567
1559 ProfileAttributesStorage& storage = GetProfileAttributesStorage(); 1568 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
1560 // |entry| and |has_entry| below are put inside a pair of brackets for 1569 // |entry| and |has_entry| below are put inside a pair of brackets for
1561 // scoping, to avoid potential clashes of variable names. 1570 // scoping, to avoid potential clashes of variable names.
1562 { 1571 {
1563 ProfileAttributesEntry* entry; 1572 ProfileAttributesEntry* entry;
1564 bool has_entry = storage.GetProfileAttributesWithPath(profile->GetPath(), 1573 bool has_entry = storage.GetProfileAttributesWithPath(profile->GetPath(),
1565 &entry); 1574 &entry);
1566 if (has_entry) { 1575 if (has_entry) {
1576 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
1577 bool was_authenticated_status = entry->IsAuthenticated();
1578 #endif
1567 // The ProfileAttributesStorage's info must match the Signin Manager. 1579 // The ProfileAttributesStorage's info must match the Signin Manager.
1568 entry->SetAuthInfo(account_info.gaia, username); 1580 entry->SetAuthInfo(account_info.gaia, username);
1581 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
1582 // Sign out if force-sign-in policy is enabled and profile is not signed
1583 // in.
1584 if (signin_util::IsForceSigninEnabled() && was_authenticated_status &&
1585 !entry->IsAuthenticated()) {
1586 BrowserThread::PostTask(
1587 BrowserThread::UI, FROM_HERE,
1588 base::Bind(&SignOut, static_cast<SigninManager*>(signin_manager)));
1589 }
1590 #endif
1569 return; 1591 return;
1570 } 1592 }
1571 } 1593 }
1572 1594
1573 // Profile name and avatar are set by InitProfileUserPrefs and stored in the 1595 // Profile name and avatar are set by InitProfileUserPrefs and stored in the
1574 // profile. Use those values to setup the entry in profile attributes storage. 1596 // profile. Use those values to setup the entry in profile attributes storage.
1575 base::string16 profile_name = 1597 base::string16 profile_name =
1576 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName)); 1598 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName));
1577 1599
1578 size_t icon_index = 1600 size_t icon_index =
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 1787
1766 const base::FilePath new_active_profile_dir = 1788 const base::FilePath new_active_profile_dir =
1767 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath(); 1789 found_entry ? found_entry->GetPath() : GenerateNextProfileDirectoryPath();
1768 FinishDeletingProfile(profile_dir, new_active_profile_dir); 1790 FinishDeletingProfile(profile_dir, new_active_profile_dir);
1769 } 1791 }
1770 #endif // !defined(OS_ANDROID) 1792 #endif // !defined(OS_ANDROID)
1771 1793
1772 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1794 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1773 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1795 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1774 } 1796 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.cc ('k') | chrome/browser/signin/chrome_signin_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698