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