Chromium Code Reviews| Index: chrome/browser/ui/cocoa/profiles/user_manager_mac.mm |
| diff --git a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm |
| index 957d95ba57bb6b8b04cab3e077f8fa47836a668c..ebe9a6c82cfe18c1365efaaac151729876089104 100644 |
| --- a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm |
| +++ b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm |
| @@ -10,6 +10,7 @@ |
| #include "chrome/browser/ui/browser_dialogs.h" |
| #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
| #include "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
| +#include "chrome/browser/ui/user_manager.h" |
| #include "chrome/grit/chromium_strings.h" |
| #include "content/public/browser/native_web_keyboard_event.h" |
| #include "content/public/browser/web_contents.h" |
| @@ -23,23 +24,9 @@ |
| const int kWindowWidth = 900; |
| const int kWindowHeight = 700; |
| -namespace chrome { |
| - |
| -// Declared in browser_dialogs.h so others don't have to depend on this header. |
| -void ShowUserManager(const base::FilePath& profile_path_to_focus) { |
| - UserManagerMac::Show( |
| - profile_path_to_focus, profiles::USER_MANAGER_NO_TUTORIAL); |
| -} |
| - |
| -void ShowUserManagerWithTutorial(profiles::UserManagerTutorialMode tutorial) { |
| - UserManagerMac::Show(base::FilePath(), tutorial); |
| -} |
| - |
| -void HideUserManager() { |
| - UserManagerMac::Hide(); |
| -} |
| - |
| -} // namespace chrome |
| +// An open User Manager window. There can only be one open at a time. This |
| +// is reset to NULL when the window is closed. |
| +UserManagerMac* instance_ = NULL; // Weak. |
|
Alexei Svitkine (slow)
2014/09/18 20:54:04
Why not make it a static member of the class?
Peter Kasting
2014/09/18 21:33:47
Being file-scoped in the .mm file is even more loc
|
| // Custom WebContentsDelegate that allows handling of hotkeys. |
| class UserManagerWebContentsDelegate : public content::WebContentsDelegate { |
| @@ -163,23 +150,14 @@ class UserManagerWebContentsDelegate : public content::WebContentsDelegate { |
| @end |
| -// static |
| -UserManagerMac* UserManagerMac::instance_ = NULL; |
| -UserManagerMac::UserManagerMac(Profile* profile) { |
| - window_controller_.reset([[UserManagerWindowController alloc] |
| - initWithProfile:profile withObserver:this]); |
| -} |
| - |
| -UserManagerMac::~UserManagerMac() { |
| -} |
| - |
| -// static |
| -void UserManagerMac::Show(const base::FilePath& profile_path_to_focus, |
| - profiles::UserManagerTutorialMode tutorial_mode) { |
| +void UserManager::Show( |
| + const base::FilePath& profile_path_to_focus, |
| + profiles::UserManagerTutorialMode tutorial_mode, |
| + profiles::UserManagerProfileSelected profile_open_action) { |
| if (instance_) { |
| // If there's a user manager window open already, just activate it. |
| - [instance_->window_controller_ show]; |
| + [instance_->get_window_controller() show]; |
| return; |
| } |
| @@ -188,25 +166,33 @@ void UserManagerMac::Show(const base::FilePath& profile_path_to_focus, |
| profiles::CreateGuestProfileForUserManager( |
| profile_path_to_focus, |
| tutorial_mode, |
| + profile_open_action, |
| base::Bind(&UserManagerMac::OnGuestProfileCreated)); |
| } |
| -// static |
| -void UserManagerMac::Hide() { |
| +void UserManager::Hide() { |
| if (instance_) |
| - [instance_->window_controller_ close]; |
| + [instance_->get_window_controller() close]; |
| } |
| -// static |
| -bool UserManagerMac::IsShowing() { |
| - return instance_ ? [instance_->window_controller_ isVisible]: false; |
| +bool UserManager::IsShowing() { |
| + return instance_ ? [instance_->get_window_controller() isVisible]: false; |
| +} |
| + |
| +UserManagerMac::UserManagerMac(Profile* profile) { |
| + window_controller_.reset([[UserManagerWindowController alloc] |
| + initWithProfile:profile withObserver:this]); |
| +} |
| + |
| +UserManagerMac::~UserManagerMac() { |
| } |
| // static |
| void UserManagerMac::OnGuestProfileCreated(Profile* guest_profile, |
| const std::string& url) { |
| + DCHECK(!instance_); |
| instance_ = new UserManagerMac(guest_profile); |
| - [instance_->window_controller_ showURL:GURL(url)]; |
| + [instance_->get_window_controller() showURL:GURL(url)]; |
| } |
| void UserManagerMac::WindowWasClosed() { |