| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/profiles/avatar_menu_model.h" | 5 #include "chrome/browser/profiles/avatar_menu_model.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 DCHECK(profiles::IsMultipleProfilesEnabled() || | 145 DCHECK(profiles::IsMultipleProfilesEnabled() || |
| 146 index == GetActiveProfileIndex()); | 146 index == GetActiveProfileIndex()); |
| 147 const Item& item = GetItemAt(index); | 147 const Item& item = GetItemAt(index); |
| 148 base::FilePath path = | 148 base::FilePath path = |
| 149 profile_info_->GetPathOfProfileAtIndex(item.model_index); | 149 profile_info_->GetPathOfProfileAtIndex(item.model_index); |
| 150 | 150 |
| 151 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 151 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
| 152 if (browser_) | 152 if (browser_) |
| 153 desktop_type = browser_->host_desktop_type(); | 153 desktop_type = browser_->host_desktop_type(); |
| 154 | 154 |
| 155 g_browser_process->profile_manager()->CreateProfileAsync( | 155 profiles::SwitchToProfile(path, desktop_type, always_create); |
| 156 path, | |
| 157 base::Bind(&OnProfileCreated, | |
| 158 always_create, | |
| 159 desktop_type), | |
| 160 string16(), | |
| 161 string16(), | |
| 162 false); | |
| 163 | |
| 164 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_ICON); | 156 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_ICON); |
| 165 } | 157 } |
| 166 | 158 |
| 167 void AvatarMenuModel::EditProfile(size_t index) { | 159 void AvatarMenuModel::EditProfile(size_t index) { |
| 168 Browser* browser = browser_; | 160 Browser* browser = browser_; |
| 169 if (!browser) { | 161 if (!browser) { |
| 170 Profile* profile = g_browser_process->profile_manager()->GetProfileByPath( | 162 Profile* profile = g_browser_process->profile_manager()->GetProfileByPath( |
| 171 profile_info_->GetPathOfProfileAtIndex(GetItemAt(index).model_index)); | 163 profile_info_->GetPathOfProfileAtIndex(GetItemAt(index).model_index)); |
| 172 browser = new Browser(Browser::CreateParams(profile, | 164 browser = new Browser(Browser::CreateParams(profile, |
| 173 chrome::GetActiveDesktop())); | 165 chrome::GetActiveDesktop())); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 contents->GetController().LoadURL( | 349 contents->GetController().LoadURL( |
| 358 logout_url, content::Referrer(), | 350 logout_url, content::Referrer(), |
| 359 content::PAGE_TRANSITION_GENERATED, std::string()); | 351 content::PAGE_TRANSITION_GENERATED, std::string()); |
| 360 | 352 |
| 361 // This object may be destructed when the menu closes but we need something | 353 // This object may be destructed when the menu closes but we need something |
| 362 // around to finish the sign-out process and close the profile windows. | 354 // around to finish the sign-out process and close the profile windows. |
| 363 new SignoutTracker(current_profile, GURL(landing_url), contents); | 355 new SignoutTracker(current_profile, GURL(landing_url), contents); |
| 364 | 356 |
| 365 return contents; // returned for testing purposes | 357 return contents; // returned for testing purposes |
| 366 } | 358 } |
| OLD | NEW |