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