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 "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #import "chrome/browser/app_controller_mac.h" | 9 #import "chrome/browser/app_controller_mac.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 } | 225 } |
226 | 226 |
227 - (void)closeButtonClicked:(NSButton*)button { | 227 - (void)closeButtonClicked:(NSButton*)button { |
228 [self close]; | 228 [self close]; |
229 } | 229 } |
230 | 230 |
231 - (void)close { | 231 - (void)close { |
232 constrained_window_->CloseWebContentsModalDialog(); | 232 constrained_window_->CloseWebContentsModalDialog(); |
233 } | 233 } |
234 | 234 |
235 - (void)dealloc { | |
236 //auto closeButton = [[self window] standardWindowButton:NSWindowCloseButton]; | |
237 //[closeButton setTarget:nil]; | |
groby-ooo-7-16
2015/09/12 00:42:16
Remove commented out code
anthonyvd
2015/09/14 23:59:18
oops, missed this. Thanks!
| |
238 constrained_window_->CloseWebContentsModalDialog(); | |
239 | |
240 [super dealloc]; | |
241 } | |
242 | |
235 @end | 243 @end |
236 | 244 |
237 // Window controller for the User Manager view. | 245 // Window controller for the User Manager view. |
238 @interface UserManagerWindowController : NSWindowController <NSWindowDelegate> { | 246 @interface UserManagerWindowController : NSWindowController <NSWindowDelegate> { |
239 @private | 247 @private |
240 scoped_ptr<content::WebContents> webContents_; | 248 scoped_ptr<content::WebContents> webContents_; |
241 scoped_ptr<UserManagerWebContentsDelegate> webContentsDelegate_; | 249 scoped_ptr<UserManagerWebContentsDelegate> webContentsDelegate_; |
242 UserManagerMac* userManagerObserver_; // Weak. | 250 UserManagerMac* userManagerObserver_; // Weak. |
243 scoped_ptr<UserManagerModalManagerDelegate> modal_manager_delegate_; | 251 scoped_ptr<UserManagerModalManagerDelegate> modal_manager_delegate_; |
244 base::scoped_nsobject<ReauthDialogWindowController> reauth_window_controller_; | 252 base::scoped_nsobject<ReauthDialogWindowController> reauth_window_controller_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 if ((self = [super initWithWindow:window])) { | 291 if ((self = [super initWithWindow:window])) { |
284 userManagerObserver_ = userManagerObserver; | 292 userManagerObserver_ = userManagerObserver; |
285 | 293 |
286 // Initialize the web view. | 294 // Initialize the web view. |
287 webContents_.reset(content::WebContents::Create( | 295 webContents_.reset(content::WebContents::Create( |
288 content::WebContents::CreateParams(profile))); | 296 content::WebContents::CreateParams(profile))); |
289 window.contentView = webContents_->GetNativeView(); | 297 window.contentView = webContents_->GetNativeView(); |
290 webContentsDelegate_.reset(new UserManagerWebContentsDelegate()); | 298 webContentsDelegate_.reset(new UserManagerWebContentsDelegate()); |
291 webContents_->SetDelegate(webContentsDelegate_.get()); | 299 webContents_->SetDelegate(webContentsDelegate_.get()); |
292 | 300 |
301 web_modal::WebContentsModalDialogManager::CreateForWebContents( | |
302 webContents_.get()); | |
303 modal_manager_delegate_.reset( | |
304 new UserManagerModalManagerDelegate([[self window] contentView])); | |
305 web_modal::WebContentsModalDialogManager::FromWebContents( | |
306 webContents_.get())->SetDelegate(modal_manager_delegate_.get()); | |
307 | |
293 [[NSNotificationCenter defaultCenter] | 308 [[NSNotificationCenter defaultCenter] |
294 addObserver:self | 309 addObserver:self |
295 selector:@selector(windowWillClose:) | 310 selector:@selector(windowWillClose:) |
296 name:NSWindowWillCloseNotification | 311 name:NSWindowWillCloseNotification |
297 object:self.window]; | 312 object:self.window]; |
298 } | 313 } |
299 return self; | 314 return self; |
300 } | 315 } |
301 | 316 |
302 - (void)dealloc { | 317 - (void)dealloc { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 return [[self window] isVisible]; | 359 return [[self window] isVisible]; |
345 } | 360 } |
346 | 361 |
347 - (void)windowWillClose:(NSNotification*)notification { | 362 - (void)windowWillClose:(NSNotification*)notification { |
348 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 363 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
349 DCHECK(userManagerObserver_); | 364 DCHECK(userManagerObserver_); |
350 userManagerObserver_->WindowWasClosed(); | 365 userManagerObserver_->WindowWasClosed(); |
351 } | 366 } |
352 | 367 |
353 - (void)showReauthDialogWithProfile:(Profile*)profile email:(std::string)email { | 368 - (void)showReauthDialogWithProfile:(Profile*)profile email:(std::string)email { |
354 // Make sure there's a WebContentsModalDialogManager for this UserManager's | |
355 // web contents. | |
356 web_modal::WebContentsModalDialogManager::CreateForWebContents( | |
357 webContents_.get()); | |
358 modal_manager_delegate_.reset( | |
359 new UserManagerModalManagerDelegate([[self window] contentView])); | |
360 web_modal::WebContentsModalDialogManager::FromWebContents( | |
361 webContents_.get())->SetDelegate(modal_manager_delegate_.get()); | |
362 reauth_window_controller_.reset( | 369 reauth_window_controller_.reset( |
363 [[ReauthDialogWindowController alloc] | 370 [[ReauthDialogWindowController alloc] |
364 initWithProfile:profile | 371 initWithProfile:profile |
365 email:email | 372 email:email |
366 webContents:webContents_.get()]); | 373 webContents:webContents_.get()]); |
367 } | 374 } |
368 | 375 |
369 - (void)closeReauthDialog { | 376 - (void)closeReauthDialog { |
370 [reauth_window_controller_ close]; | 377 [reauth_window_controller_ close]; |
371 } | 378 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 ProfileMetrics::LogTimeToOpenUserManager( | 473 ProfileMetrics::LogTimeToOpenUserManager( |
467 base::Time::Now() - user_manager_started_showing_); | 474 base::Time::Now() - user_manager_started_showing_); |
468 user_manager_started_showing_ = base::Time(); | 475 user_manager_started_showing_ = base::Time(); |
469 } | 476 } |
470 | 477 |
471 void UserManagerMac::WindowWasClosed() { | 478 void UserManagerMac::WindowWasClosed() { |
472 CloseReauthDialog(); | 479 CloseReauthDialog(); |
473 instance_ = NULL; | 480 instance_ = NULL; |
474 delete this; | 481 delete this; |
475 } | 482 } |
OLD | NEW |