| 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_avatar_icon_util.h" | 9 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 if (instance_) { | 54 if (instance_) { |
| 55 // If we are showing the User Manager after locking a profile, change the | 55 // If we are showing the User Manager after locking a profile, change the |
| 56 // active profile to Guest. | 56 // active profile to Guest. |
| 57 profiles::SetActiveProfileToGuestIfLocked(); | 57 profiles::SetActiveProfileToGuestIfLocked(); |
| 58 | 58 |
| 59 // If there's a user manager window open already, just activate it. | 59 // If there's a user manager window open already, just activate it. |
| 60 instance_->GetWidget()->Activate(); | 60 instance_->GetWidget()->Activate(); |
| 61 return; | 61 return; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Create the guest profile, if necessary, and open the user manager | 64 // Create the system profile, if necessary, and open the user manager |
| 65 // from the guest profile. | 65 // from the system profile. |
| 66 profiles::CreateGuestProfileForUserManager( | 66 profiles::CreateSystemProfileForUserManager( |
| 67 profile_path_to_focus, | 67 profile_path_to_focus, |
| 68 tutorial_mode, | 68 tutorial_mode, |
| 69 profile_open_action, | 69 profile_open_action, |
| 70 base::Bind(&UserManagerView::OnGuestProfileCreated, | 70 base::Bind(&UserManagerView::OnSystemProfileCreated, |
| 71 base::Passed(make_scoped_ptr(new UserManagerView)))); | 71 base::Passed(make_scoped_ptr(new UserManagerView)))); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void UserManager::Hide() { | 74 void UserManager::Hide() { |
| 75 if (instance_) | 75 if (instance_) |
| 76 instance_->GetWidget()->Close(); | 76 instance_->GetWidget()->Close(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool UserManager::IsShowing() { | 79 bool UserManager::IsShowing() { |
| 80 return instance_ ? instance_->GetWidget()->IsActive() : false; | 80 return instance_ ? instance_->GetWidget()->IsActive() : false; |
| 81 } | 81 } |
| 82 | 82 |
| 83 // UserManagerView ------------------------------------------------------------- | 83 // UserManagerView ------------------------------------------------------------- |
| 84 | 84 |
| 85 UserManagerView::UserManagerView() | 85 UserManagerView::UserManagerView() |
| 86 : web_view_(NULL), | 86 : web_view_(NULL), |
| 87 keep_alive_(new AutoKeepAlive(NULL)) { | 87 keep_alive_(new AutoKeepAlive(NULL)) { |
| 88 } | 88 } |
| 89 | 89 |
| 90 UserManagerView::~UserManagerView() { | 90 UserManagerView::~UserManagerView() { |
| 91 } | 91 } |
| 92 | 92 |
| 93 // static | 93 // static |
| 94 void UserManagerView::OnGuestProfileCreated( | 94 void UserManagerView::OnSystemProfileCreated( |
| 95 scoped_ptr<UserManagerView> instance, | 95 scoped_ptr<UserManagerView> instance, |
| 96 Profile* guest_profile, | 96 Profile* system_profile, |
| 97 const std::string& url) { | 97 const std::string& url) { |
| 98 // If we are showing the User Manager after locking a profile, change the | 98 // If we are showing the User Manager after locking a profile, change the |
| 99 // active profile to Guest. | 99 // active profile to Guest. |
| 100 profiles::SetActiveProfileToGuestIfLocked(); | 100 profiles::SetActiveProfileToGuestIfLocked(); |
| 101 | 101 |
| 102 DCHECK(!instance_); | 102 DCHECK(!instance_); |
| 103 instance_ = instance.release(); // |instance_| takes over ownership. | 103 instance_ = instance.release(); // |instance_| takes over ownership. |
| 104 instance_->Init(guest_profile, GURL(url)); | 104 instance_->Init(system_profile, GURL(url)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void UserManagerView::Init(Profile* guest_profile, const GURL& url) { | 107 void UserManagerView::Init(Profile* system_profile, const GURL& url) { |
| 108 web_view_ = new views::WebView(guest_profile); | 108 web_view_ = new views::WebView(system_profile); |
| 109 web_view_->set_allow_accelerators(true); | 109 web_view_->set_allow_accelerators(true); |
| 110 AddChildView(web_view_); | 110 AddChildView(web_view_); |
| 111 SetLayoutManager(new views::FillLayout); | 111 SetLayoutManager(new views::FillLayout); |
| 112 AddAccelerator(ui::Accelerator(ui::VKEY_W, ui::EF_CONTROL_DOWN)); | 112 AddAccelerator(ui::Accelerator(ui::VKEY_W, ui::EF_CONTROL_DOWN)); |
| 113 AddAccelerator(ui::Accelerator(ui::VKEY_F4, ui::EF_ALT_DOWN)); | 113 AddAccelerator(ui::Accelerator(ui::VKEY_F4, ui::EF_ALT_DOWN)); |
| 114 | 114 |
| 115 // If the user manager is being displayed from an existing profile, use | 115 // If the user manager is being displayed from an existing profile, use |
| 116 // its last active browser to determine where the user manager should be | 116 // its last active browser to determine where the user manager should be |
| 117 // placed. This is used so that we can center the dialog on the correct | 117 // placed. This is used so that we can center the dialog on the correct |
| 118 // monitor in a multiple-monitor setup. | 118 // monitor in a multiple-monitor setup. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 142 // Since the User Manager can be the only top level window, we don't | 142 // Since the User Manager can be the only top level window, we don't |
| 143 // want to accidentally quit all of Chrome if the user is just trying to | 143 // want to accidentally quit all of Chrome if the user is just trying to |
| 144 // unfocus the selected pod in the WebView. | 144 // unfocus the selected pod in the WebView. |
| 145 GetDialogClientView()->RemoveAccelerator( | 145 GetDialogClientView()->RemoveAccelerator( |
| 146 ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | 146 ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
| 147 | 147 |
| 148 #if defined(OS_WIN) | 148 #if defined(OS_WIN) |
| 149 // Set the app id for the task manager to the app id of its parent | 149 // Set the app id for the task manager to the app id of its parent |
| 150 ui::win::SetAppIdForWindow( | 150 ui::win::SetAppIdForWindow( |
| 151 ShellIntegration::GetChromiumModelIdForProfile( | 151 ShellIntegration::GetChromiumModelIdForProfile( |
| 152 guest_profile->GetPath()), | 152 system_profile->GetPath()), |
| 153 views::HWNDForWidget(GetWidget())); | 153 views::HWNDForWidget(GetWidget())); |
| 154 #endif | 154 #endif |
| 155 | 155 |
| 156 web_view_->LoadInitialURL(url); | 156 web_view_->LoadInitialURL(url); |
| 157 content::RenderWidgetHostView* rwhv = | 157 content::RenderWidgetHostView* rwhv = |
| 158 web_view_->GetWebContents()->GetRenderWidgetHostView(); | 158 web_view_->GetWebContents()->GetRenderWidgetHostView(); |
| 159 if (rwhv) | 159 if (rwhv) |
| 160 rwhv->SetBackgroundColor(profiles::kUserManagerBackgroundColor); | 160 rwhv->SetBackgroundColor(profiles::kUserManagerBackgroundColor); |
| 161 | 161 |
| 162 web_view_->RequestFocus(); | 162 web_view_->RequestFocus(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 // 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. |
| 202 // (WindowClosing comes in asynchronously from the call to Close() and we | 202 // (WindowClosing comes in asynchronously from the call to Close() and we |
| 203 // may have already opened a new instance). | 203 // may have already opened a new instance). |
| 204 if (instance_ == this) | 204 if (instance_ == this) |
| 205 instance_ = NULL; | 205 instance_ = NULL; |
| 206 } | 206 } |
| 207 | 207 |
| 208 bool UserManagerView::UseNewStyleForThisDialog() const { | 208 bool UserManagerView::UseNewStyleForThisDialog() const { |
| 209 return false; | 209 return false; |
| 210 } | 210 } |
| OLD | NEW |