| 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 |
| 22 // for smaller screens. |
| 23 static constexpr int kWindowWidth = 800; |
| 24 static constexpr int kWindowHeight = 600; |
| 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 |
| 21 // Shows the User Manager or re-activates an existing one, focusing the | 36 // Shows the User Manager or re-activates an existing one, focusing the |
| 22 // profile given by |profile_path_to_focus|; passing an empty base::FilePath | 37 // profile given by |profile_path_to_focus|; passing an empty base::FilePath |
| 23 // focuses no user pod. Based on the value of |tutorial_mode|, a tutorial | 38 // focuses no user pod. Based on the value of |tutorial_mode|, a tutorial |
| 24 // could be shown, in which case |profile_path_to_focus| is ignored. After a | 39 // could be shown, in which case |profile_path_to_focus| is ignored. After a |
| 25 // profile is opened, executes the |profile_open_action|. | 40 // profile is opened, executes the |profile_open_action|. |
| 26 static void Show(const base::FilePath& profile_path_to_focus, | 41 static void Show(const base::FilePath& profile_path_to_focus, |
| 27 profiles::UserManagerTutorialMode tutorial_mode, | 42 profiles::UserManagerTutorialMode tutorial_mode, |
| 28 profiles::UserManagerProfileSelected profile_open_action); | 43 profiles::UserManagerProfileSelected profile_open_action); |
| 29 | 44 |
| 30 // Hides the User Manager. | 45 // Hides the User Manager. |
| 31 static void Hide(); | 46 static void Hide(); |
| 32 | 47 |
| 33 // Returns whether the User Manager is showing. | 48 // Returns whether the User Manager is showing and active. |
| 49 // TODO(zmin): Rename the function to something less confusing. |
| 50 // https://crbug.com/649380. |
| 34 static bool IsShowing(); | 51 static bool IsShowing(); |
| 35 | 52 |
| 36 // To be called once the User Manager's contents are showing. | 53 // To be called once the User Manager's contents are showing. |
| 37 static void OnUserManagerShown(); | 54 static void OnUserManagerShown(); |
| 38 | 55 |
| 39 // Add a callback that will be called when OnUserManagerShown is called. | 56 // Add a callback that will be called when OnUserManagerShown is called. |
| 40 static void AddOnUserManagerShownCallbackForTesting( | 57 static void AddOnUserManagerShownCallbackForTesting( |
| 41 const base::Closure& callback); | 58 const base::Closure& callback); |
| 42 | 59 |
| 43 // Shows a dialog where the user can re-authenticate the profile with the | 60 // Shows a dialog where the user can re-authenticate the profile with the |
| 44 // given |email|. This is called in the following scenarios: | 61 // given |email|. This is called in the following scenarios: |
| 45 // -From the user manager when a profile is locked and the user's password is | 62 // -From the user manager when a profile is locked and the user's password is |
| 46 // detected to have been changed. | 63 // detected to have been changed. |
| 47 // -From the user manager when a custodian account needs to be | 64 // -From the user manager when a custodian account needs to be |
| 48 // reauthenticated. | 65 // reauthenticated. |
| 49 // |reason| can be REASON_UNLOCK or REASON_REAUTHENTICATION to indicate | 66 // |reason| can be REASON_UNLOCK or REASON_REAUTHENTICATION to indicate |
| 50 // whether this is a reauth or unlock scenario. | 67 // whether this is a reauth or unlock scenario. |
| 51 static void ShowReauthDialog(content::BrowserContext* browser_context, | 68 static void ShowReauthDialog(content::BrowserContext* browser_context, |
| 52 const std::string& email, | 69 const std::string& email, |
| 53 signin_metrics::Reason reason); | 70 signin_metrics::Reason reason); |
| 54 | 71 |
| 55 // Hides the reauth dialog if it is showing. | 72 // Hides the reauth dialog if it is showing. |
| 56 static void HideReauthDialog(); | 73 static void HideReauthDialog(); |
| 57 | 74 |
| 58 // TODO(noms): Figure out if this size can be computed dynamically or adjusted | 75 // TODO(zmin): Remove the condition for MACOSX once user_manager_mac.cc is |
| 59 // for smaller screens. | 76 // updated. |
| 60 static const int kWindowWidth = 800; | 77 #if !defined(OS_MACOSX) |
| 61 static const int kWindowHeight = 600; | 78 // Shows a dialog where the user login his or her profile by the first time |
| 79 // via user manager. |
| 80 static void ShowSigninDialog(content::BrowserContext* browser_context, |
| 81 const base::FilePath& profile_path); |
| 62 | 82 |
| 63 // Dimensions of the reauth dialog displaying the old-style signin flow with | 83 // Display local sign in error message without browser. |
| 64 // the username and password challenge on the same form. | 84 static void DisplayErrorMessage(); |
| 65 static const int kPasswordCombinedReauthDialogHeight = 440; | |
| 66 static const int kPasswordCombinedReauthDialogWidth = 360; | |
| 67 | 85 |
| 68 // Dimensions of the reauth dialog displaying the password-separated signin | 86 // Get the path of profile that is being signed in. |
| 69 // flow. | 87 static base::FilePath GetSigninProfilePath(); |
| 70 static const int kReauthDialogHeight = 512; | 88 #endif |
| 71 static const int kReauthDialogWidth = 448; | |
| 72 | 89 |
| 73 // Abstract base class for performing online reauthentication of profiles in | 90 // Abstract base class for performing online reauthentication of profiles in |
| 74 // the User Manager. It is concretely implemented in UserManagerMac and | 91 // the User Manager. It is concretely implemented in UserManagerMac and |
| 75 // UserManagerView to specialize the closing of the UI's dialog widgets. | 92 // UserManagerView to specialize the closing of the UI's dialog widgets. |
| 76 class BaseReauthDialogDelegate : public content::WebContentsDelegate { | 93 class BaseReauthDialogDelegate : public content::WebContentsDelegate { |
| 77 public: | 94 public: |
| 78 BaseReauthDialogDelegate(); | 95 BaseReauthDialogDelegate(); |
| 79 | 96 |
| 80 // content::WebContentsDelegate: | 97 // content::WebContentsDelegate: |
| 81 bool HandleContextMenu(const content::ContextMenuParams& params) override; | 98 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
| 82 | 99 |
| 83 // content::WebContentsDelegate: | 100 // content::WebContentsDelegate: |
| 84 void LoadingStateChanged(content::WebContents* source, | 101 void LoadingStateChanged(content::WebContents* source, |
| 85 bool to_different_document) override; | 102 bool to_different_document) override; |
| 86 | 103 |
| 87 private: | 104 private: |
| 88 virtual void CloseReauthDialog() = 0; | 105 virtual void CloseReauthDialog() = 0; |
| 89 | 106 |
| 90 // WebContents of the embedded WebView. | 107 // WebContents of the embedded WebView. |
| 91 content::WebContents* guest_web_contents_; | 108 content::WebContents* guest_web_contents_; |
| 92 | 109 |
| 93 DISALLOW_COPY_AND_ASSIGN(BaseReauthDialogDelegate); | 110 DISALLOW_COPY_AND_ASSIGN(BaseReauthDialogDelegate); |
| 94 }; | 111 }; |
| 95 | 112 |
| 96 private: | 113 private: |
| 97 DISALLOW_COPY_AND_ASSIGN(UserManager); | 114 DISALLOW_COPY_AND_ASSIGN(UserManager); |
| 98 }; | 115 }; |
| 99 | 116 |
| 100 #endif // CHROME_BROWSER_UI_USER_MANAGER_H_ | 117 #endif // CHROME_BROWSER_UI_USER_MANAGER_H_ |
| OLD | NEW |