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

Side by Side Diff: chrome/browser/ui/webui/signin/user_manager_screen_handler.cc

Issue 856733004: Loading the Launcher with a Locked Profile launched UserManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move ProfileLocked check. Add unit test. Created 5 years, 11 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 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/ui/webui/signin/user_manager_screen_handler.h" 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/value_conversions.h" 10 #include "base/value_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap i.h" 14 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap i.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 16 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
17 #include "chrome/browser/profiles/profile_info_cache.h" 17 #include "chrome/browser/profiles/profile_info_cache.h"
18 #include "chrome/browser/profiles/profile_info_cache_observer.h" 18 #include "chrome/browser/profiles/profile_info_cache_observer.h"
19 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/profiles/profile_metrics.h" 20 #include "chrome/browser/profiles/profile_metrics.h"
21 #include "chrome/browser/profiles/profile_window.h" 21 #include "chrome/browser/profiles/profile_window.h"
22 #include "chrome/browser/profiles/profiles_state.h" 22 #include "chrome/browser/profiles/profiles_state.h"
23 #include "chrome/browser/signin/local_auth.h" 23 #include "chrome/browser/signin/local_auth.h"
24 #include "chrome/browser/ui/app_list/app_list_service.h"
24 #include "chrome/browser/ui/browser_commands.h" 25 #include "chrome/browser/ui/browser_commands.h"
25 #include "chrome/browser/ui/browser_dialogs.h" 26 #include "chrome/browser/ui/browser_dialogs.h"
26 #include "chrome/browser/ui/browser_finder.h" 27 #include "chrome/browser/ui/browser_finder.h"
27 #include "chrome/browser/ui/browser_list.h" 28 #include "chrome/browser/ui/browser_list.h"
28 #include "chrome/browser/ui/chrome_pages.h" 29 #include "chrome/browser/ui/chrome_pages.h"
29 #include "chrome/browser/ui/singleton_tabs.h" 30 #include "chrome/browser/ui/singleton_tabs.h"
30 #include "chrome/browser/ui/user_manager.h" 31 #include "chrome/browser/ui/user_manager.h"
31 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
32 #include "chrome/common/url_constants.h" 33 #include "chrome/common/url_constants.h"
33 #include "chrome/grit/chromium_strings.h" 34 #include "chrome/grit/chromium_strings.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 DCHECK(service); 142 DCHECK(service);
142 return service->GetBoolean(prefs::kBrowserGuestModeEnabled); 143 return service->GetBoolean(prefs::kBrowserGuestModeEnabled);
143 } 144 }
144 145
145 bool IsAddPersonEnabled() { 146 bool IsAddPersonEnabled() {
146 PrefService* service = g_browser_process->local_state(); 147 PrefService* service = g_browser_process->local_state();
147 DCHECK(service); 148 DCHECK(service);
148 return service->GetBoolean(prefs::kBrowserAddPersonEnabled); 149 return service->GetBoolean(prefs::kBrowserAddPersonEnabled);
149 } 150 }
150 151
152 void ShowAppList(Browser* browser, chrome::HostDesktopType desktop_type) {
153 AppListService* app_list_service = AppListService::Get(desktop_type);
154 app_list_service->ShowForProfile(browser->profile());
155 }
156
151 } // namespace 157 } // namespace
152 158
153 // ProfileUpdateObserver ------------------------------------------------------ 159 // ProfileUpdateObserver ------------------------------------------------------
154 160
155 class UserManagerScreenHandler::ProfileUpdateObserver 161 class UserManagerScreenHandler::ProfileUpdateObserver
156 : public ProfileInfoCacheObserver { 162 : public ProfileInfoCacheObserver {
157 public: 163 public:
158 ProfileUpdateObserver( 164 ProfileUpdateObserver(
159 ProfileManager* profile_manager, UserManagerScreenHandler* handler) 165 ProfileManager* profile_manager, UserManagerScreenHandler* handler)
160 : profile_manager_(profile_manager), 166 : profile_manager_(profile_manager),
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 FROM_HERE, base::Bind(&chrome::OpenTaskManager, browser)); 729 FROM_HERE, base::Bind(&chrome::OpenTaskManager, browser));
724 } else if (url_hash_ == profiles::kUserManagerSelectProfileAboutChrome) { 730 } else if (url_hash_ == profiles::kUserManagerSelectProfileAboutChrome) {
725 base::MessageLoop::current()->PostTask( 731 base::MessageLoop::current()->PostTask(
726 FROM_HERE, base::Bind(&chrome::ShowAboutChrome, browser)); 732 FROM_HERE, base::Bind(&chrome::ShowAboutChrome, browser));
727 } else if (url_hash_ == profiles::kUserManagerSelectProfileChromeSettings) { 733 } else if (url_hash_ == profiles::kUserManagerSelectProfileChromeSettings) {
728 base::MessageLoop::current()->PostTask( 734 base::MessageLoop::current()->PostTask(
729 FROM_HERE, base::Bind(&chrome::ShowSettings, browser)); 735 FROM_HERE, base::Bind(&chrome::ShowSettings, browser));
730 } else if (url_hash_ == profiles::kUserManagerSelectProfileChromeMemory) { 736 } else if (url_hash_ == profiles::kUserManagerSelectProfileChromeMemory) {
731 base::MessageLoop::current()->PostTask( 737 base::MessageLoop::current()->PostTask(
732 FROM_HERE, base::Bind(&chrome::ShowMemory, browser)); 738 FROM_HERE, base::Bind(&chrome::ShowMemory, browser));
739 } else if (url_hash_ == profiles::kUserManagerSelectProfileAppLauncher) {
740 base::MessageLoop::current()->PostTask(
741 FROM_HERE, base::Bind(&ShowAppList, browser, desktop_type_));
sky 2015/01/22 18:26:15 How do you know browser is still valid by the time
Mike Lerman 2015/01/23 16:58:33 It just got created and there's nothing that shoul
sky 2015/01/23 17:55:04 Yes, the object just got got created (object being
Mike Lerman 2015/01/23 18:21:03 For the Profile, we should be safe, since the Prof
733 } 742 }
734 743
735 // This call is last as it deletes this object. 744 // This call is last as it deletes this object.
736 UserManager::Hide(); 745 UserManager::Hide();
737 } 746 }
738 747
739 void UserManagerScreenHandler::Observe( 748 void UserManagerScreenHandler::Observe(
740 int type, 749 int type,
741 const content::NotificationSource& source, 750 const content::NotificationSource& source,
742 const content::NotificationDetails& details) { 751 const content::NotificationDetails& details) {
(...skipping 19 matching lines...) Expand all
762 Profile* profile, Profile::CreateStatus profile_create_status) { 771 Profile* profile, Profile::CreateStatus profile_create_status) {
763 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); 772 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_);
764 if (browser && browser->window()) { 773 if (browser && browser->window()) {
765 OnBrowserWindowReady(browser); 774 OnBrowserWindowReady(browser);
766 } else { 775 } else {
767 registrar_.Add(this, 776 registrar_.Add(this,
768 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 777 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
769 content::NotificationService::AllSources()); 778 content::NotificationService::AllSources());
770 } 779 }
771 } 780 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698