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. |
(...skipping 17 matching lines...) Expand all Loading... |
48 // reauthenticated. | 63 // reauthenticated. |
49 // |reason| can be REASON_UNLOCK or REASON_REAUTHENTICATION to indicate | 64 // |reason| can be REASON_UNLOCK or REASON_REAUTHENTICATION to indicate |
50 // whether this is a reauth or unlock scenario. | 65 // whether this is a reauth or unlock scenario. |
51 static void ShowReauthDialog(content::BrowserContext* browser_context, | 66 static void ShowReauthDialog(content::BrowserContext* browser_context, |
52 const std::string& email, | 67 const std::string& email, |
53 signin_metrics::Reason reason); | 68 signin_metrics::Reason reason); |
54 | 69 |
55 // Hides the reauth dialog if it is showing. | 70 // Hides the reauth dialog if it is showing. |
56 static void HideReauthDialog(); | 71 static void HideReauthDialog(); |
57 | 72 |
58 // TODO(noms): Figure out if this size can be computed dynamically or adjusted | 73 // TODO(zmin): Remove the condition for MACOSX once user_manager_mac.cc is |
59 // for smaller screens. | 74 // updated. |
60 static const int kWindowWidth = 800; | 75 #if !defined(OS_MACOSX) |
61 static const int kWindowHeight = 600; | 76 // Shows a dialog where the user login his or her profile by the first time |
| 77 // via user manager. |
| 78 static void ShowSigninDialog(content::BrowserContext* browser_context, |
| 79 const base::FilePath& profile_path); |
62 | 80 |
63 // Dimensions of the reauth dialog displaying the old-style signin flow with | 81 // Display local sign in error message without browser. |
64 // the username and password challenge on the same form. | 82 static void DisplayErrorMessage(); |
65 static const int kPasswordCombinedReauthDialogHeight = 440; | |
66 static const int kPasswordCombinedReauthDialogWidth = 360; | |
67 | 83 |
68 // Dimensions of the reauth dialog displaying the password-separated signin | 84 // Get the path of profile that is being signed in. |
69 // flow. | 85 static base::FilePath GetSigninProfilePath(); |
70 static const int kReauthDialogHeight = 512; | 86 #endif |
71 static const int kReauthDialogWidth = 448; | |
72 | 87 |
73 // Abstract base class for performing online reauthentication of profiles in | 88 // Abstract base class for performing online reauthentication of profiles in |
74 // the User Manager. It is concretely implemented in UserManagerMac and | 89 // the User Manager. It is concretely implemented in UserManagerMac and |
75 // UserManagerView to specialize the closing of the UI's dialog widgets. | 90 // UserManagerView to specialize the closing of the UI's dialog widgets. |
76 class BaseReauthDialogDelegate : public content::WebContentsDelegate { | 91 class BaseReauthDialogDelegate : public content::WebContentsDelegate { |
77 public: | 92 public: |
78 BaseReauthDialogDelegate(); | 93 BaseReauthDialogDelegate(); |
79 | 94 |
80 // content::WebContentsDelegate: | 95 // content::WebContentsDelegate: |
81 bool HandleContextMenu(const content::ContextMenuParams& params) override; | 96 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
82 | 97 |
83 // content::WebContentsDelegate: | 98 // content::WebContentsDelegate: |
84 void LoadingStateChanged(content::WebContents* source, | 99 void LoadingStateChanged(content::WebContents* source, |
85 bool to_different_document) override; | 100 bool to_different_document) override; |
86 | 101 |
87 private: | 102 private: |
88 virtual void CloseReauthDialog() = 0; | 103 virtual void CloseReauthDialog() = 0; |
89 | 104 |
90 // WebContents of the embedded WebView. | 105 // WebContents of the embedded WebView. |
91 content::WebContents* guest_web_contents_; | 106 content::WebContents* guest_web_contents_; |
92 | 107 |
93 DISALLOW_COPY_AND_ASSIGN(BaseReauthDialogDelegate); | 108 DISALLOW_COPY_AND_ASSIGN(BaseReauthDialogDelegate); |
94 }; | 109 }; |
95 | 110 |
96 private: | 111 private: |
97 DISALLOW_COPY_AND_ASSIGN(UserManager); | 112 DISALLOW_COPY_AND_ASSIGN(UserManager); |
98 }; | 113 }; |
99 | 114 |
100 #endif // CHROME_BROWSER_UI_USER_MANAGER_H_ | 115 #endif // CHROME_BROWSER_UI_USER_MANAGER_H_ |
OLD | NEW |