1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_USER_MANAGER_H_ 6 #define CHROME_BROWSER_UI_USER_MANAGER_H_ 7 8 #include "base/callback_forward.h" 9 #include "base/macros.h" 10 #include "build/build_config.h" 11 #include "chrome/browser/profiles/profile_window.h" 12 #include "components/signin/public/base/signin_metrics.h" 13 #include "content/public/browser/web_contents_delegate.h" 14 15 namespace base { 16 class FilePath; 17 } 18 19 // Cross-platform methods for displaying the user manager. 20 class UserManager { 21 public: 22 // TODO(noms): Figure out if this size can be computed dynamically or adjusted 23 // for smaller screens. 24 static constexpr int kWindowWidth = 800; 25 static constexpr int kWindowHeight = 600; 26 27 // Shows the User Manager or re-activates an existing one, focusing the 28 // profile given by |profile_path_to_focus|; passing an empty base::FilePath 29 // focuses no user pod. Depending on the value of |user_manager_action|, 30 // executes an action once the user manager displays or after a profile is 31 // opened. 32 static void Show(const base::FilePath& profile_path_to_focus, 33 profiles::UserManagerAction user_manager_action); 34 35 // Hides the User Manager. 36 static void Hide(); 37 38 // Returns whether the User Manager is showing and active. 39 // TODO(zmin): Rename the function to something less confusing. 40 // https://crbug.com/649380. 41 static bool IsShowing(); 42 43 // To be called once the User Manager's contents are showing. 44 static void OnUserManagerShown(); 45 46 // Add a callback that will be called the next time OnUserManagerShown is 47 // called. 48 static void AddOnUserManagerShownCallbackForTesting( 49 base::OnceClosure callback); 50 51 // Get the path of profile that is being signed in. 52 static base::FilePath GetSigninProfilePath(); 53 54 private: 55 DISALLOW_IMPLICIT_CONSTRUCTORS(UserManager); 56 }; 57 58 // Dialog that will be displayed when a profile is selected in UserManager. 59 class UserManagerProfileDialog { 60 public: 61 // Dimensions of the reauth dialog displaying the password-separated signin 62 // flow. 63 static constexpr int kDialogHeight = 512; 64 static constexpr int kDialogWidth = 448; 65 66 // Shows a dialog where the user can re-authenticate the profile with the 67 // given |email|. This is called from the user manager when a profile is 68 // locked and the user's password is detected to have been changed. 69 static void ShowUnlockDialog(content::BrowserContext* browser_context, 70 const std::string& email); 71 72 // Shows a reauth dialog with profile path so that the sign in error message 73 // can be displayed without browser window. 74 static void ShowUnlockDialogWithProfilePath( 75 content::BrowserContext* browser_context, 76 const std::string& email, 77 const base::FilePath& profile_path); 78 79 // Shows a dialog where the user logs into their profile for the first time 80 // via the user manager, when force signin is enabled. 81 static void ShowForceSigninDialog(content::BrowserContext* browser_context, 82 const base::FilePath& profile_path); 83 84 // Show the dialog and display local sign in error message without browser. 85 static void ShowDialogAndDisplayErrorMessage( 86 content::BrowserContext* browser_context); 87 88 // Display local sign in error message without browser. 89 static void DisplayErrorMessage(); 90 91 // Hides the dialog if it is showing. 92 static void HideDialog(); 93 94 // Abstract base class for performing online reauthentication of profiles in 95 // the User Manager. It is concretely implemented in UserManagerMac and 96 // UserManagerView to specialize the closing of the UI's dialog widgets. 97 class BaseDialogDelegate : public content::WebContentsDelegate { 98 public: 99 BaseDialogDelegate(); 100 101 // content::WebContentsDelegate: 102 bool HandleContextMenu(content::RenderFrameHost* render_frame_host, 103 const content::ContextMenuParams& params) override; 104 105 // content::WebContentsDelegate: 106 void LoadingStateChanged(content::WebContents* source, 107 bool to_different_document) override; 108 109 protected: 110 virtual void CloseDialog() = 0; 111 112 // WebContents of the embedded WebView. 113 content::WebContents* guest_web_contents_; 114 115 DISALLOW_COPY_AND_ASSIGN(BaseDialogDelegate); 116 }; 117 }; 118 119 #endif // CHROME_BROWSER_UI_USER_MANAGER_H_ 120