| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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_VIEWS_PROFILES_USER_MANAGER_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_USER_MANAGER_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_USER_MANAGER_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_USER_MANAGER_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/profiles/profile_window.h" | 13 #include "chrome/browser/profiles/profile_window.h" |
| 14 #include "chrome/browser/ui/user_manager.h" | 14 #include "chrome/browser/ui/user_manager.h" |
| 15 #include "components/signin/core/browser/signin_metrics.h" | 15 #include "components/signin/core/browser/signin_metrics.h" |
| 16 #include "ui/views/controls/webview/webview.h" | 16 #include "ui/views/controls/webview/webview.h" |
| 17 #include "ui/views/window/dialog_delegate.h" | 17 #include "ui/views/window/dialog_delegate.h" |
| 18 | 18 |
| 19 class ScopedKeepAlive; | 19 class ScopedKeepAlive; |
| 20 class UserManagerView; | 20 class UserManagerView; |
| 21 | 21 |
| 22 class ReauthDelegate : public views::DialogDelegateView, | 22 class UserManagerProfileDialogDelegate |
| 23 public UserManager::BaseReauthDialogDelegate { | 23 : public views::DialogDelegateView, |
| 24 public UserManagerProfileDialog::BaseDialogDelegate { |
| 24 public: | 25 public: |
| 25 ReauthDelegate(UserManagerView* parent, | 26 UserManagerProfileDialogDelegate(UserManagerView* parent, |
| 26 views::WebView* web_view, | 27 views::WebView* web_view, |
| 27 const std::string& email_address, | 28 const std::string& email_address, |
| 28 signin_metrics::Reason reason); | 29 const GURL& url); |
| 29 ~ReauthDelegate() override; | 30 ~UserManagerProfileDialogDelegate() override; |
| 30 | 31 |
| 31 // UserManager::BaseReauthDialogDelegate: | 32 // UserManagerProfileDialog::BaseDialogDelegate |
| 32 void CloseReauthDialog() override; | 33 void CloseDialog() override; |
| 33 | 34 |
| 34 // Display the local error message inside login window. | 35 // Display the local error message inside login window. |
| 35 void DisplayErrorMessage(); | 36 void DisplayErrorMessage(); |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 ReauthDelegate(); | 39 UserManagerProfileDialogDelegate(); |
| 39 | 40 |
| 40 // Before its destruction, tells its parent container to reset its reference | 41 // Before its destruction, tells its parent container to reset its reference |
| 41 // to the ReauthDelegate. | 42 // to the UserManagerProfileDialogDelegate. |
| 42 void OnReauthDialogDestroyed(); | 43 void OnDialogDestroyed(); |
| 43 | 44 |
| 44 // views::DialogDelegate: | 45 // views::DialogDelegate: |
| 45 gfx::Size GetPreferredSize() const override; | 46 gfx::Size GetPreferredSize() const override; |
| 46 bool CanResize() const override; | 47 bool CanResize() const override; |
| 47 bool CanMaximize() const override; | 48 bool CanMaximize() const override; |
| 48 bool CanMinimize() const override; | 49 bool CanMinimize() const override; |
| 49 bool ShouldUseCustomFrame() const override; | 50 bool ShouldUseCustomFrame() const override; |
| 50 ui::ModalType GetModalType() const override; | 51 ui::ModalType GetModalType() const override; |
| 51 void DeleteDelegate() override; | 52 void DeleteDelegate() override; |
| 52 base::string16 GetWindowTitle() const override; | 53 base::string16 GetWindowTitle() const override; |
| 53 int GetDialogButtons() const override; | 54 int GetDialogButtons() const override; |
| 54 views::View* GetInitiallyFocusedView() override; | 55 views::View* GetInitiallyFocusedView() override; |
| 55 | 56 |
| 56 UserManagerView* parent_; // Not owned. | 57 UserManagerView* parent_; // Not owned. |
| 57 views::WebView* web_view_; | 58 views::WebView* web_view_; |
| 58 const std::string email_address_; | 59 const std::string email_address_; |
| 59 | 60 |
| 60 DISALLOW_COPY_AND_ASSIGN(ReauthDelegate); | 61 DISALLOW_COPY_AND_ASSIGN(UserManagerProfileDialogDelegate); |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 namespace views { | 64 namespace views { |
| 64 class WebView; | 65 class WebView; |
| 65 } | 66 } |
| 66 | 67 |
| 67 // Dialog widget that contains the Desktop User Manager webui. | 68 // Dialog widget that contains the Desktop User Manager webui. |
| 68 class UserManagerView : public views::DialogDelegateView { | 69 class UserManagerView : public views::DialogDelegateView { |
| 69 public: | 70 public: |
| 70 // Do not call directly. To display the User Manager, use UserManager::Show(). | 71 // Do not call directly. To display the User Manager, use UserManager::Show(). |
| 71 UserManagerView(); | 72 UserManagerView(); |
| 72 | 73 |
| 73 // Creates a new UserManagerView instance for the |system_profile| and shows | 74 // Creates a new UserManagerView instance for the |system_profile| and shows |
| 74 // the |url|. | 75 // the |url|. |
| 75 static void OnSystemProfileCreated(std::unique_ptr<UserManagerView> instance, | 76 static void OnSystemProfileCreated(std::unique_ptr<UserManagerView> instance, |
| 76 base::AutoReset<bool>* pending, | 77 base::AutoReset<bool>* pending, |
| 77 Profile* system_profile, | 78 Profile* system_profile, |
| 78 const std::string& url); | 79 const std::string& url); |
| 79 | 80 |
| 80 void set_user_manager_started_showing( | 81 void set_user_manager_started_showing( |
| 81 const base::Time& user_manager_started_showing) { | 82 const base::Time& user_manager_started_showing) { |
| 82 user_manager_started_showing_ = user_manager_started_showing; | 83 user_manager_started_showing_ = user_manager_started_showing; |
| 83 } | 84 } |
| 84 | 85 |
| 85 // Logs how long it took the UserManager to open. | 86 // Logs how long it took the UserManager to open. |
| 86 void LogTimeToOpen(); | 87 void LogTimeToOpen(); |
| 87 | 88 |
| 88 // Shows a dialog where the user can re-authenticate the profile with the | 89 // Hides the reauth dialog if it is showing. |
| 89 // given |email|. This is called in the following scenarios: | 90 void HideDialog(); |
| 90 // -From the user manager when a profile is locked and the user's password is | |
| 91 // detected to have been changed. | |
| 92 // -From the user manager when a custodian account needs to be | |
| 93 // reauthenticated. | |
| 94 // reason| can be REASON_UNLOCK or REASON_REAUTHENTICATION to indicate | |
| 95 // whether this is a reauth or unlock scenario. | |
| 96 void ShowReauthDialog(content::BrowserContext* browser_context, | |
| 97 const std::string& email, | |
| 98 signin_metrics::Reason reason); | |
| 99 | 91 |
| 100 // Hides the reauth dialog if it is showing. | 92 // Show a dialog where the user can auth the profile or see the auth error |
| 101 void HideReauthDialog(); | 93 // message. |
| 94 void ShowDialog(content::BrowserContext* browser_context, |
| 95 const std::string& email, |
| 96 const GURL& url); |
| 102 | 97 |
| 103 // Display sign in error message that is created by Chrome but not GAIA | 98 // Display sign in error message that is created by Chrome but not GAIA |
| 104 // without browser window. | 99 // without browser window. |
| 105 void DisplayErrorMessage(); | 100 void DisplayErrorMessage(); |
| 106 | 101 |
| 107 // Setter and getter of the path of profile which is selected in user manager | 102 // Setter and getter of the path of profile which is selected in user manager |
| 108 // for first time signin. | 103 // for first time signin. |
| 109 void SetSigninProfilePath(const base::FilePath& profile_path); | 104 void SetSigninProfilePath(const base::FilePath& profile_path); |
| 110 base::FilePath GetSigninProfilePath(); | 105 base::FilePath GetSigninProfilePath(); |
| 111 | 106 |
| 112 private: | 107 private: |
| 113 friend class ReauthDelegate; | 108 friend class UserManagerProfileDialogDelegate; |
| 114 friend std::default_delete<UserManagerView>; | 109 friend std::default_delete<UserManagerView>; |
| 115 | 110 |
| 116 ~UserManagerView() override; | 111 ~UserManagerView() override; |
| 117 | 112 |
| 118 // Resets delegate_ to nullptr when delegate_ is no longer alive. | 113 // Resets delegate_ to nullptr when delegate_ is no longer alive. |
| 119 void OnReauthDialogDestroyed(); | 114 void OnDialogDestroyed(); |
| 120 | 115 |
| 121 // Creates dialog and initializes UI. | 116 // Creates dialog and initializes UI. |
| 122 void Init(Profile* guest_profile, const GURL& url); | 117 void Init(Profile* guest_profile, const GURL& url); |
| 123 | 118 |
| 124 // views::View: | 119 // views::View: |
| 125 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 120 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 126 gfx::Size GetPreferredSize() const override; | 121 gfx::Size GetPreferredSize() const override; |
| 127 | 122 |
| 128 // views::DialogDelegateView: | 123 // views::DialogDelegateView: |
| 129 bool CanResize() const override; | 124 bool CanResize() const override; |
| 130 bool CanMaximize() const override; | 125 bool CanMaximize() const override; |
| 131 bool CanMinimize() const override; | 126 bool CanMinimize() const override; |
| 132 base::string16 GetWindowTitle() const override; | 127 base::string16 GetWindowTitle() const override; |
| 133 int GetDialogButtons() const override; | 128 int GetDialogButtons() const override; |
| 134 void WindowClosing() override; | 129 void WindowClosing() override; |
| 135 bool ShouldUseCustomFrame() const override; | 130 bool ShouldUseCustomFrame() const override; |
| 136 | 131 |
| 137 views::WebView* web_view_; | 132 views::WebView* web_view_; |
| 138 | 133 |
| 139 ReauthDelegate* delegate_; | 134 UserManagerProfileDialogDelegate* delegate_; |
| 140 | 135 |
| 141 std::unique_ptr<ScopedKeepAlive> keep_alive_; | 136 std::unique_ptr<ScopedKeepAlive> keep_alive_; |
| 142 base::Time user_manager_started_showing_; | 137 base::Time user_manager_started_showing_; |
| 143 | 138 |
| 144 base::FilePath signin_profile_path_; | 139 base::FilePath signin_profile_path_; |
| 145 | 140 |
| 146 DISALLOW_COPY_AND_ASSIGN(UserManagerView); | 141 DISALLOW_COPY_AND_ASSIGN(UserManagerView); |
| 147 }; | 142 }; |
| 148 | 143 |
| 149 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_USER_MANAGER_VIEW_H_ | 144 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_USER_MANAGER_VIEW_H_ |
| OLD | NEW |