OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/cocoa/user_manager_mac.h" | 5 #include "chrome/browser/ui/cocoa/user_manager_mac.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
10 #include "chrome/browser/ui/browser_dialogs.h" | 10 #include "chrome/browser/ui/browser_dialogs.h" |
11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 #include "content/public/browser/web_contents_view.h" | 13 #include "content/public/browser/web_contents_view.h" |
14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
15 #include "ui/base/l10n/l10n_util_mac.h" | 15 #include "ui/base/l10n/l10n_util_mac.h" |
16 | 16 |
17 // Default window size. Taken from the views implementation in | 17 // Default window size. Taken from the views implementation in |
18 // chrome/browser/ui/views/user_manager_view.cc. | 18 // chrome/browser/ui/views/user_manager_view.cc. |
19 // TODO(noms): Figure out if this size can be computed dynamically or adjusted | 19 // TODO(noms): Figure out if this size can be computed dynamically or adjusted |
20 // for smaller screens. | 20 // for smaller screens. |
21 const int kWindowWidth = 900; | 21 const int kWindowWidth = 900; |
22 const int kWindowHeight = 700; | 22 const int kWindowHeight = 700; |
23 | 23 |
24 namespace chrome { | 24 namespace chrome { |
25 | 25 |
26 // Declared in browser_dialogs.h so others don't have to depend on this header. | 26 // Declared in browser_dialogs.h so others don't have to depend on this header. |
27 void ShowUserManager(const base::FilePath& profile_path_to_focus) { | 27 void ShowUserManager(const base::FilePath& profile_path_to_focus) { |
28 UserManagerMac::Show(profile_path_to_focus); | 28 UserManagerMac::Show(profile_path_to_focus, false); |
29 } | 29 } |
30 | 30 |
31 void HideUserManager() { | 31 void HideUserManager() { |
32 UserManagerMac::Hide(); | 32 UserManagerMac::Hide(); |
33 } | 33 } |
34 | 34 |
35 } // namespace chrome | 35 } // namespace chrome |
36 | 36 |
37 // Window controller for the User Manager view. | 37 // Window controller for the User Manager view. |
38 @interface UserManagerWindowController : NSWindowController <NSWindowDelegate> { | 38 @interface UserManagerWindowController : NSWindowController <NSWindowDelegate> { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 | 128 |
129 UserManagerMac::UserManagerMac(Profile* profile) { | 129 UserManagerMac::UserManagerMac(Profile* profile) { |
130 window_controller_.reset([[UserManagerWindowController alloc] | 130 window_controller_.reset([[UserManagerWindowController alloc] |
131 initWithProfile:profile withObserver:this]); | 131 initWithProfile:profile withObserver:this]); |
132 } | 132 } |
133 | 133 |
134 UserManagerMac::~UserManagerMac() { | 134 UserManagerMac::~UserManagerMac() { |
135 } | 135 } |
136 | 136 |
137 // static | 137 // static |
138 void UserManagerMac::Show(const base::FilePath& profile_path_to_focus) { | 138 void UserManagerMac::Show(const base::FilePath& profile_path_to_focus, |
139 bool show_tutorial) { | |
139 if (instance_) { | 140 if (instance_) { |
140 [instance_->window_controller_ show]; | 141 [instance_->window_controller_ show]; |
141 return; | 142 return; |
142 } | 143 } |
143 | 144 |
144 // Create the guest profile, if necessary, and open the User Manager | 145 // Create the guest profile, if necessary, and open the User Manager |
145 // from the guest profile. | 146 // from the guest profile. |
146 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 147 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
147 profile_manager->CreateProfileAsync( | 148 profile_manager->CreateProfileAsync( |
148 ProfileManager::GetGuestProfilePath(), | 149 ProfileManager::GetGuestProfilePath(), |
149 base::Bind(&UserManagerMac::OnGuestProfileCreated, | 150 base::Bind(&UserManagerMac::OnGuestProfileCreated, |
150 profile_path_to_focus), | 151 profile_path_to_focus, |
152 show_tutorial), | |
151 base::string16(), | 153 base::string16(), |
152 base::string16(), | 154 base::string16(), |
153 std::string()); | 155 std::string()); |
154 } | 156 } |
155 | 157 |
156 // static | 158 // static |
157 void UserManagerMac::Hide() { | 159 void UserManagerMac::Hide() { |
158 if (instance_) | 160 if (instance_) |
159 [instance_->window_controller_ close]; | 161 [instance_->window_controller_ close]; |
160 } | 162 } |
161 | 163 |
162 // static | 164 // static |
163 bool UserManagerMac::IsShowing() { | 165 bool UserManagerMac::IsShowing() { |
164 return instance_ ? [instance_->window_controller_ isVisible]: false; | 166 return instance_ ? [instance_->window_controller_ isVisible]: false; |
165 } | 167 } |
166 | 168 |
167 void UserManagerMac::WindowWasClosed() { | 169 void UserManagerMac::WindowWasClosed() { |
168 instance_ = NULL; | 170 instance_ = NULL; |
169 delete this; | 171 delete this; |
170 } | 172 } |
171 | 173 |
172 void UserManagerMac::OnGuestProfileCreated( | 174 void UserManagerMac::OnGuestProfileCreated( |
173 const base::FilePath& profile_path_to_focus, | 175 const base::FilePath& profile_path_to_focus, |
176 bool show_tutorial, | |
174 Profile* guest_profile, | 177 Profile* guest_profile, |
175 Profile::CreateStatus status) { | 178 Profile::CreateStatus status) { |
176 if (status != Profile::CREATE_STATUS_INITIALIZED) | 179 if (status != Profile::CREATE_STATUS_INITIALIZED) |
177 return; | 180 return; |
178 | 181 |
179 instance_ = new UserManagerMac(guest_profile); | 182 instance_ = new UserManagerMac(guest_profile); |
180 | 183 |
181 // Tell the webui which user pod should be focused. | 184 // Tell the webui which user pod should be focused. |
182 std::string page = chrome::kChromeUIUserManagerURL; | 185 std::string page = chrome::kChromeUIUserManagerURL; |
183 | 186 |
184 if (!profile_path_to_focus.empty()) { | 187 if (show_tutorial) { |
188 page += "#tutorial"; | |
Alexei Svitkine (slow)
2014/03/14 21:04:40
So this case ignores the |profile_path_to_focus| p
noms (inactive)
2014/03/17 21:52:23
Done.
| |
189 } else if (!profile_path_to_focus.empty()) { | |
185 ProfileInfoCache& cache = | 190 ProfileInfoCache& cache = |
186 g_browser_process->profile_manager()->GetProfileInfoCache(); | 191 g_browser_process->profile_manager()->GetProfileInfoCache(); |
187 size_t index = cache.GetIndexOfProfileWithPath(profile_path_to_focus); | 192 size_t index = cache.GetIndexOfProfileWithPath(profile_path_to_focus); |
188 if (index != std::string::npos) { | 193 if (index != std::string::npos) { |
189 page += "#"; | 194 page += "#"; |
190 page += base::IntToString(index); | 195 page += base::IntToString(index); |
191 } | 196 } |
192 } | 197 } |
193 [instance_->window_controller_ showURL:GURL(page)]; | 198 [instance_->window_controller_ showURL:GURL(page)]; |
194 } | 199 } |
195 | |
OLD | NEW |