| 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/profiles/profiles_state.h" |
| 12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_dialogs.h" | 14 #include "chrome/browser/ui/browser_dialogs.h" |
| 14 #include "chrome/browser/ui/browser_finder.h" | 15 #include "chrome/browser/ui/browser_finder.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.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" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 66 } |
| 66 | 67 |
| 67 UserManagerView::~UserManagerView() { | 68 UserManagerView::~UserManagerView() { |
| 68 } | 69 } |
| 69 | 70 |
| 70 // static | 71 // static |
| 71 void UserManagerView::Show(const base::FilePath& profile_path_to_focus, | 72 void UserManagerView::Show(const base::FilePath& profile_path_to_focus, |
| 72 profiles::UserManagerTutorialMode tutorial_mode) { | 73 profiles::UserManagerTutorialMode tutorial_mode) { |
| 73 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::OPEN_USER_MANAGER); | 74 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::OPEN_USER_MANAGER); |
| 74 if (instance_) { | 75 if (instance_) { |
| 76 // If we are showing the User Manager after locking a profile, change the |
| 77 // active profile to Guest. |
| 78 profiles::SetActiveProfileToGuestIfLocked(); |
| 79 |
| 75 // If there's a user manager window open already, just activate it. | 80 // If there's a user manager window open already, just activate it. |
| 76 instance_->GetWidget()->Activate(); | 81 instance_->GetWidget()->Activate(); |
| 77 return; | 82 return; |
| 78 } | 83 } |
| 79 | 84 |
| 80 // Create the guest profile, if necessary, and open the user manager | 85 // Create the guest profile, if necessary, and open the user manager |
| 81 // from the guest profile. | 86 // from the guest profile. |
| 82 profiles::CreateGuestProfileForUserManager( | 87 profiles::CreateGuestProfileForUserManager( |
| 83 profile_path_to_focus, | 88 profile_path_to_focus, |
| 84 tutorial_mode, | 89 tutorial_mode, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 97 bool UserManagerView::IsShowing() { | 102 bool UserManagerView::IsShowing() { |
| 98 return instance_ ? instance_->GetWidget()->IsActive() : false; | 103 return instance_ ? instance_->GetWidget()->IsActive() : false; |
| 99 } | 104 } |
| 100 | 105 |
| 101 // static | 106 // static |
| 102 void UserManagerView::OnGuestProfileCreated( | 107 void UserManagerView::OnGuestProfileCreated( |
| 103 scoped_ptr<UserManagerView> instance, | 108 scoped_ptr<UserManagerView> instance, |
| 104 const base::FilePath& profile_path_to_focus, | 109 const base::FilePath& profile_path_to_focus, |
| 105 Profile* guest_profile, | 110 Profile* guest_profile, |
| 106 const std::string& url) { | 111 const std::string& url) { |
| 112 // If we are showing the User Manager after locking a profile, change the |
| 113 // active profile to Guest. |
| 114 profiles::SetActiveProfileToGuestIfLocked(); |
| 115 |
| 107 instance_ = instance.release(); // |instance_| takes over ownership. | 116 instance_ = instance.release(); // |instance_| takes over ownership. |
| 108 instance_->Init(profile_path_to_focus, guest_profile, GURL(url)); | 117 instance_->Init(profile_path_to_focus, guest_profile, GURL(url)); |
| 109 } | 118 } |
| 110 | 119 |
| 111 void UserManagerView::Init( | 120 void UserManagerView::Init( |
| 112 const base::FilePath& profile_path_to_focus, | 121 const base::FilePath& profile_path_to_focus, |
| 113 Profile* guest_profile, | 122 Profile* guest_profile, |
| 114 const GURL& url) { | 123 const GURL& url) { |
| 115 web_view_ = new views::WebView(guest_profile); | 124 web_view_ = new views::WebView(guest_profile); |
| 116 web_view_->set_allow_accelerators(true); | 125 web_view_->set_allow_accelerators(true); |
| (...skipping 81 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. | 207 // 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 | 208 // (WindowClosing comes in asynchronously from the call to Close() and we |
| 200 // may have already opened a new instance). | 209 // may have already opened a new instance). |
| 201 if (instance_ == this) | 210 if (instance_ == this) |
| 202 instance_ = NULL; | 211 instance_ = NULL; |
| 203 } | 212 } |
| 204 | 213 |
| 205 bool UserManagerView::UseNewStyleForThisDialog() const { | 214 bool UserManagerView::UseNewStyleForThisDialog() const { |
| 206 return false; | 215 return false; |
| 207 } | 216 } |
| OLD | NEW |