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" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // static | 74 // static |
75 void UserManagerView::Show(const base::FilePath& profile_path_to_focus, | 75 void UserManagerView::Show(const base::FilePath& profile_path_to_focus, |
76 profiles::UserManagerTutorialMode tutorial_mode) { | 76 profiles::UserManagerTutorialMode tutorial_mode) { |
77 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::OPEN_USER_MANAGER); | 77 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::OPEN_USER_MANAGER); |
78 if (instance_) { | 78 if (instance_) { |
79 // If there's a user manager window open already, just activate it. | 79 // If there's a user manager window open already, just activate it. |
80 instance_->GetWidget()->Activate(); | 80 instance_->GetWidget()->Activate(); |
81 return; | 81 return; |
82 } | 82 } |
83 | 83 |
84 // Create the guest profile, if necessary, and open the user manager | 84 // Create the User Manager profile, if necessary, and open the User Manager |
85 // from the guest profile. | 85 // when the profile is ready. |
86 profiles::CreateGuestProfileForUserManager( | 86 profiles::CreateUserManagerProfile( |
87 profile_path_to_focus, | 87 profile_path_to_focus, |
88 tutorial_mode, | 88 tutorial_mode, |
89 base::Bind(&UserManagerView::OnGuestProfileCreated)); | 89 base::Bind(&UserManagerView::OnUserManagerProfileCreated)); |
90 } | 90 } |
91 | 91 |
92 // static | 92 // static |
93 void UserManagerView::Hide() { | 93 void UserManagerView::Hide() { |
94 if (instance_) | 94 if (instance_) |
95 instance_->GetWidget()->Close(); | 95 instance_->GetWidget()->Close(); |
96 } | 96 } |
97 | 97 |
98 // static | 98 // static |
99 bool UserManagerView::IsShowing() { | 99 bool UserManagerView::IsShowing() { |
100 return instance_ ? instance_->GetWidget()->IsActive() : false; | 100 return instance_ ? instance_->GetWidget()->IsActive() : false; |
101 } | 101 } |
102 | 102 |
103 // static | 103 // static |
104 void UserManagerView::OnGuestProfileCreated(Profile* guest_profile, | 104 void UserManagerView::OnUserManagerProfileCreated(Profile* profile, |
105 const std::string& url) { | 105 const std::string& url) { |
106 instance_ = new UserManagerView(guest_profile); | 106 instance_ = new UserManagerView(profile); |
107 DialogDelegate::CreateDialogWidget(instance_, NULL, NULL); | 107 DialogDelegate::CreateDialogWidget(instance_, NULL, NULL); |
108 | 108 |
109 gfx::NativeWindow window = instance_->GetWidget()->GetNativeWindow(); | 109 gfx::NativeWindow window = instance_->GetWidget()->GetNativeWindow(); |
110 instance_->keep_alive_.reset(new AutoKeepAlive(window)); | 110 instance_->keep_alive_.reset(new AutoKeepAlive(window)); |
111 | 111 |
112 #if defined(OS_WIN) | 112 #if defined(OS_WIN) |
113 // Set the app id for the task manager to the app id of its parent | 113 // Set the app id for the task manager to the app id of its parent |
114 ui::win::SetAppIdForWindow( | 114 ui::win::SetAppIdForWindow( |
115 ShellIntegration::GetChromiumModelIdForProfile( | 115 ShellIntegration::GetChromiumModelIdForProfile(profile->GetPath()), |
116 guest_profile->GetPath()), | |
117 views::HWNDForWidget(instance_->GetWidget())); | 116 views::HWNDForWidget(instance_->GetWidget())); |
118 #endif | 117 #endif |
119 instance_->GetWidget()->Show(); | 118 instance_->GetWidget()->Show(); |
120 | 119 |
121 instance_->web_view_->LoadInitialURL(GURL(url)); | 120 instance_->web_view_->LoadInitialURL(GURL(url)); |
122 instance_->web_view_->RequestFocus(); | 121 instance_->web_view_->RequestFocus(); |
123 } | 122 } |
124 | 123 |
125 gfx::Size UserManagerView::GetPreferredSize() { | 124 gfx::Size UserManagerView::GetPreferredSize() { |
126 return gfx::Size(kWindowWidth, kWindowHeight); | 125 return gfx::Size(kWindowWidth, kWindowHeight); |
(...skipping 19 matching lines...) Expand all Loading... |
146 // Now that the window is closed, we can allow a new one to be opened. | 145 // Now that the window is closed, we can allow a new one to be opened. |
147 // (WindowClosing comes in asynchronously from the call to Close() and we | 146 // (WindowClosing comes in asynchronously from the call to Close() and we |
148 // may have already opened a new instance). | 147 // may have already opened a new instance). |
149 if (instance_ == this) | 148 if (instance_ == this) |
150 instance_ = NULL; | 149 instance_ = NULL; |
151 } | 150 } |
152 | 151 |
153 bool UserManagerView::UseNewStyleForThisDialog() const { | 152 bool UserManagerView::UseNewStyleForThisDialog() const { |
154 return false; | 153 return false; |
155 } | 154 } |
OLD | NEW |