Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: chrome/browser/ui/cocoa/profiles/user_manager_mac.mm

Issue 1320893003: Create the UserManager's Dialog Manager during init. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove commented code. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 constrained_window_->CloseWebContentsModalDialog();
237
238 [super dealloc];
239 }
240
235 @end 241 @end
236 242
237 // Window controller for the User Manager view. 243 // Window controller for the User Manager view.
238 @interface UserManagerWindowController : NSWindowController <NSWindowDelegate> { 244 @interface UserManagerWindowController : NSWindowController <NSWindowDelegate> {
239 @private 245 @private
240 scoped_ptr<content::WebContents> webContents_; 246 scoped_ptr<content::WebContents> webContents_;
241 scoped_ptr<UserManagerWebContentsDelegate> webContentsDelegate_; 247 scoped_ptr<UserManagerWebContentsDelegate> webContentsDelegate_;
242 UserManagerMac* userManagerObserver_; // Weak. 248 UserManagerMac* userManagerObserver_; // Weak.
243 scoped_ptr<UserManagerModalManagerDelegate> modal_manager_delegate_; 249 scoped_ptr<UserManagerModalManagerDelegate> modal_manager_delegate_;
244 base::scoped_nsobject<ReauthDialogWindowController> reauth_window_controller_; 250 base::scoped_nsobject<ReauthDialogWindowController> reauth_window_controller_;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if ((self = [super initWithWindow:window])) { 289 if ((self = [super initWithWindow:window])) {
284 userManagerObserver_ = userManagerObserver; 290 userManagerObserver_ = userManagerObserver;
285 291
286 // Initialize the web view. 292 // Initialize the web view.
287 webContents_.reset(content::WebContents::Create( 293 webContents_.reset(content::WebContents::Create(
288 content::WebContents::CreateParams(profile))); 294 content::WebContents::CreateParams(profile)));
289 window.contentView = webContents_->GetNativeView(); 295 window.contentView = webContents_->GetNativeView();
290 webContentsDelegate_.reset(new UserManagerWebContentsDelegate()); 296 webContentsDelegate_.reset(new UserManagerWebContentsDelegate());
291 webContents_->SetDelegate(webContentsDelegate_.get()); 297 webContents_->SetDelegate(webContentsDelegate_.get());
292 298
299 web_modal::WebContentsModalDialogManager::CreateForWebContents(
300 webContents_.get());
301 modal_manager_delegate_.reset(
302 new UserManagerModalManagerDelegate([[self window] contentView]));
303 web_modal::WebContentsModalDialogManager::FromWebContents(
304 webContents_.get())->SetDelegate(modal_manager_delegate_.get());
305
293 [[NSNotificationCenter defaultCenter] 306 [[NSNotificationCenter defaultCenter]
294 addObserver:self 307 addObserver:self
295 selector:@selector(windowWillClose:) 308 selector:@selector(windowWillClose:)
296 name:NSWindowWillCloseNotification 309 name:NSWindowWillCloseNotification
297 object:self.window]; 310 object:self.window];
298 } 311 }
299 return self; 312 return self;
300 } 313 }
301 314
302 - (void)dealloc { 315 - (void)dealloc {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return [[self window] isVisible]; 357 return [[self window] isVisible];
345 } 358 }
346 359
347 - (void)windowWillClose:(NSNotification*)notification { 360 - (void)windowWillClose:(NSNotification*)notification {
348 [[NSNotificationCenter defaultCenter] removeObserver:self]; 361 [[NSNotificationCenter defaultCenter] removeObserver:self];
349 DCHECK(userManagerObserver_); 362 DCHECK(userManagerObserver_);
350 userManagerObserver_->WindowWasClosed(); 363 userManagerObserver_->WindowWasClosed();
351 } 364 }
352 365
353 - (void)showReauthDialogWithProfile:(Profile*)profile email:(std::string)email { 366 - (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( 367 reauth_window_controller_.reset(
363 [[ReauthDialogWindowController alloc] 368 [[ReauthDialogWindowController alloc]
364 initWithProfile:profile 369 initWithProfile:profile
365 email:email 370 email:email
366 webContents:webContents_.get()]); 371 webContents:webContents_.get()]);
367 } 372 }
368 373
369 - (void)closeReauthDialog { 374 - (void)closeReauthDialog {
370 [reauth_window_controller_ close]; 375 [reauth_window_controller_ close];
371 } 376 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 ProfileMetrics::LogTimeToOpenUserManager( 471 ProfileMetrics::LogTimeToOpenUserManager(
467 base::Time::Now() - user_manager_started_showing_); 472 base::Time::Now() - user_manager_started_showing_);
468 user_manager_started_showing_ = base::Time(); 473 user_manager_started_showing_ = base::Time();
469 } 474 }
470 475
471 void UserManagerMac::WindowWasClosed() { 476 void UserManagerMac::WindowWasClosed() {
472 CloseReauthDialog(); 477 CloseReauthDialog();
473 instance_ = NULL; 478 instance_ = NULL;
474 delete this; 479 delete this;
475 } 480 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698