| 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/views/profiles/user_manager_view.h" | 5 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/lifetime/application_lifetime.h" | 8 #include "chrome/browser/lifetime/application_lifetime.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/profiles/profile_metrics.h" | 10 #include "chrome/browser/profiles/profile_metrics.h" |
| 11 #include "chrome/browser/profiles/profile_window.h" | 11 #include "chrome/browser/profiles/profile_window.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_dialogs.h" | 13 #include "chrome/browser/ui/browser_dialogs.h" |
| 14 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/user_manager.h" |
| 16 #include "chrome/browser/ui/views/auto_keep_alive.h" | 17 #include "chrome/browser/ui/views/auto_keep_alive.h" |
| 17 #include "chrome/grit/chromium_strings.h" | 18 #include "chrome/grit/chromium_strings.h" |
| 18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
| 21 #include "ui/views/controls/webview/webview.h" | 22 #include "ui/views/controls/webview/webview.h" |
| 22 #include "ui/views/layout/fill_layout.h" | 23 #include "ui/views/layout/fill_layout.h" |
| 23 #include "ui/views/view.h" | 24 #include "ui/views/view.h" |
| 24 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
| 25 #include "ui/views/window/dialog_client_view.h" | 26 #include "ui/views/window/dialog_client_view.h" |
| 26 | 27 |
| 27 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 28 #include "chrome/browser/shell_integration.h" | 29 #include "chrome/browser/shell_integration.h" |
| 29 #include "ui/base/win/shell.h" | 30 #include "ui/base/win/shell.h" |
| 30 #include "ui/views/win/hwnd_util.h" | 31 #include "ui/views/win/hwnd_util.h" |
| 31 #endif | 32 #endif |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 // Default window size. | 36 // Default window size. |
| 36 const int kWindowWidth = 900; | 37 const int kWindowWidth = 900; |
| 37 const int kWindowHeight = 700; | 38 const int kWindowHeight = 700; |
| 38 | 39 |
| 39 } | 40 } |
| 40 | 41 |
| 41 namespace chrome { | 42 void UserManager::Show( |
| 42 | 43 const base::FilePath& profile_path_to_focus, |
| 43 // Declared in browser_dialogs.h so others don't have to depend on this header. | 44 profiles::UserManagerTutorialMode tutorial_mode, |
| 44 void ShowUserManager(const base::FilePath& profile_path_to_focus) { | 45 profiles::UserManagerProfileSelected profile_open_action) { |
| 45 UserManagerView::Show( | 46 UserManagerView::Show(profile_path_to_focus, |
| 46 profile_path_to_focus, profiles::USER_MANAGER_NO_TUTORIAL); | 47 tutorial_mode, |
| 48 profile_open_action); |
| 47 } | 49 } |
| 48 | 50 |
| 49 void ShowUserManagerWithTutorial(profiles::UserManagerTutorialMode tutorial) { | 51 void UserManager::Hide() { |
| 50 UserManagerView::Show(base::FilePath(), tutorial); | |
| 51 } | |
| 52 | |
| 53 void HideUserManager() { | |
| 54 UserManagerView::Hide(); | 52 UserManagerView::Hide(); |
| 55 } | 53 } |
| 56 | 54 |
| 57 } // namespace chrome | 55 bool UserManager::IsShowing() { |
| 56 return UserManagerView::IsShowing(); |
| 57 } |
| 58 | 58 |
| 59 // static | 59 // static |
| 60 UserManagerView* UserManagerView::instance_ = NULL; | 60 UserManagerView* UserManagerView::instance_ = NULL; |
| 61 | 61 |
| 62 UserManagerView::UserManagerView() | 62 UserManagerView::UserManagerView() |
| 63 : web_view_(NULL), | 63 : web_view_(NULL), |
| 64 keep_alive_(new AutoKeepAlive(NULL)) { | 64 keep_alive_(new AutoKeepAlive(NULL)) { |
| 65 } | 65 } |
| 66 | 66 |
| 67 UserManagerView::~UserManagerView() { | 67 UserManagerView::~UserManagerView() { |
| 68 } | 68 } |
| 69 | 69 |
| 70 // static | 70 // static |
| 71 void UserManagerView::Show(const base::FilePath& profile_path_to_focus, | 71 void UserManagerView::Show( |
| 72 profiles::UserManagerTutorialMode tutorial_mode) { | 72 const base::FilePath& profile_path_to_focus, |
| 73 profiles::UserManagerTutorialMode tutorial_mode, |
| 74 profiles::UserManagerProfileSelected profile_open_action) { |
| 73 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::OPEN_USER_MANAGER); | 75 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::OPEN_USER_MANAGER); |
| 74 if (instance_) { | 76 if (instance_) { |
| 75 // If there's a user manager window open already, just activate it. | 77 // If there's a user manager window open already, just activate it. |
| 76 instance_->GetWidget()->Activate(); | 78 instance_->GetWidget()->Activate(); |
| 77 return; | 79 return; |
| 78 } | 80 } |
| 79 | 81 |
| 80 // Create the guest profile, if necessary, and open the user manager | 82 // Create the guest profile, if necessary, and open the user manager |
| 81 // from the guest profile. | 83 // from the guest profile. |
| 82 profiles::CreateGuestProfileForUserManager( | 84 profiles::CreateGuestProfileForUserManager( |
| 83 profile_path_to_focus, | 85 profile_path_to_focus, |
| 84 tutorial_mode, | 86 tutorial_mode, |
| 87 profile_open_action, |
| 85 base::Bind(&UserManagerView::OnGuestProfileCreated, | 88 base::Bind(&UserManagerView::OnGuestProfileCreated, |
| 86 base::Passed(make_scoped_ptr(new UserManagerView)), | 89 base::Passed(make_scoped_ptr(new UserManagerView)), |
| 87 profile_path_to_focus)); | 90 profile_path_to_focus)); |
| 88 } | 91 } |
| 89 | 92 |
| 90 // static | 93 // static |
| 91 void UserManagerView::Hide() { | 94 void UserManagerView::Hide() { |
| 92 if (instance_) | 95 if (instance_) |
| 93 instance_->GetWidget()->Close(); | 96 instance_->GetWidget()->Close(); |
| 94 } | 97 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // Now that the window is closed, we can allow a new one to be opened. | 201 // Now that the window is closed, we can allow a new one to be opened. |
| 199 // (WindowClosing comes in asynchronously from the call to Close() and we | 202 // (WindowClosing comes in asynchronously from the call to Close() and we |
| 200 // may have already opened a new instance). | 203 // may have already opened a new instance). |
| 201 if (instance_ == this) | 204 if (instance_ == this) |
| 202 instance_ = NULL; | 205 instance_ = NULL; |
| 203 } | 206 } |
| 204 | 207 |
| 205 bool UserManagerView::UseNewStyleForThisDialog() const { | 208 bool UserManagerView::UseNewStyleForThisDialog() const { |
| 206 return false; | 209 return false; |
| 207 } | 210 } |
| OLD | NEW |