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

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

Issue 471763008: Nicely handle OnBeforeUnloads with guest and lock mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A couple of comments and compiler issues Created 6 years, 3 months 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
« no previous file with comments | « no previous file | chrome/browser/ui/browser_list.h » ('j') | chrome/browser/ui/browser_list.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/profile_window.h" 5 #include "chrome/browser/profiles/profile_window.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 placeholder_avatar_index)), 252 placeholder_avatar_index)),
253 base::Bind(&OpenBrowserWindowForProfile, 253 base::Bind(&OpenBrowserWindowForProfile,
254 callback, 254 callback,
255 true, 255 true,
256 true, 256 true,
257 desktop_type), 257 desktop_type),
258 std::string()); 258 std::string());
259 ProfileMetrics::LogProfileAddNewUser(metric); 259 ProfileMetrics::LogProfileAddNewUser(metric);
260 } 260 }
261 261
262 void GuestBrowserCloseSuccess(const base::FilePath& profile_path) {
263 chrome::ShowUserManager(profile_path);
264 }
265
262 void CloseGuestProfileWindows() { 266 void CloseGuestProfileWindows() {
263 ProfileManager* profile_manager = g_browser_process->profile_manager(); 267 ProfileManager* profile_manager = g_browser_process->profile_manager();
264 Profile* profile = profile_manager->GetProfileByPath( 268 Profile* profile = profile_manager->GetProfileByPath(
265 ProfileManager::GetGuestProfilePath()); 269 ProfileManager::GetGuestProfilePath());
266 270
267 if (profile) { 271 if (profile) {
268 BrowserList::CloseAllBrowsersWithProfile(profile); 272 BrowserList::CloseAllBrowsersWithProfile(
273 profile,
274 base::Bind(&GuestBrowserCloseSuccess));
269 } 275 }
270 } 276 }
271 277
278 void LockBrowserCloseSuccess(const base::FilePath& profile_path) {
279 ProfileInfoCache* cache =
280 &g_browser_process->profile_manager()->GetProfileInfoCache();
281
282 cache->SetProfileSigninRequiredAtIndex(
283 cache->GetIndexOfProfileWithPath(profile_path),
284 true);
285 chrome::ShowUserManager(profile_path);
286 }
287
272 void LockProfile(Profile* profile) { 288 void LockProfile(Profile* profile) {
273 DCHECK(profile); 289 DCHECK(profile);
274 ProfileInfoCache& cache = 290 if (profile) {
275 g_browser_process->profile_manager()->GetProfileInfoCache(); 291 BrowserList::CloseAllBrowsersWithProfile(profile,
276 292 base::Bind(&LockBrowserCloseSuccess));
277 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 293 }
278 cache.SetProfileSigninRequiredAtIndex(index, true);
279 chrome::ShowUserManager(profile->GetPath());
280 BrowserList::CloseAllBrowsersWithProfile(profile);
281 } 294 }
282 295
283 void CreateGuestProfileForUserManager( 296 void CreateGuestProfileForUserManager(
284 const base::FilePath& profile_path_to_focus, 297 const base::FilePath& profile_path_to_focus,
285 profiles::UserManagerTutorialMode tutorial_mode, 298 profiles::UserManagerTutorialMode tutorial_mode,
286 const base::Callback<void(Profile*, const std::string&)>& callback) { 299 const base::Callback<void(Profile*, const std::string&)>& callback) {
287 // Create the guest profile, if necessary, and open the User Manager 300 // Create the guest profile, if necessary, and open the User Manager
288 // from the guest profile. 301 // from the guest profile.
289 g_browser_process->profile_manager()->CreateProfileAsync( 302 g_browser_process->profile_manager()->CreateProfileAsync(
290 ProfileManager::GetGuestProfilePath(), 303 ProfileManager::GetGuestProfilePath(),
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 case BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR: 388 case BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR:
376 *bubble_view_mode = BUBBLE_VIEW_MODE_PROFILE_CHOOSER; 389 *bubble_view_mode = BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
377 *tutorial_mode = TUTORIAL_MODE_SHOW_ERROR; 390 *tutorial_mode = TUTORIAL_MODE_SHOW_ERROR;
378 return; 391 return;
379 default: 392 default:
380 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; 393 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
381 } 394 }
382 } 395 }
383 396
384 } // namespace profiles 397 } // namespace profiles
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/browser_list.h » ('j') | chrome/browser/ui/browser_list.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698