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

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

Issue 504893002: [Mac] User manager should open on the screen that has focus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2125
Patch Set: Created 6 years, 4 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 "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/ui/browser_dialogs.h" 10 #include "chrome/browser/ui/browser_dialogs.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 - (void)show; 85 - (void)show;
86 - (void)close; 86 - (void)close;
87 - (BOOL)isVisible; 87 - (BOOL)isVisible;
88 @end 88 @end
89 89
90 @implementation UserManagerWindowController 90 @implementation UserManagerWindowController
91 91
92 - (id)initWithProfile:(Profile*)profile 92 - (id)initWithProfile:(Profile*)profile
93 withObserver:(UserManagerMac*)userManagerObserver { 93 withObserver:(UserManagerMac*)userManagerObserver {
94 94
95 // Center the window on the primary screen. 95 // Center the window on the screen that currently has focus.
96 CGFloat screenHeight = 96 NSScreen* mainScreen = [NSScreen mainScreen];
97 [[[NSScreen screens] objectAtIndex:0] frame].size.height; 97 CGFloat screenHeight = [mainScreen frame].size.height;
98 CGFloat screenWidth = 98 CGFloat screenWidth = [mainScreen frame].size.width;
99 [[[NSScreen screens] objectAtIndex:0] frame].size.width;
100 99
101 NSRect contentRect = NSMakeRect((screenWidth - kWindowWidth) / 2, 100 NSRect contentRect = NSMakeRect((screenWidth - kWindowWidth) / 2,
102 (screenHeight - kWindowHeight) / 2, 101 (screenHeight - kWindowHeight) / 2,
103 kWindowWidth, kWindowHeight); 102 kWindowWidth, kWindowHeight);
104 ChromeEventProcessingWindow* window = [[ChromeEventProcessingWindow alloc] 103 ChromeEventProcessingWindow* window = [[ChromeEventProcessingWindow alloc]
105 initWithContentRect:contentRect 104 initWithContentRect:contentRect
106 styleMask:NSTitledWindowMask | 105 styleMask:NSTitledWindowMask |
107 NSClosableWindowMask | 106 NSClosableWindowMask |
108 NSResizableWindowMask 107 NSResizableWindowMask
109 backing:NSBackingStoreBuffered 108 backing:NSBackingStoreBuffered
110 defer:NO]; 109 defer:NO
110 screen:mainScreen];
111 [window setTitle:l10n_util::GetNSString(IDS_PRODUCT_NAME)]; 111 [window setTitle:l10n_util::GetNSString(IDS_PRODUCT_NAME)];
112 [window setMinSize:NSMakeSize(kWindowWidth, kWindowHeight)]; 112 [window setMinSize:NSMakeSize(kWindowWidth, kWindowHeight)];
113 113
114 if ((self = [super initWithWindow:window])) { 114 if ((self = [super initWithWindow:window])) {
115 userManagerObserver_ = userManagerObserver; 115 userManagerObserver_ = userManagerObserver;
116 116
117 // Initialize the web view. 117 // Initialize the web view.
118 webContents_.reset(content::WebContents::Create( 118 webContents_.reset(content::WebContents::Create(
119 content::WebContents::CreateParams(profile))); 119 content::WebContents::CreateParams(profile)));
120 window.contentView = webContents_->GetNativeView(); 120 window.contentView = webContents_->GetNativeView();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void UserManagerMac::OnGuestProfileCreated(Profile* guest_profile, 206 void UserManagerMac::OnGuestProfileCreated(Profile* guest_profile,
207 const std::string& url) { 207 const std::string& url) {
208 instance_ = new UserManagerMac(guest_profile); 208 instance_ = new UserManagerMac(guest_profile);
209 [instance_->window_controller_ showURL:GURL(url)]; 209 [instance_->window_controller_ showURL:GURL(url)];
210 } 210 }
211 211
212 void UserManagerMac::WindowWasClosed() { 212 void UserManagerMac::WindowWasClosed() {
213 instance_ = NULL; 213 instance_ = NULL;
214 delete this; 214 delete this;
215 } 215 }
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