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