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

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: fixup 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/cross_device_promo.h" 52 #include "chrome/browser/signin/cross_device_promo.h"
53 #include "chrome/browser/signin/cross_device_promo_factory.h" 53 #include "chrome/browser/signin/cross_device_promo_factory.h"
54 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" 54 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
55 #include "chrome/browser/signin/signin_manager_factory.h" 55 #include "chrome/browser/signin/signin_manager_factory.h"
56 #include "chrome/browser/signin/signin_util.h"
56 #include "chrome/browser/sync/profile_sync_service_factory.h" 57 #include "chrome/browser/sync/profile_sync_service_factory.h"
57 #include "chrome/browser/ui/browser.h" 58 #include "chrome/browser/ui/browser.h"
58 #include "chrome/browser/ui/browser_list.h" 59 #include "chrome/browser/ui/browser_list.h"
59 #include "chrome/browser/ui/sync/sync_promo_ui.h" 60 #include "chrome/browser/ui/sync/sync_promo_ui.h"
60 #include "chrome/common/chrome_constants.h" 61 #include "chrome/common/chrome_constants.h"
61 #include "chrome/common/chrome_paths_internal.h" 62 #include "chrome/common/chrome_paths_internal.h"
62 #include "chrome/common/chrome_switches.h" 63 #include "chrome/common/chrome_switches.h"
63 #include "chrome/common/features.h" 64 #include "chrome/common/features.h"
64 #include "chrome/common/logging_chrome.h" 65 #include "chrome/common/logging_chrome.h"
65 #include "chrome/common/pref_names.h" 66 #include "chrome/common/pref_names.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 317 }
317 if (status != Profile::CREATE_STATUS_INITIALIZED) { 318 if (status != Profile::CREATE_STATUS_INITIALIZED) {
318 LOG(WARNING) << "Profile not loaded correctly"; 319 LOG(WARNING) << "Profile not loaded correctly";
319 client_callback.Run(nullptr); 320 client_callback.Run(nullptr);
320 return; 321 return;
321 } 322 }
322 DCHECK(profile); 323 DCHECK(profile);
323 client_callback.Run(incognito ? profile->GetOffTheRecordProfile() : profile); 324 client_callback.Run(incognito ? profile->GetOffTheRecordProfile() : profile);
324 } 325 }
325 326
327 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
328 void SignOut(SigninManager* signin_manager) {
329 signin_manager->SignOut(signin_metrics::AUTHENTICATION_FAILED,
330 signin_metrics::SignoutDelete::IGNORE_METRIC);
331 }
332 #endif
333
326 } // namespace 334 } // namespace
327 335
328 ProfileManager::ProfileManager(const base::FilePath& user_data_dir) 336 ProfileManager::ProfileManager(const base::FilePath& user_data_dir)
329 : user_data_dir_(user_data_dir), 337 : user_data_dir_(user_data_dir),
330 logged_in_(false), 338 logged_in_(false),
331 #if !defined(OS_ANDROID) 339 #if !defined(OS_ANDROID)
332 browser_list_observer_(this), 340 browser_list_observer_(this),
333 #endif 341 #endif
334 closing_all_browsers_(false) { 342 closing_all_browsers_(false) {
335 #if defined(OS_CHROMEOS) 343 #if defined(OS_CHROMEOS)
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 base::string16 username = base::UTF8ToUTF16(account_info.email); 1548 base::string16 username = base::UTF8ToUTF16(account_info.email);
1541 1549
1542 ProfileAttributesStorage& storage = GetProfileAttributesStorage(); 1550 ProfileAttributesStorage& storage = GetProfileAttributesStorage();
1543 // |entry| and |has_entry| below are put inside a pair of brackets for 1551 // |entry| and |has_entry| below are put inside a pair of brackets for
1544 // scoping, to avoid potential clashes of variable names. 1552 // scoping, to avoid potential clashes of variable names.
1545 { 1553 {
1546 ProfileAttributesEntry* entry; 1554 ProfileAttributesEntry* entry;
1547 bool has_entry = storage.GetProfileAttributesWithPath(profile->GetPath(), 1555 bool has_entry = storage.GetProfileAttributesWithPath(profile->GetPath(),
1548 &entry); 1556 &entry);
1549 if (has_entry) { 1557 if (has_entry) {
1558 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
1559 bool previous_authenticated_status = entry->IsAuthenticated();
Roger Tawa OOO till Jul 10th 2017/02/27 22:08:26 nit: rename |previous_authenticated_status| to |wa
zmin 2017/03/07 20:06:41 Done.
1560 #endif
1550 // The ProfileAttributesStorage's info must match the Signin Manager. 1561 // The ProfileAttributesStorage's info must match the Signin Manager.
1551 entry->SetAuthInfo(account_info.gaia, username); 1562 entry->SetAuthInfo(account_info.gaia, username);
1563 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
1564 // Sign out if force-sign-in policy is enabled and profile is not signed
1565 // in.
1566 if (signin_util::IsForceSigninEnabled() &&
1567 previous_authenticated_status && !entry->IsAuthenticated()) {
1568 BrowserThread::PostTask(
1569 BrowserThread::UI, FROM_HERE,
1570 base::Bind(&SignOut, static_cast<SigninManager*>(signin_manager)));
1571 }
1572 #endif
1552 return; 1573 return;
1553 } 1574 }
1554 } 1575 }
1555 1576
1556 // Profile name and avatar are set by InitProfileUserPrefs and stored in the 1577 // Profile name and avatar are set by InitProfileUserPrefs and stored in the
1557 // profile. Use those values to setup the entry in profile attributes storage. 1578 // profile. Use those values to setup the entry in profile attributes storage.
1558 base::string16 profile_name = 1579 base::string16 profile_name =
1559 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName)); 1580 base::UTF8ToUTF16(profile->GetPrefs()->GetString(prefs::kProfileName));
1560 1581
1561 size_t icon_index = 1582 size_t icon_index =
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 1745
1725 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); 1746 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path);
1726 if (!original_callback.is_null()) 1747 if (!original_callback.is_null())
1727 original_callback.Run(loaded_profile, status); 1748 original_callback.Run(loaded_profile, status);
1728 } 1749 }
1729 #endif // !defined(OS_ANDROID) 1750 #endif // !defined(OS_ANDROID)
1730 1751
1731 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1752 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1732 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1753 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1733 } 1754 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698