| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_COCOA_PROFILES_SIGNIN_VIEW_CONTROLLER_DELEGATE_MAC_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_PROFILES_SIGNIN_VIEW_CONTROLLER_DELEGATE_MAC_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_PROFILES_SIGNIN_VIEW_CONTROLLER_DELEGATE_MAC_H_ | 6 #define CHROME_BROWSER_UI_COCOA_PROFILES_SIGNIN_VIEW_CONTROLLER_DELEGATE_MAC_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" | |
| 13 #include "chrome/browser/ui/profile_chooser_constants.h" | 12 #include "chrome/browser/ui/profile_chooser_constants.h" |
| 14 #include "chrome/browser/ui/signin_view_controller_delegate.h" | 13 #include "chrome/browser/ui/signin_view_controller_delegate.h" |
| 15 | 14 |
| 16 @class ConstrainedWindowCustomWindow; | 15 @class ConstrainedWindowCustomWindow; |
| 17 class ConstrainedWindowMac; | |
| 18 class Profile; | 16 class Profile; |
| 19 | 17 |
| 20 namespace content { | 18 namespace content { |
| 21 class WebContents; | 19 class WebContents; |
| 22 class WebContentsDelegate; | 20 class WebContentsDelegate; |
| 23 } | 21 } |
| 24 | 22 |
| 25 namespace signin_metrics { | 23 namespace signin_metrics { |
| 26 enum class AccessPoint; | 24 enum class AccessPoint; |
| 27 } | 25 } |
| 28 | 26 |
| 29 // Cocoa implementation of SigninViewControllerDelegate. It's responsible for | 27 // Cocoa implementation of SigninViewControllerDelegate. It's responsible for |
| 30 // managing the Signin and Sync Confirmation tab-modal dialogs. | 28 // managing the Signin and Sync Confirmation tab-modal dialogs. |
| 31 // Instances of this class delete themselves when the window they manage is | 29 // Instances of this class delete themselves when the window they manage is |
| 32 // closed (in the OnConstrainedWindowClosed callback). | 30 // closed (in the OnConstrainedWindowClosed callback). |
| 33 class SigninViewControllerDelegateMac : public ConstrainedWindowMacDelegate, | 31 class SigninViewControllerDelegateMac : public SigninViewControllerDelegate { |
| 34 public SigninViewControllerDelegate { | |
| 35 public: | 32 public: |
| 36 // Creates and displays a constrained window off of |host_web_contents|, | 33 // Creates and displays a constrained window off of |host_web_contents|, |
| 37 // containing |web_contents|. If |wait_for_size| is true, the delegate will | 34 // containing |web_contents|. If |wait_for_size| is true, the delegate will |
| 38 // wait for ResizeNativeView() to be called by the base class before | 35 // wait for ResizeNativeView() to be called by the base class before |
| 39 // displaying the constrained window. Otherwise, the window's dimensions will | 36 // displaying the constrained window. Otherwise, the window's dimensions will |
| 40 // be |frame|. | 37 // be |frame|. |
| 41 SigninViewControllerDelegateMac( | 38 SigninViewControllerDelegateMac( |
| 42 SigninViewController* signin_view_controller, | 39 SigninViewController* signin_view_controller, |
| 43 std::unique_ptr<content::WebContents> web_contents, | 40 std::unique_ptr<content::WebContents> web_contents, |
| 44 content::WebContents* host_web_contents, | 41 content::WebContents* host_web_contents, |
| 45 NSRect frame, | 42 NSRect frame, |
| 46 bool wait_for_size); | 43 bool wait_for_size); |
| 47 | 44 |
| 48 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override; | |
| 49 | |
| 50 // Creates the web view that contains the signin flow in |mode| using | 45 // Creates the web view that contains the signin flow in |mode| using |
| 51 // |profile| as the web content's profile, then sets |delegate| as the created | 46 // |profile| as the web content's profile, then sets |delegate| as the created |
| 52 // web content's delegate. | 47 // web content's delegate. |
| 53 static std::unique_ptr<content::WebContents> CreateGaiaWebContents( | 48 static std::unique_ptr<content::WebContents> CreateGaiaWebContents( |
| 54 content::WebContentsDelegate* delegate, | 49 content::WebContentsDelegate* delegate, |
| 55 profiles::BubbleViewMode mode, | 50 profiles::BubbleViewMode mode, |
| 56 Profile* profile, | 51 Profile* profile, |
| 57 signin_metrics::AccessPoint access_point); | 52 signin_metrics::AccessPoint access_point); |
| 58 | 53 |
| 59 static std::unique_ptr<content::WebContents> | 54 static std::unique_ptr<content::WebContents> |
| 60 CreateSyncConfirmationWebContents(Profile* profile); | 55 CreateSyncConfirmationWebContents(Profile* profile); |
| 61 | 56 |
| 62 static std::unique_ptr<content::WebContents> CreateSigninErrorWebContents( | 57 static std::unique_ptr<content::WebContents> CreateSigninErrorWebContents( |
| 63 Profile* profile); | 58 Profile* profile); |
| 64 | 59 |
| 65 private: | 60 private: |
| 66 void PerformClose() override; | 61 void PerformClose() override; |
| 67 void ResizeNativeView(int height) override; | 62 void ResizeNativeView(int height) override; |
| 68 | 63 |
| 69 void DisplayModal(); | 64 void DisplayModal(); |
| 70 | 65 |
| 71 void HandleKeyboardEvent( | 66 void HandleKeyboardEvent( |
| 72 content::WebContents* source, | 67 content::WebContents* source, |
| 73 const content::NativeWebKeyboardEvent& event) override; | 68 const content::NativeWebKeyboardEvent& event) override; |
| 74 | 69 |
| 75 ~SigninViewControllerDelegateMac() override; | 70 ~SigninViewControllerDelegateMac() override; |
| 76 | 71 |
| 77 // The constrained window opened by this delegate to display signin flow | |
| 78 // content. | |
| 79 std::unique_ptr<ConstrainedWindowMac> constrained_window_; | |
| 80 | |
| 81 // The web contents displayed in the constrained window. | 72 // The web contents displayed in the constrained window. |
| 82 std::unique_ptr<content::WebContents> web_contents_; | 73 std::unique_ptr<content::WebContents> web_contents_; |
| 83 base::scoped_nsobject<ConstrainedWindowCustomWindow> window_; | 74 base::scoped_nsobject<ConstrainedWindowCustomWindow> window_; |
| 84 | 75 |
| 85 // wait_for_size_ stores whether the dialog should only be shown after its | 76 // wait_for_size_ stores whether the dialog should only be shown after its |
| 86 // content's size has been laid out and measured so that the constrained | 77 // content's size has been laid out and measured so that the constrained |
| 87 // window is sized to the content. | 78 // window is sized to the content. |
| 88 bool wait_for_size_; | 79 bool wait_for_size_; |
| 89 | 80 |
| 90 // The web contents that the constrained window is displayed off of. | 81 // The web contents that the constrained window is displayed off of. |
| 91 // Typically, this is going to be the active tab when the window is shown. | 82 // Typically, this is going to be the active tab when the window is shown. |
| 92 content::WebContents* host_web_contents_; | 83 content::WebContents* host_web_contents_; |
| 93 NSRect window_frame_; | 84 NSRect window_frame_; |
| 94 | 85 |
| 95 DISALLOW_COPY_AND_ASSIGN(SigninViewControllerDelegateMac); | 86 DISALLOW_COPY_AND_ASSIGN(SigninViewControllerDelegateMac); |
| 96 }; | 87 }; |
| 97 | 88 |
| 98 #endif // CHROME_BROWSER_UI_COCOA_PROFILES_SIGNIN_VIEW_CONTROLLER_DELEGATE_MAC_
H_ | 89 #endif // CHROME_BROWSER_UI_COCOA_PROFILES_SIGNIN_VIEW_CONTROLLER_DELEGATE_MAC_
H_ |
| OLD | NEW |