| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 #import <Carbon/Carbon.h> // kVK_Return. | 6 #import <Carbon/Carbon.h> // kVK_Return. |
| 7 | 7 |
| 8 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 8 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
| 9 | 9 |
| 10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
| (...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: | 1204 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: |
| 1205 subView = [self buildGaiaEmbeddedView]; | 1205 subView = [self buildGaiaEmbeddedView]; |
| 1206 break; | 1206 break; |
| 1207 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: | 1207 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: |
| 1208 subView = [self buildAccountRemovalView]; | 1208 subView = [self buildAccountRemovalView]; |
| 1209 break; | 1209 break; |
| 1210 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 1210 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
| 1211 subView = [self buildSwitchUserView]; | 1211 subView = [self buildSwitchUserView]; |
| 1212 break; | 1212 break; |
| 1213 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 1213 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
| 1214 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: |
| 1214 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 1215 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
| 1215 subView = [self buildProfileChooserView]; | 1216 subView = [self buildProfileChooserView]; |
| 1216 break; | 1217 break; |
| 1217 } | 1218 } |
| 1218 | 1219 |
| 1219 // Clears tutorial mode for all non-profile-chooser views. | 1220 // Clears tutorial mode for all non-profile-chooser views. |
| 1220 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 1221 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
| 1221 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; | 1222 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
| 1222 | 1223 |
| 1223 // Add a dummy, empty element so that we don't initially display any | 1224 // Add a dummy, empty element so that we don't initially display any |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1236 - (NSView*)buildProfileChooserView { | 1237 - (NSView*)buildProfileChooserView { |
| 1237 base::scoped_nsobject<NSView> container( | 1238 base::scoped_nsobject<NSView> container( |
| 1238 [[NSView alloc] initWithFrame:NSZeroRect]); | 1239 [[NSView alloc] initWithFrame:NSZeroRect]); |
| 1239 | 1240 |
| 1240 NSView* tutorialView = nil; | 1241 NSView* tutorialView = nil; |
| 1241 NSView* currentProfileView = nil; | 1242 NSView* currentProfileView = nil; |
| 1242 base::scoped_nsobject<NSMutableArray> otherProfiles( | 1243 base::scoped_nsobject<NSMutableArray> otherProfiles( |
| 1243 [[NSMutableArray alloc] init]); | 1244 [[NSMutableArray alloc] init]); |
| 1244 // Local and guest profiles cannot lock their profile. | 1245 // Local and guest profiles cannot lock their profile. |
| 1245 bool displayLock = false; | 1246 bool displayLock = false; |
| 1247 bool isFastProfileChooser = |
| 1248 viewMode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
| 1246 | 1249 |
| 1247 // Loop over the profiles in reverse, so that they are sorted by their | 1250 // Loop over the profiles in reverse, so that they are sorted by their |
| 1248 // y-coordinate, and separate them into active and "other" profiles. | 1251 // y-coordinate, and separate them into active and "other" profiles. |
| 1249 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { | 1252 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { |
| 1250 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); | 1253 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); |
| 1251 if (item.active) { | 1254 if (item.active) { |
| 1252 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { | 1255 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { |
| 1253 switch (tutorialMode_) { | 1256 switch (tutorialMode_) { |
| 1254 case profiles::TUTORIAL_MODE_NONE: | 1257 case profiles::TUTORIAL_MODE_NONE: |
| 1255 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: | 1258 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1271 } | 1274 } |
| 1272 } | 1275 } |
| 1273 if (!currentProfileView) // Guest windows don't have an active profile. | 1276 if (!currentProfileView) // Guest windows don't have an active profile. |
| 1274 currentProfileView = [self createGuestProfileView]; | 1277 currentProfileView = [self createGuestProfileView]; |
| 1275 | 1278 |
| 1276 // |yOffset| is the next position at which to draw in |container| | 1279 // |yOffset| is the next position at which to draw in |container| |
| 1277 // coordinates. Add a pixel offset so that the bottom option buttons don't | 1280 // coordinates. Add a pixel offset so that the bottom option buttons don't |
| 1278 // overlap the bubble's rounded corners. | 1281 // overlap the bubble's rounded corners. |
| 1279 CGFloat yOffset = 1; | 1282 CGFloat yOffset = 1; |
| 1280 | 1283 |
| 1281 // Option buttons. | 1284 if (!isFastProfileChooser) { |
| 1282 NSRect rect = NSMakeRect(0, yOffset, kFixedMenuWidth, 0); | 1285 // Option buttons. |
| 1283 NSView* optionsView = [self createOptionsViewWithRect:rect | 1286 NSRect rect = NSMakeRect(0, yOffset, kFixedMenuWidth, 0); |
| 1284 displayLock:displayLock]; | 1287 NSView* optionsView = [self createOptionsViewWithRect:rect |
| 1285 [container addSubview:optionsView]; | 1288 displayLock:displayLock]; |
| 1286 rect.origin.y = NSMaxY([optionsView frame]); | 1289 [container addSubview:optionsView]; |
| 1290 rect.origin.y = NSMaxY([optionsView frame]); |
| 1287 | 1291 |
| 1288 NSBox* separator = [self horizontalSeparatorWithFrame:rect]; | 1292 NSBox* separator = [self horizontalSeparatorWithFrame:rect]; |
| 1289 [container addSubview:separator]; | 1293 [container addSubview:separator]; |
| 1290 yOffset = NSMaxY([separator frame]); | 1294 yOffset = NSMaxY([separator frame]); |
| 1295 } |
| 1291 | 1296 |
| 1292 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && | 1297 if ((viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && |
| 1293 switches::IsFastUserSwitching()) { | 1298 switches::IsFastUserSwitching()) || isFastProfileChooser) { |
| 1294 // Other profiles switcher. The profiles have already been sorted | 1299 // Other profiles switcher. The profiles have already been sorted |
| 1295 // by their y-coordinate, so they can be added in the existing order. | 1300 // by their y-coordinate, so they can be added in the existing order. |
| 1296 for (NSView *otherProfileView in otherProfiles.get()) { | 1301 for (NSView *otherProfileView in otherProfiles.get()) { |
| 1297 [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1302 [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| 1298 [container addSubview:otherProfileView]; | 1303 [container addSubview:otherProfileView]; |
| 1299 yOffset = NSMaxY([otherProfileView frame]); | 1304 yOffset = NSMaxY([otherProfileView frame]); |
| 1300 | 1305 |
| 1301 NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( | 1306 NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( |
| 1302 0, yOffset, kFixedMenuWidth, 0)]; | 1307 0, yOffset, kFixedMenuWidth, 0)]; |
| 1303 [container addSubview:separator]; | 1308 [container addSubview:separator]; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1326 [container addSubview:currentProfileAccountsView]; | 1331 [container addSubview:currentProfileAccountsView]; |
| 1327 yOffset = NSMaxY([currentProfileAccountsView frame]); | 1332 yOffset = NSMaxY([currentProfileAccountsView frame]); |
| 1328 | 1333 |
| 1329 NSBox* accountsSeparator = [self horizontalSeparatorWithFrame: | 1334 NSBox* accountsSeparator = [self horizontalSeparatorWithFrame: |
| 1330 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; | 1335 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
| 1331 [container addSubview:accountsSeparator]; | 1336 [container addSubview:accountsSeparator]; |
| 1332 yOffset = NSMaxY([accountsSeparator frame]); | 1337 yOffset = NSMaxY([accountsSeparator frame]); |
| 1333 } | 1338 } |
| 1334 | 1339 |
| 1335 // Active profile card. | 1340 // Active profile card. |
| 1336 if (currentProfileView) { | 1341 if (!isFastProfileChooser && currentProfileView) { |
| 1337 yOffset += kVerticalSpacing; | 1342 yOffset += kVerticalSpacing; |
| 1338 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1343 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| 1339 [container addSubview:currentProfileView]; | 1344 [container addSubview:currentProfileView]; |
| 1340 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; | 1345 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; |
| 1341 } | 1346 } |
| 1342 | 1347 |
| 1343 if (tutorialView) { | 1348 if (!isFastProfileChooser && tutorialView) { |
| 1344 [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1349 [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| 1345 [container addSubview:tutorialView]; | 1350 [container addSubview:tutorialView]; |
| 1346 yOffset = NSMaxY([tutorialView frame]); | 1351 yOffset = NSMaxY([tutorialView frame]); |
| 1347 //TODO(mlerman): update UMA stats for the new tutorials. | 1352 //TODO(mlerman): update UMA stats for the new tutorials. |
| 1348 } else { | 1353 } else { |
| 1349 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; | 1354 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
| 1350 } | 1355 } |
| 1351 | 1356 |
| 1352 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; | 1357 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
| 1353 return container.autorelease(); | 1358 return container.autorelease(); |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2279 } | 2284 } |
| 2280 | 2285 |
| 2281 - (bool)shouldShowGoIncognito { | 2286 - (bool)shouldShowGoIncognito { |
| 2282 bool incognitoAvailable = | 2287 bool incognitoAvailable = |
| 2283 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2288 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2284 IncognitoModePrefs::DISABLED; | 2289 IncognitoModePrefs::DISABLED; |
| 2285 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2290 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
| 2286 } | 2291 } |
| 2287 | 2292 |
| 2288 @end | 2293 @end |
| OLD | NEW |