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

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: tapted@: test fixes and remove a const-ref. Created 5 years, 10 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
« no previous file with comments | « chrome/browser/ui/views/app_list/win/app_list_service_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
29 #include "chrome/browser/ui/browser_list_observer.h"
28 #include "chrome/browser/ui/chrome_pages.h" 30 #include "chrome/browser/ui/chrome_pages.h"
29 #include "chrome/browser/ui/singleton_tabs.h" 31 #include "chrome/browser/ui/singleton_tabs.h"
30 #include "chrome/browser/ui/user_manager.h" 32 #include "chrome/browser/ui/user_manager.h"
31 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
32 #include "chrome/common/url_constants.h" 34 #include "chrome/common/url_constants.h"
33 #include "chrome/grit/chromium_strings.h" 35 #include "chrome/grit/chromium_strings.h"
34 #include "chrome/grit/generated_resources.h" 36 #include "chrome/grit/generated_resources.h"
35 #include "content/public/browser/notification_service.h" 37 #include "content/public/browser/notification_service.h"
36 #include "content/public/browser/web_contents.h" 38 #include "content/public/browser/web_contents.h"
37 #include "content/public/browser/web_ui.h" 39 #include "content/public/browser/web_ui.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 DCHECK(service); 138 DCHECK(service);
137 return service->GetBoolean(prefs::kBrowserGuestModeEnabled); 139 return service->GetBoolean(prefs::kBrowserGuestModeEnabled);
138 } 140 }
139 141
140 bool IsAddPersonEnabled() { 142 bool IsAddPersonEnabled() {
141 PrefService* service = g_browser_process->local_state(); 143 PrefService* service = g_browser_process->local_state();
142 DCHECK(service); 144 DCHECK(service);
143 return service->GetBoolean(prefs::kBrowserAddPersonEnabled); 145 return service->GetBoolean(prefs::kBrowserAddPersonEnabled);
144 } 146 }
145 147
148 // Executes the action specified by the URL's Hash parameter, if any. Deletes
149 // itself after the action would be performed.
150 class UrlHashHelper : public chrome::BrowserListObserver {
151 public:
152 UrlHashHelper(Browser* browser, const std::string& hash);
153 ~UrlHashHelper() override;
154
155 void ExecuteUrlHash();
156
157 // chrome::BrowserListObserver overrides:
158 void OnBrowserRemoved(Browser* browser) override;
159
160 private:
161 Browser* browser_;
162 Profile* profile_;
163 chrome::HostDesktopType desktop_type_;
164 std::string hash_;
165
166 DISALLOW_COPY_AND_ASSIGN(UrlHashHelper);
167 };
168
169 UrlHashHelper::UrlHashHelper(Browser* browser, const std::string& hash)
170 : browser_(browser),
171 profile_(browser->profile()),
172 desktop_type_(browser->host_desktop_type()),
173 hash_(hash) {
174 BrowserList::AddObserver(this);
175 }
176
177 UrlHashHelper::~UrlHashHelper() {
178 BrowserList::RemoveObserver(this);
179 }
180
181 void UrlHashHelper::OnBrowserRemoved(Browser* browser) {
182 if (browser == browser_)
183 browser_ = nullptr;
184 }
185
186 void UrlHashHelper::ExecuteUrlHash() {
187 if (hash_ == profiles::kUserManagerSelectProfileAppLauncher) {
188 AppListService* app_list_service = AppListService::Get(desktop_type_);
189 app_list_service->ShowForProfile(profile_);
190 return;
191 }
192
193 Browser* target_browser = browser_;
194 if (!target_browser) {
195 target_browser = chrome::FindLastActiveWithProfile(profile_, desktop_type_);
196 if (!target_browser)
197 return;
198 }
199
200 if (hash_ == profiles::kUserManagerSelectProfileTaskManager)
201 chrome::OpenTaskManager(target_browser);
202 else if (hash_ == profiles::kUserManagerSelectProfileAboutChrome)
203 chrome::ShowAboutChrome(target_browser);
204 else if (hash_ == profiles::kUserManagerSelectProfileChromeSettings)
205 chrome::ShowSettings(target_browser);
206 else if (hash_ == profiles::kUserManagerSelectProfileChromeMemory)
207 chrome::ShowMemory(target_browser);
208 }
209
146 } // namespace 210 } // namespace
147 211
148 // ProfileUpdateObserver ------------------------------------------------------ 212 // ProfileUpdateObserver ------------------------------------------------------
149 213
150 class UserManagerScreenHandler::ProfileUpdateObserver 214 class UserManagerScreenHandler::ProfileUpdateObserver
151 : public ProfileInfoCacheObserver { 215 : public ProfileInfoCacheObserver {
152 public: 216 public:
153 ProfileUpdateObserver( 217 ProfileUpdateObserver(
154 ProfileManager* profile_manager, UserManagerScreenHandler* handler) 218 ProfileManager* profile_manager, UserManagerScreenHandler* handler)
155 : profile_manager_(profile_manager), 219 : profile_manager_(profile_manager),
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 // Unlock the profile after browser opens so startup can read the lock bit. 771 // Unlock the profile after browser opens so startup can read the lock bit.
708 // Any necessary authentication must have been successful to reach this point. 772 // Any necessary authentication must have been successful to reach this point.
709 if (!browser->profile()->IsGuestSession()) { 773 if (!browser->profile()->IsGuestSession()) {
710 ProfileInfoCache& info_cache = 774 ProfileInfoCache& info_cache =
711 g_browser_process->profile_manager()->GetProfileInfoCache(); 775 g_browser_process->profile_manager()->GetProfileInfoCache();
712 size_t index = info_cache.GetIndexOfProfileWithPath( 776 size_t index = info_cache.GetIndexOfProfileWithPath(
713 browser->profile()->GetPath()); 777 browser->profile()->GetPath());
714 info_cache.SetProfileSigninRequiredAtIndex(index, false); 778 info_cache.SetProfileSigninRequiredAtIndex(index, false);
715 } 779 }
716 780
717 if (url_hash_ == profiles::kUserManagerSelectProfileTaskManager) { 781 if (!url_hash_.empty()) {
718 base::MessageLoop::current()->PostTask( 782 base::MessageLoop::current()->PostTask(
719 FROM_HERE, base::Bind(&chrome::OpenTaskManager, browser)); 783 FROM_HERE,
720 } else if (url_hash_ == profiles::kUserManagerSelectProfileAboutChrome) { 784 base::Bind(&UrlHashHelper::ExecuteUrlHash,
721 base::MessageLoop::current()->PostTask( 785 base::Owned(new UrlHashHelper(browser, url_hash_))));
722 FROM_HERE, base::Bind(&chrome::ShowAboutChrome, browser));
723 } else if (url_hash_ == profiles::kUserManagerSelectProfileChromeSettings) {
724 base::MessageLoop::current()->PostTask(
725 FROM_HERE, base::Bind(&chrome::ShowSettings, browser));
726 } else if (url_hash_ == profiles::kUserManagerSelectProfileChromeMemory) {
727 base::MessageLoop::current()->PostTask(
728 FROM_HERE, base::Bind(&chrome::ShowMemory, browser));
729 } 786 }
730 787
731 // This call is last as it deletes this object. 788 // This call is last as it deletes this object.
732 UserManager::Hide(); 789 UserManager::Hide();
733 } 790 }
734 791
735 void UserManagerScreenHandler::Observe( 792 void UserManagerScreenHandler::Observe(
736 int type, 793 int type,
737 const content::NotificationSource& source, 794 const content::NotificationSource& source,
738 const content::NotificationDetails& details) { 795 const content::NotificationDetails& details) {
(...skipping 19 matching lines...) Expand all
758 Profile* profile, Profile::CreateStatus profile_create_status) { 815 Profile* profile, Profile::CreateStatus profile_create_status) {
759 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); 816 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_);
760 if (browser && browser->window()) { 817 if (browser && browser->window()) {
761 OnBrowserWindowReady(browser); 818 OnBrowserWindowReady(browser);
762 } else { 819 } else {
763 registrar_.Add(this, 820 registrar_.Add(this,
764 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 821 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
765 content::NotificationService::AllSources()); 822 content::NotificationService::AllSources());
766 } 823 }
767 } 824 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/app_list/win/app_list_service_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698