OLD | NEW |
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" | |
12 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/browser/profiles/profiles_state.h" | 12 #include "chrome/browser/profiles/profiles_state.h" |
14 #include "chrome/browser/ui/browser_dialogs.h" | 13 #include "chrome/browser/ui/browser_dialogs.h" |
15 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 14 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
16 #include "chrome/browser/ui/cocoa/chrome_event_processing_window.h" | 15 #include "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
17 #include "chrome/browser/ui/user_manager.h" | 16 #include "chrome/browser/ui/user_manager.h" |
18 #include "chrome/grit/chromium_strings.h" | 17 #include "chrome/grit/chromium_strings.h" |
19 #include "content/public/browser/native_web_keyboard_event.h" | 18 #include "content/public/browser/native_web_keyboard_event.h" |
20 #include "content/public/browser/render_widget_host_view.h" | |
21 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
22 #include "content/public/browser/web_contents_delegate.h" | 20 #include "content/public/browser/web_contents_delegate.h" |
23 #include "ui/base/l10n/l10n_util_mac.h" | 21 #include "ui/base/l10n/l10n_util_mac.h" |
24 #include "ui/events/keycodes/keyboard_codes.h" | 22 #include "ui/events/keycodes/keyboard_codes.h" |
25 | 23 |
26 | 24 |
27 // An open User Manager window. There can only be one open at a time. This | 25 // 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. | 26 // is reset to NULL when the window is closed. |
29 UserManagerMac* instance_ = NULL; // Weak. | 27 UserManagerMac* instance_ = NULL; // Weak. |
30 | 28 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 121 |
124 - (void)dealloc { | 122 - (void)dealloc { |
125 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 123 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
126 [super dealloc]; | 124 [super dealloc]; |
127 } | 125 } |
128 | 126 |
129 - (void)showURL:(const GURL&)url { | 127 - (void)showURL:(const GURL&)url { |
130 webContents_->GetController().LoadURL(url, content::Referrer(), | 128 webContents_->GetController().LoadURL(url, content::Referrer(), |
131 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 129 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
132 std::string()); | 130 std::string()); |
133 content::RenderWidgetHostView* rwhv = webContents_->GetRenderWidgetHostView(); | |
134 if (rwhv) | |
135 rwhv->SetBackgroundColor(profiles::kUserManagerBackgroundColor); | |
136 [self show]; | 131 [self show]; |
137 } | 132 } |
138 | 133 |
139 - (void)show { | 134 - (void)show { |
140 // Because the User Manager isn't a BrowserWindowController, activating it | 135 // Because the User Manager isn't a BrowserWindowController, activating it |
141 // will not trigger a -windowChangedToProfile and update the menu bar. | 136 // will not trigger a -windowChangedToProfile and update the menu bar. |
142 // This is only important if the active profile is Guest, which may have | 137 // This is only important if the active profile is Guest, which may have |
143 // happened after locking a profile. | 138 // happened after locking a profile. |
144 Profile* guestProfile = profiles::SetActiveProfileToGuestIfLocked(); | 139 Profile* guestProfile = profiles::SetActiveProfileToGuestIfLocked(); |
145 if (guestProfile && guestProfile->IsGuestSession()) { | 140 if (guestProfile && guestProfile->IsGuestSession()) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 const std::string& url) { | 204 const std::string& url) { |
210 DCHECK(!instance_); | 205 DCHECK(!instance_); |
211 instance_ = new UserManagerMac(guest_profile); | 206 instance_ = new UserManagerMac(guest_profile); |
212 [instance_->window_controller() showURL:GURL(url)]; | 207 [instance_->window_controller() showURL:GURL(url)]; |
213 } | 208 } |
214 | 209 |
215 void UserManagerMac::WindowWasClosed() { | 210 void UserManagerMac::WindowWasClosed() { |
216 instance_ = NULL; | 211 instance_ = NULL; |
217 delete this; | 212 delete this; |
218 } | 213 } |
OLD | NEW |