Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_UI_USER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_USER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_UI_USER_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_USER_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "chrome/browser/profiles/profile_window.h" | 10 #include "chrome/browser/profiles/profile_window.h" |
| 11 #include "components/signin/core/browser/signin_metrics.h" | 11 #include "components/signin/core/browser/signin_metrics.h" |
| 12 #include "content/public/browser/web_contents_delegate.h" | 12 #include "content/public/browser/web_contents_delegate.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class FilePath; | 15 class FilePath; |
| 16 } | 16 } |
| 17 | 17 |
| 18 // Cross-platform methods for displaying the user manager. | 18 // Cross-platform methods for displaying the user manager. |
| 19 class UserManager { | 19 class UserManager { |
| 20 public: | 20 public: |
| 21 // TODO(noms): Figure out if this size can be computed dynamically or adjusted | 21 // TODO(noms): Figure out if this size can be computed dynamically or adjusted |
| 22 // for smaller screens. | 22 // for smaller screens. |
| 23 static constexpr int kWindowWidth = 800; | 23 static constexpr int kWindowWidth = 800; |
| 24 static constexpr int kWindowHeight = 600; | 24 static constexpr int kWindowHeight = 600; |
| 25 | 25 |
| 26 // Dimensions of the reauth dialog displaying the old-style signin flow with | |
| 27 // the username and password challenge on the same form. | |
| 28 static constexpr int kPasswordCombinedReauthDialogHeight = 440; | |
| 29 static constexpr int kPasswordCombinedReauthDialogWidth = 360; | |
| 30 | |
| 31 // Dimensions of the reauth dialog displaying the password-separated signin | |
| 32 // flow. | |
| 33 static constexpr int kReauthDialogHeight = 512; | |
| 34 static constexpr int kReauthDialogWidth = 448; | |
| 35 | |
| 36 // Shows the User Manager or re-activates an existing one, focusing the | 26 // Shows the User Manager or re-activates an existing one, focusing the |
| 37 // profile given by |profile_path_to_focus|; passing an empty base::FilePath | 27 // profile given by |profile_path_to_focus|; passing an empty base::FilePath |
| 38 // focuses no user pod. Based on the value of |tutorial_mode|, a tutorial | 28 // focuses no user pod. Based on the value of |tutorial_mode|, a tutorial |
| 39 // could be shown, in which case |profile_path_to_focus| is ignored. Depending | 29 // could be shown, in which case |profile_path_to_focus| is ignored. Depending |
| 40 // on the value of |user_manager_action|, executes an action once the user | 30 // on the value of |user_manager_action|, executes an action once the user |
| 41 // manager displays or after a profile is opened. | 31 // manager displays or after a profile is opened. |
| 42 static void Show(const base::FilePath& profile_path_to_focus, | 32 static void Show(const base::FilePath& profile_path_to_focus, |
| 43 profiles::UserManagerTutorialMode tutorial_mode, | 33 profiles::UserManagerTutorialMode tutorial_mode, |
| 44 profiles::UserManagerAction user_manager_action); | 34 profiles::UserManagerAction user_manager_action); |
| 45 | 35 |
| 46 // Hides the User Manager. | 36 // Hides the User Manager. |
| 47 static void Hide(); | 37 static void Hide(); |
| 48 | 38 |
| 49 // Returns whether the User Manager is showing and active. | 39 // Returns whether the User Manager is showing and active. |
| 50 // TODO(zmin): Rename the function to something less confusing. | 40 // TODO(zmin): Rename the function to something less confusing. |
| 51 // https://crbug.com/649380. | 41 // https://crbug.com/649380. |
| 52 static bool IsShowing(); | 42 static bool IsShowing(); |
| 53 | 43 |
| 54 // To be called once the User Manager's contents are showing. | 44 // To be called once the User Manager's contents are showing. |
| 55 static void OnUserManagerShown(); | 45 static void OnUserManagerShown(); |
| 56 | 46 |
| 57 // Add a callback that will be called when OnUserManagerShown is called. | 47 // Add a callback that will be called when OnUserManagerShown is called. |
| 58 static void AddOnUserManagerShownCallbackForTesting( | 48 static void AddOnUserManagerShownCallbackForTesting( |
| 59 const base::Closure& callback); | 49 const base::Closure& callback); |
| 60 | 50 |
| 51 // Get the path of profile that is being signed in. | |
| 52 static base::FilePath GetSigninProfilePath(); | |
| 53 | |
| 54 private: | |
| 55 DISALLOW_COPY_AND_ASSIGN(UserManager); | |
|
sky
2016/12/08 23:39:59
Are subclasses of these classes actually created?
zmin
2016/12/09 00:16:28
Done.
| |
| 56 }; | |
| 57 | |
| 58 // Dialog that will be displayed when a profile is selected in UserManager. | |
| 59 class UserManagerDialog { | |
|
sky
2016/12/08 23:39:59
How about a more specific name, UserManagerProfile
zmin
2016/12/09 00:16:28
Done. Also changed the delegate's name to UserMana
| |
| 60 public: | |
| 61 // Dimensions of the reauth dialog displaying the old-style signin flow with | |
| 62 // the username and password challenge on the same form. | |
| 63 static constexpr int kPasswordCombinedDialogHeight = 440; | |
| 64 static constexpr int kPasswordCombinedDialogWidth = 360; | |
| 65 | |
| 66 // Dimensions of the reauth dialog displaying the password-separated signin | |
| 67 // flow. | |
| 68 static constexpr int kDialogHeight = 512; | |
| 69 static constexpr int kDialogWidth = 448; | |
| 70 | |
| 61 // Shows a dialog where the user can re-authenticate the profile with the | 71 // Shows a dialog where the user can re-authenticate the profile with the |
| 62 // given |email|. This is called in the following scenarios: | 72 // given |email|. This is called in the following scenarios: |
| 63 // -From the user manager when a profile is locked and the user's password is | 73 // -From the user manager when a profile is locked and the user's password is |
| 64 // detected to have been changed. | 74 // detected to have been changed. |
| 65 // -From the user manager when a custodian account needs to be | 75 // -From the user manager when a custodian account needs to be |
| 66 // reauthenticated. | 76 // reauthenticated. |
| 67 // |reason| can be REASON_UNLOCK or REASON_REAUTHENTICATION to indicate | 77 // |reason| can be REASON_UNLOCK or REASON_REAUTHENTICATION to indicate |
| 68 // whether this is a reauth or unlock scenario. | 78 // whether this is a reauth or unlock scenario. |
| 69 static void ShowReauthDialog(content::BrowserContext* browser_context, | 79 static void ShowReauthDialog(content::BrowserContext* browser_context, |
| 70 const std::string& email, | 80 const std::string& email, |
| 71 signin_metrics::Reason reason); | 81 signin_metrics::Reason reason); |
| 72 | 82 |
| 73 // Hides the reauth dialog if it is showing. | |
| 74 static void HideReauthDialog(); | |
| 75 | |
| 76 // Shows a dialog where the user logs into their profile for the first time | 83 // Shows a dialog where the user logs into their profile for the first time |
| 77 // via the user manager. | 84 // via the user manager. |
| 78 static void ShowSigninDialog(content::BrowserContext* browser_context, | 85 static void ShowSigninDialog(content::BrowserContext* browser_context, |
| 79 const base::FilePath& profile_path); | 86 const base::FilePath& profile_path); |
| 80 | 87 |
| 88 // Show the dialog and display local sign in error message without browser. | |
| 89 static void ShowDialogAndDisplayErrorMessage( | |
| 90 content::BrowserContext* browser_context); | |
| 91 | |
| 81 // Display local sign in error message without browser. | 92 // Display local sign in error message without browser. |
| 82 static void DisplayErrorMessage(); | 93 static void DisplayErrorMessage(); |
| 83 | 94 |
| 84 // Get the path of profile that is being signed in. | 95 // Hides the dialog if it is showing. |
| 85 static base::FilePath GetSigninProfilePath(); | 96 static void HideDialog(); |
| 86 | 97 |
| 87 // Abstract base class for performing online reauthentication of profiles in | 98 // Abstract base class for performing online reauthentication of profiles in |
| 88 // the User Manager. It is concretely implemented in UserManagerMac and | 99 // the User Manager. It is concretely implemented in UserManagerMac and |
| 89 // UserManagerView to specialize the closing of the UI's dialog widgets. | 100 // UserManagerView to specialize the closing of the UI's dialog widgets. |
| 90 class BaseReauthDialogDelegate : public content::WebContentsDelegate { | 101 class BaseDialogDelegate : public content::WebContentsDelegate { |
| 91 public: | 102 public: |
| 92 BaseReauthDialogDelegate(); | 103 BaseDialogDelegate(); |
| 93 | 104 |
| 94 // content::WebContentsDelegate: | 105 // content::WebContentsDelegate: |
| 95 bool HandleContextMenu(const content::ContextMenuParams& params) override; | 106 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
| 96 | 107 |
| 97 // content::WebContentsDelegate: | 108 // content::WebContentsDelegate: |
| 98 void LoadingStateChanged(content::WebContents* source, | 109 void LoadingStateChanged(content::WebContents* source, |
| 99 bool to_different_document) override; | 110 bool to_different_document) override; |
| 100 | 111 |
| 101 private: | 112 private: |
| 102 virtual void CloseReauthDialog() = 0; | 113 virtual void CloseDialog() = 0; |
|
sky
2016/12/08 23:39:59
Shouldn't the virtual function be protected? It's
zmin
2016/12/09 00:16:28
I just copy+paste but I agree private is weird her
| |
| 103 | 114 |
| 104 // WebContents of the embedded WebView. | 115 // WebContents of the embedded WebView. |
| 105 content::WebContents* guest_web_contents_; | 116 content::WebContents* guest_web_contents_; |
| 106 | 117 |
| 107 DISALLOW_COPY_AND_ASSIGN(BaseReauthDialogDelegate); | 118 DISALLOW_COPY_AND_ASSIGN(BaseDialogDelegate); |
| 108 }; | 119 }; |
| 109 | |
| 110 private: | |
| 111 DISALLOW_COPY_AND_ASSIGN(UserManager); | |
| 112 }; | 120 }; |
| 113 | 121 |
| 114 #endif // CHROME_BROWSER_UI_USER_MANAGER_H_ | 122 #endif // CHROME_BROWSER_UI_USER_MANAGER_H_ |
| OLD | NEW |