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 off of |host_web_contents|, | |
37 // containing |web_contents|. If |wait_for_size| is true, the delegate will | |
38 // wait for ResizeNativeView() to be called by the base class before | |
39 // displaying the constrained window. Otherwise, the window's dimensions will | |
40 // be |frame|. | |
41 SigninViewControllerDelegateMac( | |
42 SigninViewController* signin_view_controller, | |
43 std::unique_ptr<content::WebContents> web_contents, | |
44 content::WebContents* host_web_contents, | |
45 NSRect frame, | |
46 bool wait_for_size); | |
47 | |
48 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override; | 37 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override; |
49 | 38 |
50 // 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 |
51 // |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 |
52 // web content's delegate. | 41 // web content's delegate. |
53 static std::unique_ptr<content::WebContents> CreateGaiaWebContents( | 42 static std::unique_ptr<content::WebContents> CreateGaiaWebContents( |
54 content::WebContentsDelegate* delegate, | 43 content::WebContentsDelegate* delegate, |
55 profiles::BubbleViewMode mode, | 44 profiles::BubbleViewMode mode, |
56 Profile* profile, | 45 Profile* profile, |
57 signin_metrics::AccessPoint access_point); | 46 signin_metrics::AccessPoint access_point); |
58 | 47 |
59 static std::unique_ptr<content::WebContents> | 48 static std::unique_ptr<content::WebContents> |
60 CreateSyncConfirmationWebContents(Profile* profile); | 49 CreateSyncConfirmationWebContents(Profile* profile); |
61 | 50 |
62 static std::unique_ptr<content::WebContents> CreateSigninErrorWebContents( | 51 static std::unique_ptr<content::WebContents> CreateSigninErrorWebContents( |
63 Profile* profile); | 52 Profile* profile); |
64 | 53 |
65 private: | 54 private: |
55 friend SigninViewControllerDelegate; | |
56 | |
57 // Creates and displays a constrained window off of |host_web_contents|, | |
58 // containing |web_contents|. If |wait_for_size| is true, the delegate will | |
59 // wait for ResizeNativeView() to be called by the base class before | |
60 // displaying the constrained window. Otherwise, the window's dimensions will | |
61 // be |frame|. | |
62 SigninViewControllerDelegateMac( | |
63 SigninViewController* signin_view_controller, | |
64 std::unique_ptr<content::WebContents> web_contents, | |
65 content::WebContents* host_web_contents, | |
66 NSRect frame, | |
67 ui::ModalType dialog_modal_type, | |
68 bool wait_for_size); | |
69 ~SigninViewControllerDelegateMac() override; | |
70 | |
66 void PerformClose() override; | 71 void PerformClose() override; |
67 void ResizeNativeView(int height) override; | 72 void ResizeNativeView(int height) override; |
68 | 73 |
69 void DisplayModal(); | 74 void DisplayModal(); |
70 | 75 |
71 void HandleKeyboardEvent( | 76 void HandleKeyboardEvent( |
72 content::WebContents* source, | 77 content::WebContents* source, |
73 const content::NativeWebKeyboardEvent& event) override; | 78 const content::NativeWebKeyboardEvent& event) override; |
74 | 79 |
75 ~SigninViewControllerDelegateMac() override; | 80 // Deletes this object. |
81 void DeleteThis(); | |
Peter Kasting
2017/01/11 19:38:29
Nit: I wonder if this should have a different name
jlebel
2017/01/12 09:51:26
Done.
| |
76 | 82 |
77 // The constrained window opened by this delegate to display signin flow | 83 // The constrained window opened by this delegate to display signin flow |
78 // content. | 84 // content. |
79 std::unique_ptr<ConstrainedWindowMac> constrained_window_; | 85 std::unique_ptr<ConstrainedWindowMac> constrained_window_; |
80 | 86 |
81 // The web contents displayed in the constrained window. | 87 // The web contents displayed in the constrained window. |
82 std::unique_ptr<content::WebContents> web_contents_; | 88 std::unique_ptr<content::WebContents> web_contents_; |
83 base::scoped_nsobject<ConstrainedWindowCustomWindow> window_; | 89 base::scoped_nsobject<ConstrainedWindowCustomWindow> window_; |
84 | 90 |
85 // wait_for_size_ stores whether the dialog should only be shown after its | 91 // 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 | 92 // content's size has been laid out and measured so that the constrained |
87 // window is sized to the content. | 93 // window is sized to the content. |
88 bool wait_for_size_; | 94 bool wait_for_size_; |
89 | 95 |
90 // The web contents that the constrained window is displayed off of. | 96 // 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. | 97 // Typically, this is going to be the active tab when the window is shown. |
92 content::WebContents* host_web_contents_; | 98 content::WebContents* host_web_contents_; |
99 | |
100 // The dialog modal presentation type. | |
101 ui::ModalType dialog_modal_type_; | |
102 | |
93 NSRect window_frame_; | 103 NSRect window_frame_; |
94 | 104 |
95 DISALLOW_COPY_AND_ASSIGN(SigninViewControllerDelegateMac); | 105 DISALLOW_COPY_AND_ASSIGN(SigninViewControllerDelegateMac); |
96 }; | 106 }; |
97 | 107 |
98 #endif // CHROME_BROWSER_UI_COCOA_PROFILES_SIGNIN_VIEW_CONTROLLER_DELEGATE_MAC_ H_ | 108 #endif // CHROME_BROWSER_UI_COCOA_PROFILES_SIGNIN_VIEW_CONTROLLER_DELEGATE_MAC_ H_ |
OLD | NEW |