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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/user_manager_mac.mm

Issue 885493005: Setting Guest last-active for the User Manager doesn't create the Guest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac UserManager asyncly creates Guest for Controller 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/cocoa/profiles/user_manager_mac.h" 5 #include "chrome/browser/ui/cocoa/profiles/user_manager_mac.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #import "chrome/browser/app_controller_mac.h" 9 #import "chrome/browser/app_controller_mac.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 11 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
12 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/profiles/profiles_state.h" 13 #include "chrome/browser/profiles/profiles_state.h"
14 #include "chrome/browser/ui/browser_dialogs.h" 14 #include "chrome/browser/ui/browser_dialogs.h"
15 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 15 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
16 #include "chrome/browser/ui/cocoa/chrome_event_processing_window.h" 16 #include "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
17 #include "chrome/browser/ui/user_manager.h" 17 #include "chrome/browser/ui/user_manager.h"
18 #include "chrome/grit/chromium_strings.h" 18 #include "chrome/grit/chromium_strings.h"
19 #include "content/public/browser/native_web_keyboard_event.h" 19 #include "content/public/browser/native_web_keyboard_event.h"
20 #include "content/public/browser/render_widget_host_view.h" 20 #include "content/public/browser/render_widget_host_view.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "content/public/browser/web_contents_delegate.h" 22 #include "content/public/browser/web_contents_delegate.h"
23 #include "ui/base/l10n/l10n_util_mac.h" 23 #include "ui/base/l10n/l10n_util_mac.h"
24 #include "ui/events/keycodes/keyboard_codes.h" 24 #include "ui/events/keycodes/keyboard_codes.h"
25 25
26 namespace {
27
28 void ChangeAppControllerForProfile(Profile* profile,
Alexei Svitkine (slow) 2015/01/28 21:12:32 Add a comment.
Mike Lerman 2015/01/29 14:01:58 Done.
29 Profile::CreateStatus status) {
30 if (status == Profile::CREATE_STATUS_INITIALIZED) {
31 AppController* controller =
32 base::mac::ObjCCast<AppController>([NSApp delegate]);
33 [controller windowChangedToProfile:profile];
34 }
35 }
36
37 }
Alexei Svitkine (slow) 2015/01/28 21:12:32 Add " // namespace" comment.
Mike Lerman 2015/01/29 14:01:58 Done.
26 38
27 // An open User Manager window. There can only be one open at a time. This 39 // An open User Manager window. There can only be one open at a time. This
28 // is reset to NULL when the window is closed. 40 // is reset to NULL when the window is closed.
29 UserManagerMac* instance_ = NULL; // Weak. 41 UserManagerMac* instance_ = NULL; // Weak.
30 42
31 // Custom WebContentsDelegate that allows handling of hotkeys. 43 // Custom WebContentsDelegate that allows handling of hotkeys.
32 class UserManagerWebContentsDelegate : public content::WebContentsDelegate { 44 class UserManagerWebContentsDelegate : public content::WebContentsDelegate {
33 public: 45 public:
34 UserManagerWebContentsDelegate() {} 46 UserManagerWebContentsDelegate() {}
35 47
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (rwhv) 146 if (rwhv)
135 rwhv->SetBackgroundColor(profiles::kUserManagerBackgroundColor); 147 rwhv->SetBackgroundColor(profiles::kUserManagerBackgroundColor);
136 [self show]; 148 [self show];
137 } 149 }
138 150
139 - (void)show { 151 - (void)show {
140 // Because the User Manager isn't a BrowserWindowController, activating it 152 // Because the User Manager isn't a BrowserWindowController, activating it
141 // will not trigger a -windowChangedToProfile and update the menu bar. 153 // will not trigger a -windowChangedToProfile and update the menu bar.
142 // This is only important if the active profile is Guest, which may have 154 // This is only important if the active profile is Guest, which may have
143 // happened after locking a profile. 155 // happened after locking a profile.
144 Profile* guestProfile = profiles::SetActiveProfileToGuestIfLocked(); 156 if (profiles::SetActiveProfileToGuestIfLocked()) {
145 if (guestProfile && guestProfile->IsGuestSession()) { 157 g_browser_process->profile_manager()->CreateProfileAsync(
146 AppController* controller = 158 ProfileManager::GetGuestProfilePath(),
147 base::mac::ObjCCast<AppController>([NSApp delegate]); 159 base::Bind(&ChangeAppControllerForProfile),
148 [controller windowChangedToProfile:guestProfile]; 160 base::string16(),
161 base::string16(),
162 std::string());
149 } 163 }
150 [[self window] makeKeyAndOrderFront:self]; 164 [[self window] makeKeyAndOrderFront:self];
151 } 165 }
152 166
153 - (void)close { 167 - (void)close {
154 [[self window] close]; 168 [[self window] close];
155 } 169 }
156 170
157 -(BOOL)isVisible { 171 -(BOOL)isVisible {
158 return [[self window] isVisible]; 172 return [[self window] isVisible];
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 const std::string& url) { 225 const std::string& url) {
212 DCHECK(!instance_); 226 DCHECK(!instance_);
213 instance_ = new UserManagerMac(system_profile); 227 instance_ = new UserManagerMac(system_profile);
214 [instance_->window_controller() showURL:GURL(url)]; 228 [instance_->window_controller() showURL:GURL(url)];
215 } 229 }
216 230
217 void UserManagerMac::WindowWasClosed() { 231 void UserManagerMac::WindowWasClosed() {
218 instance_ = NULL; 232 instance_ = NULL;
219 delete this; 233 delete this;
220 } 234 }
OLDNEW
« chrome/browser/profiles/profiles_state.cc ('K') | « chrome/browser/profiles/profiles_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698