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 #include "chrome/browser/ui/cocoa/profiles/user_manager_mac.h" | 5 #include "chrome/browser/ui/cocoa/profiles/user_manager_mac.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #import "chrome/browser/app_controller_mac.h" | 10 #import "chrome/browser/app_controller_mac.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 DISALLOW_COPY_AND_ASSIGN(ReauthDialogDelegate); | 160 DISALLOW_COPY_AND_ASSIGN(ReauthDialogDelegate); |
161 }; | 161 }; |
162 | 162 |
163 // WindowController for the reauth dialog. | 163 // WindowController for the reauth dialog. |
164 @interface ReauthDialogWindowController | 164 @interface ReauthDialogWindowController |
165 : NSWindowController <NSWindowDelegate> { | 165 : NSWindowController <NSWindowDelegate> { |
166 @private | 166 @private |
167 std::string emailAddress_; | 167 std::string emailAddress_; |
168 content::WebContents* webContents_; | 168 content::WebContents* webContents_; |
169 scoped_ptr<ReauthDialogDelegate> webContentsDelegate_; | 169 scoped_ptr<ReauthDialogDelegate> webContentsDelegate_; |
170 std::unique_ptr<ConstrainedWindowMac> constrained_window_; | 170 scoped_ptr<ConstrainedWindowMac> constrained_window_; |
171 scoped_ptr<content::WebContents> reauthWebContents_; | 171 scoped_ptr<content::WebContents> reauthWebContents_; |
172 } | 172 } |
173 - (id)initWithProfile:(Profile*)profile | 173 - (id)initWithProfile:(Profile*)profile |
174 email:(std::string)email | 174 email:(std::string)email |
175 webContents:(content::WebContents*)webContents; | 175 webContents:(content::WebContents*)webContents; |
176 - (void)close; | 176 - (void)close; |
177 @end | 177 @end |
178 | 178 |
179 @implementation ReauthDialogWindowController | 179 @implementation ReauthDialogWindowController |
180 | 180 |
(...skipping 15 matching lines...) Expand all Loading... |
196 reauthWebContents_.reset(content::WebContents::Create( | 196 reauthWebContents_.reset(content::WebContents::Create( |
197 content::WebContents::CreateParams(profile))); | 197 content::WebContents::CreateParams(profile))); |
198 window.get().contentView = reauthWebContents_->GetNativeView(); | 198 window.get().contentView = reauthWebContents_->GetNativeView(); |
199 webContentsDelegate_.reset( | 199 webContentsDelegate_.reset( |
200 new ReauthDialogDelegate(reauthWebContents_.get(), emailAddress_)); | 200 new ReauthDialogDelegate(reauthWebContents_.get(), emailAddress_)); |
201 reauthWebContents_->SetDelegate(webContentsDelegate_.get()); | 201 reauthWebContents_->SetDelegate(webContentsDelegate_.get()); |
202 | 202 |
203 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( | 203 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( |
204 [[CustomConstrainedWindowSheet alloc] | 204 [[CustomConstrainedWindowSheet alloc] |
205 initWithCustomWindow:[self window]]); | 205 initWithCustomWindow:[self window]]); |
206 constrained_window_ = | 206 constrained_window_.reset( |
207 CreateAndShowWebModalDialogMac( | 207 new ConstrainedWindowMac( |
208 webContentsDelegate_.get(), webContents_, sheet); | 208 webContentsDelegate_.get(), webContents_, sheet)); |
209 | 209 |
210 // The close button needs to call CloseWebContentsModalDialog() on the | 210 // The close button needs to call CloseWebContentsModalDialog() on the |
211 // constrained window isntead of just [window close] so grab a reference to | 211 // constrained window isntead of just [window close] so grab a reference to |
212 // it in the title bar and change its action. | 212 // it in the title bar and change its action. |
213 auto closeButton = [window standardWindowButton:NSWindowCloseButton]; | 213 auto closeButton = [window standardWindowButton:NSWindowCloseButton]; |
214 [closeButton setTarget:self]; | 214 [closeButton setTarget:self]; |
215 [closeButton setAction:@selector(closeButtonClicked:)]; | 215 [closeButton setAction:@selector(closeButtonClicked:)]; |
216 [self show]; | 216 [self show]; |
217 } | 217 } |
218 | 218 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 ProfileMetrics::LogTimeToOpenUserManager( | 475 ProfileMetrics::LogTimeToOpenUserManager( |
476 base::Time::Now() - user_manager_started_showing_); | 476 base::Time::Now() - user_manager_started_showing_); |
477 user_manager_started_showing_ = base::Time(); | 477 user_manager_started_showing_ = base::Time(); |
478 } | 478 } |
479 | 479 |
480 void UserManagerMac::WindowWasClosed() { | 480 void UserManagerMac::WindowWasClosed() { |
481 CloseReauthDialog(); | 481 CloseReauthDialog(); |
482 instance_ = NULL; | 482 instance_ = NULL; |
483 delete this; | 483 delete this; |
484 } | 484 } |
OLD | NEW |