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

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

Issue 2899083003: Delete unused tutorial code from profile switcher/user manager. (Closed)
Patch Set: fix merge Created 3 years, 6 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 // Profile for which the browser should be opened. 118 // Profile for which the browser should be opened.
119 Profile* profile_; 119 Profile* profile_;
120 ProfileManager::CreateCallback callback_; 120 ProfileManager::CreateCallback callback_;
121 121
122 DISALLOW_COPY_AND_ASSIGN(BrowserAddedForProfileObserver); 122 DISALLOW_COPY_AND_ASSIGN(BrowserAddedForProfileObserver);
123 }; 123 };
124 124
125 // Called after a |system_profile| is available to be used by the user manager. 125 // Called after a |system_profile| is available to be used by the user manager.
126 // Based on the value of |tutorial_mode| we determine a url to be displayed 126 // Runs |callback|, if it exists. Depending on the value of
127 // by the webui and run the |callback|, if it exists. Depending on the value of
128 // |user_manager_action|, executes an action once the user manager displays or 127 // |user_manager_action|, executes an action once the user manager displays or
129 // after a profile is opened. 128 // after a profile is opened.
130 void OnUserManagerSystemProfileCreated( 129 void OnUserManagerSystemProfileCreated(
131 const base::FilePath& profile_path_to_focus, 130 const base::FilePath& profile_path_to_focus,
132 profiles::UserManagerTutorialMode tutorial_mode,
133 profiles::UserManagerAction user_manager_action, 131 profiles::UserManagerAction user_manager_action,
134 const base::Callback<void(Profile*, const std::string&)>& callback, 132 const base::Callback<void(Profile*, const std::string&)>& callback,
135 Profile* system_profile, 133 Profile* system_profile,
136 Profile::CreateStatus status) { 134 Profile::CreateStatus status) {
137 if (status != Profile::CREATE_STATUS_INITIALIZED || callback.is_null()) 135 if (status != Profile::CREATE_STATUS_INITIALIZED || callback.is_null())
138 return; 136 return;
139 137
140 // Tell the webui which user should be focused. 138 // Tell the webui which user should be focused.
141 std::string page = chrome::kChromeUIMdUserManagerUrl; 139 std::string page = chrome::kChromeUIMdUserManagerUrl;
142 140
143 if (tutorial_mode == profiles::USER_MANAGER_TUTORIAL_OVERVIEW) { 141 if (!profile_path_to_focus.empty()) {
144 page += profiles::kUserManagerDisplayTutorial;
145 } else if (!profile_path_to_focus.empty()) {
146 // The file path is processed in the same way as base::CreateFilePathValue 142 // The file path is processed in the same way as base::CreateFilePathValue
147 // (i.e. convert to std::string with AsUTF8Unsafe()), and then URI encoded. 143 // (i.e. convert to std::string with AsUTF8Unsafe()), and then URI encoded.
148 page += "#"; 144 page += "#";
149 page += net::EscapeUrlEncodedData(profile_path_to_focus.AsUTF8Unsafe(), 145 page += net::EscapeUrlEncodedData(profile_path_to_focus.AsUTF8Unsafe(),
150 false); 146 false);
151 } else if (user_manager_action == 147 } else if (user_manager_action ==
152 profiles::USER_MANAGER_OPEN_CREATE_USER_PAGE) { 148 profiles::USER_MANAGER_OPEN_CREATE_USER_PAGE) {
153 page += profiles::kUserManagerOpenCreateUserPage; 149 page += profiles::kUserManagerOpenCreateUserPage;
154 } else if (user_manager_action == 150 } else if (user_manager_action ==
155 profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER) { 151 profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER) {
(...skipping 23 matching lines...) Expand all
179 175
180 if (!callback.is_null()) 176 if (!callback.is_null())
181 callback.Run(profile, Profile::CREATE_STATUS_INITIALIZED); 177 callback.Run(profile, Profile::CREATE_STATUS_INITIALIZED);
182 } 178 }
183 179
184 } // namespace 180 } // namespace
185 181
186 namespace profiles { 182 namespace profiles {
187 183
188 // User Manager parameters are prefixed with hash. 184 // User Manager parameters are prefixed with hash.
189 const char kUserManagerDisplayTutorial[] = "#tutorial";
190 const char kUserManagerOpenCreateUserPage[] = "#create-user"; 185 const char kUserManagerOpenCreateUserPage[] = "#create-user";
191 const char kUserManagerSelectProfileTaskManager[] = "#task-manager"; 186 const char kUserManagerSelectProfileTaskManager[] = "#task-manager";
192 const char kUserManagerSelectProfileAboutChrome[] = "#about-chrome"; 187 const char kUserManagerSelectProfileAboutChrome[] = "#about-chrome";
193 const char kUserManagerSelectProfileChromeSettings[] = "#chrome-settings"; 188 const char kUserManagerSelectProfileChromeSettings[] = "#chrome-settings";
194 const char kUserManagerSelectProfileAppLauncher[] = "#app-launcher"; 189 const char kUserManagerSelectProfileAppLauncher[] = "#app-launcher";
195 190
196 base::FilePath GetPathOfProfileWithEmail(ProfileManager* profile_manager, 191 base::FilePath GetPathOfProfileWithEmail(ProfileManager* profile_manager,
197 const std::string& email) { 192 const std::string& email) {
198 base::string16 profile_email = base::UTF8ToUTF16(email); 193 base::string16 profile_email = base::UTF8ToUTF16(email);
199 std::vector<ProfileAttributesEntry*> entries = 194 std::vector<ProfileAttributesEntry*> entries =
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 base::Bind(&profiles::OpenBrowserWindowForProfile, 348 base::Bind(&profiles::OpenBrowserWindowForProfile,
354 callback, 349 callback,
355 true, 350 true,
356 true), 351 true),
357 std::string()); 352 std::string());
358 ProfileMetrics::LogProfileAddNewUser(metric); 353 ProfileMetrics::LogProfileAddNewUser(metric);
359 } 354 }
360 355
361 void ProfileBrowserCloseSuccess(const base::FilePath& profile_path) { 356 void ProfileBrowserCloseSuccess(const base::FilePath& profile_path) {
362 UserManager::Show(base::FilePath(), 357 UserManager::Show(base::FilePath(),
363 profiles::USER_MANAGER_NO_TUTORIAL,
364 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 358 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
365 } 359 }
366 360
367 void CloseGuestProfileWindows() { 361 void CloseGuestProfileWindows() {
368 ProfileManager* profile_manager = g_browser_process->profile_manager(); 362 ProfileManager* profile_manager = g_browser_process->profile_manager();
369 Profile* profile = profile_manager->GetProfileByPath( 363 Profile* profile = profile_manager->GetProfileByPath(
370 ProfileManager::GetGuestProfilePath()); 364 ProfileManager::GetGuestProfilePath());
371 365
372 if (profile) { 366 if (profile) {
373 BrowserList::CloseAllBrowsersWithProfile( 367 BrowserList::CloseAllBrowsersWithProfile(
(...skipping 10 matching lines...) Expand all
384 DCHECK(has_entry); 378 DCHECK(has_entry);
385 entry->SetIsSigninRequired(true); 379 entry->SetIsSigninRequired(true);
386 380
387 #if BUILDFLAG(ENABLE_EXTENSIONS) 381 #if BUILDFLAG(ENABLE_EXTENSIONS)
388 // Profile guaranteed to exist for it to have been locked. 382 // Profile guaranteed to exist for it to have been locked.
389 BlockExtensions(profile_manager->GetProfileByPath(profile_path)); 383 BlockExtensions(profile_manager->GetProfileByPath(profile_path));
390 #endif // BUILDFLAG(ENABLE_EXTENSIONS) 384 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
391 385
392 chrome::HideTaskManager(); 386 chrome::HideTaskManager();
393 UserManager::Show(profile_path, 387 UserManager::Show(profile_path,
394 profiles::USER_MANAGER_NO_TUTORIAL,
395 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 388 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
396 } 389 }
397 390
398 void LockProfile(Profile* profile) { 391 void LockProfile(Profile* profile) {
399 DCHECK(profile); 392 DCHECK(profile);
400 if (profile) { 393 if (profile) {
401 BrowserList::CloseAllBrowsersWithProfile( 394 BrowserList::CloseAllBrowsersWithProfile(
402 profile, base::Bind(&LockBrowserCloseSuccess), 395 profile, base::Bind(&LockBrowserCloseSuccess),
403 BrowserList::CloseCallback(), false); 396 BrowserList::CloseCallback(), false);
404 } 397 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 433
441 void CloseProfileWindows(Profile* profile) { 434 void CloseProfileWindows(Profile* profile) {
442 DCHECK(profile); 435 DCHECK(profile);
443 BrowserList::CloseAllBrowsersWithProfile( 436 BrowserList::CloseAllBrowsersWithProfile(
444 profile, base::Bind(&ProfileBrowserCloseSuccess), 437 profile, base::Bind(&ProfileBrowserCloseSuccess),
445 BrowserList::CloseCallback(), false); 438 BrowserList::CloseCallback(), false);
446 } 439 }
447 440
448 void CreateSystemProfileForUserManager( 441 void CreateSystemProfileForUserManager(
449 const base::FilePath& profile_path_to_focus, 442 const base::FilePath& profile_path_to_focus,
450 profiles::UserManagerTutorialMode tutorial_mode,
451 profiles::UserManagerAction user_manager_action, 443 profiles::UserManagerAction user_manager_action,
452 const base::Callback<void(Profile*, const std::string&)>& callback) { 444 const base::Callback<void(Profile*, const std::string&)>& callback) {
453 // Create the system profile, if necessary, and open the User Manager 445 // Create the system profile, if necessary, and open the User Manager
454 // from the system profile. 446 // from the system profile.
455 g_browser_process->profile_manager()->CreateProfileAsync( 447 g_browser_process->profile_manager()->CreateProfileAsync(
456 ProfileManager::GetSystemProfilePath(), 448 ProfileManager::GetSystemProfilePath(),
457 base::Bind(&OnUserManagerSystemProfileCreated, 449 base::Bind(&OnUserManagerSystemProfileCreated,
458 profile_path_to_focus, 450 profile_path_to_focus,
459 tutorial_mode,
460 user_manager_action, 451 user_manager_action,
461 callback), 452 callback),
462 base::string16(), 453 base::string16(),
463 std::string(), 454 std::string(),
464 std::string()); 455 std::string());
465 } 456 }
466 457
467 void ShowUserManagerMaybeWithTutorial(Profile* profile) { 458 void BubbleViewModeFromAvatarBubbleMode(BrowserWindow::AvatarBubbleMode mode,
468 // Guest users cannot appear in the User Manager, nor display a tutorial. 459 BubbleViewMode* bubble_view_mode) {
469 if (!profile || profile->IsGuestSession()) {
470 UserManager::Show(base::FilePath(),
471 profiles::USER_MANAGER_NO_TUTORIAL,
472 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
473 return;
474 }
475 UserManager::Show(base::FilePath(),
476 profiles::USER_MANAGER_TUTORIAL_OVERVIEW,
477 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
478 }
479
480 void BubbleViewModeFromAvatarBubbleMode(
481 BrowserWindow::AvatarBubbleMode mode,
482 BubbleViewMode* bubble_view_mode,
483 TutorialMode* tutorial_mode) {
484 *tutorial_mode = TUTORIAL_MODE_NONE;
485 switch (mode) { 460 switch (mode) {
486 case BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT: 461 case BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT:
487 *bubble_view_mode = BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; 462 *bubble_view_mode = BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
488 return; 463 return;
489 case BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN: 464 case BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN:
490 *bubble_view_mode = BUBBLE_VIEW_MODE_GAIA_SIGNIN; 465 *bubble_view_mode = BUBBLE_VIEW_MODE_GAIA_SIGNIN;
491 return; 466 return;
492 case BrowserWindow::AVATAR_BUBBLE_MODE_ADD_ACCOUNT: 467 case BrowserWindow::AVATAR_BUBBLE_MODE_ADD_ACCOUNT:
493 *bubble_view_mode = BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT; 468 *bubble_view_mode = BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT;
494 return; 469 return;
495 case BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH: 470 case BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH:
496 *bubble_view_mode = BUBBLE_VIEW_MODE_GAIA_REAUTH; 471 *bubble_view_mode = BUBBLE_VIEW_MODE_GAIA_REAUTH;
497 return; 472 return;
498 case BrowserWindow::AVATAR_BUBBLE_MODE_CONFIRM_SIGNIN: 473 case BrowserWindow::AVATAR_BUBBLE_MODE_CONFIRM_SIGNIN:
499 *bubble_view_mode = BUBBLE_VIEW_MODE_PROFILE_CHOOSER; 474 *bubble_view_mode = BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
500 *tutorial_mode = TUTORIAL_MODE_CONFIRM_SIGNIN;
501 return; 475 return;
502 case BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR: 476 case BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR:
503 *bubble_view_mode = BUBBLE_VIEW_MODE_PROFILE_CHOOSER; 477 *bubble_view_mode = BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
504 *tutorial_mode = TUTORIAL_MODE_SHOW_ERROR;
505 return; 478 return;
506 default: 479 default:
507 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; 480 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
508 } 481 }
509 } 482 }
510 483
511 bool ShouldShowWelcomeUpgradeTutorial(
512 Profile* profile, TutorialMode tutorial_mode) {
513 const int show_count = profile->GetPrefs()->GetInteger(
514 prefs::kProfileAvatarTutorialShown);
515 // Do not show the tutorial if user has dismissed it.
516 if (show_count > signin_ui_util::kUpgradeWelcomeTutorialShowMax)
517 return false;
518
519 return tutorial_mode == TUTORIAL_MODE_WELCOME_UPGRADE ||
520 show_count != signin_ui_util::kUpgradeWelcomeTutorialShowMax;
521 }
522
523 } // namespace profiles 484 } // namespace profiles
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_window.h ('k') | chrome/browser/profiles/profile_window_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698