Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: chrome/browser/profiles/avatar_menu_actions_desktop.cc

Issue 64313005: Fix crash when locking a profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/profiles/avatar_menu_actions_desktop.h" 5 #include "chrome/browser/profiles/avatar_menu_actions_desktop.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.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_info_cache.h" 10 #include "chrome/browser/profiles/profile_info_cache.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 bool AvatarMenuActionsDesktop::ShouldShowAddNewProfileLink() const { 114 bool AvatarMenuActionsDesktop::ShouldShowAddNewProfileLink() const {
115 // |browser_| can be NULL in unit_tests. 115 // |browser_| can be NULL in unit_tests.
116 return !browser_ || !browser_->profile()->IsManaged(); 116 return !browser_ || !browser_->profile()->IsManaged();
117 } 117 }
118 118
119 bool AvatarMenuActionsDesktop::ShouldShowEditProfileLink() const { 119 bool AvatarMenuActionsDesktop::ShouldShowEditProfileLink() const {
120 return true; 120 return true;
121 } 121 }
122 122
123 content::WebContents* AvatarMenuActionsDesktop::BeginSignOut() { 123 void AvatarMenuActionsDesktop::BeginSignOut() {
124 ProfileManager* profile_manager = g_browser_process->profile_manager(); 124 ProfileManager* profile_manager = g_browser_process->profile_manager();
125 Profile* current_profile = browser_->profile(); 125 Profile* current_profile = browser_->profile();
126 126
127 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 127 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
128 size_t index = cache.GetIndexOfProfileWithPath(current_profile->GetPath()); 128 size_t index = cache.GetIndexOfProfileWithPath(current_profile->GetPath());
129 cache.SetProfileSigninRequiredAtIndex(index, true); 129 cache.SetProfileSigninRequiredAtIndex(index, true);
130 130
131 std::string landing_url = signin::GetLandingURL("close", 1).spec(); 131 if (profiles::IsNewProfileManagementEnabled()) {
Roger Tawa OOO till Jul 10th 2013/11/12 15:27:49 nit: do we need this if? I assume this function c
noms (inactive) 2013/11/12 16:47:27 Changed to a DCHECK. It can technically be called
132 GURL logout_url(GaiaUrls::GetInstance()->service_logout_url()); 132 DCHECK(current_profile);
133 logout_url = net::AppendQueryParameter(logout_url, "continue", landing_url); 133 chrome::ShowUserManager(current_profile->GetPath());
134 if (!logout_override_.empty()) {
135 // We're testing...
136 landing_url = logout_override_;
137 logout_url = GURL(logout_override_);
138 } 134 }
139 135
140 content::WebContents::CreateParams create_params(current_profile); 136 BrowserList::CloseAllBrowsersWithProfile(current_profile);
141 create_params.site_instance =
142 content::SiteInstance::CreateForURL(current_profile, logout_url);
143 content::WebContents* contents = content::WebContents::Create(create_params);
144 // This object may be destructed when the menu closes but we need something
145 // around to finish the sign-out process and close the profile windows.
146 new SignoutTracker(current_profile,
147 GURL(landing_url),
148 contents,
149 browser_);
150 contents->GetController().LoadURL(
151 logout_url, content::Referrer(),
152 content::PAGE_TRANSITION_GENERATED, std::string());
153
154 return contents; // returned for testing purposes
155 }
156
157 void AvatarMenuActionsDesktop::SetLogoutURL(const std::string& logout_url) {
158 logout_override_ = logout_url;
159 } 137 }
160 138
161 void AvatarMenuActionsDesktop::ActiveBrowserChanged(Browser* browser) { 139 void AvatarMenuActionsDesktop::ActiveBrowserChanged(Browser* browser) {
162 browser_ = browser; 140 browser_ = browser;
163 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698