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 | 6 |
7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
8 | 8 |
9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1191 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: | 1191 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: |
1192 subView = [self buildGaiaEmbeddedView]; | 1192 subView = [self buildGaiaEmbeddedView]; |
1193 break; | 1193 break; |
1194 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: | 1194 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: |
1195 subView = [self buildAccountRemovalView]; | 1195 subView = [self buildAccountRemovalView]; |
1196 break; | 1196 break; |
1197 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 1197 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
1198 subView = [self buildSwitchUserView]; | 1198 subView = [self buildSwitchUserView]; |
1199 break; | 1199 break; |
1200 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 1200 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
1201 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: | |
1201 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 1202 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
1202 subView = [self buildProfileChooserView]; | 1203 subView = [self buildProfileChooserView]; |
1203 break; | 1204 break; |
1204 } | 1205 } |
1205 | 1206 |
1206 // Clears tutorial mode for all non-profile-chooser views. | 1207 // Clears tutorial mode for all non-profile-chooser views. |
1207 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 1208 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
1208 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; | 1209 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
1209 | 1210 |
1210 // Add a dummy, empty element so that we don't initially display any | 1211 // Add a dummy, empty element so that we don't initially display any |
(...skipping 12 matching lines...) Expand all Loading... | |
1223 - (NSView*)buildProfileChooserView { | 1224 - (NSView*)buildProfileChooserView { |
1224 base::scoped_nsobject<NSView> container( | 1225 base::scoped_nsobject<NSView> container( |
1225 [[NSView alloc] initWithFrame:NSZeroRect]); | 1226 [[NSView alloc] initWithFrame:NSZeroRect]); |
1226 | 1227 |
1227 NSView* tutorialView = nil; | 1228 NSView* tutorialView = nil; |
1228 NSView* currentProfileView = nil; | 1229 NSView* currentProfileView = nil; |
1229 base::scoped_nsobject<NSMutableArray> otherProfiles( | 1230 base::scoped_nsobject<NSMutableArray> otherProfiles( |
1230 [[NSMutableArray alloc] init]); | 1231 [[NSMutableArray alloc] init]); |
1231 // Local and guest profiles cannot lock their profile. | 1232 // Local and guest profiles cannot lock their profile. |
1232 bool displayLock = false; | 1233 bool displayLock = false; |
1234 bool isFastProfileChooser = | |
1235 viewMode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | |
1233 | 1236 |
1234 // Loop over the profiles in reverse, so that they are sorted by their | 1237 // Loop over the profiles in reverse, so that they are sorted by their |
1235 // y-coordinate, and separate them into active and "other" profiles. | 1238 // y-coordinate, and separate them into active and "other" profiles. |
1236 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { | 1239 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { |
1237 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); | 1240 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); |
1238 if (item.active) { | 1241 if (item.active) { |
1239 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { | 1242 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { |
1240 switch (tutorialMode_) { | 1243 switch (tutorialMode_) { |
1241 case profiles::TUTORIAL_MODE_NONE: | 1244 case profiles::TUTORIAL_MODE_NONE: |
1242 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: | 1245 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: |
(...skipping 15 matching lines...) Expand all Loading... | |
1258 } | 1261 } |
1259 } | 1262 } |
1260 if (!currentProfileView) // Guest windows don't have an active profile. | 1263 if (!currentProfileView) // Guest windows don't have an active profile. |
1261 currentProfileView = [self createGuestProfileView]; | 1264 currentProfileView = [self createGuestProfileView]; |
1262 | 1265 |
1263 // |yOffset| is the next position at which to draw in |container| | 1266 // |yOffset| is the next position at which to draw in |container| |
1264 // coordinates. Add a pixel offset so that the bottom option buttons don't | 1267 // coordinates. Add a pixel offset so that the bottom option buttons don't |
1265 // overlap the bubble's rounded corners. | 1268 // overlap the bubble's rounded corners. |
1266 CGFloat yOffset = 1; | 1269 CGFloat yOffset = 1; |
1267 | 1270 |
1268 // Option buttons. | 1271 if (!isFastProfileChooser) { |
1269 NSRect rect = NSMakeRect(0, yOffset, kFixedMenuWidth, 0); | 1272 // Option buttons. |
1270 NSView* optionsView = [self createOptionsViewWithRect:rect | 1273 NSRect rect = NSMakeRect(0, yOffset, kFixedMenuWidth, 0); |
1271 displayLock:displayLock]; | 1274 NSView* optionsView = [self createOptionsViewWithRect:rect |
1272 [container addSubview:optionsView]; | 1275 displayLock:displayLock]; |
1273 rect.origin.y = NSMaxY([optionsView frame]); | 1276 [container addSubview:optionsView]; |
1277 rect.origin.y = NSMaxY([optionsView frame]); | |
1274 | 1278 |
1275 NSBox* separator = [self horizontalSeparatorWithFrame:rect]; | 1279 NSBox* separator = [self horizontalSeparatorWithFrame:rect]; |
1276 [container addSubview:separator]; | 1280 [container addSubview:separator]; |
1277 yOffset = NSMaxY([separator frame]); | 1281 yOffset = NSMaxY([separator frame]); |
1282 } | |
1278 | 1283 |
1279 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && | 1284 if ((viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && |
1280 switches::IsFastUserSwitching()) { | 1285 switches::IsFastUserSwitching()) || |
1286 isFastProfileChooser) { | |
1281 // Other profiles switcher. The profiles have already been sorted | 1287 // Other profiles switcher. The profiles have already been sorted |
1282 // by their y-coordinate, so they can be added in the existing order. | 1288 // by their y-coordinate, so they can be added in the existing order. |
1283 for (NSView *otherProfileView in otherProfiles.get()) { | 1289 for (NSView *otherProfileView in otherProfiles.get()) { |
1284 [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1290 [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
1285 [container addSubview:otherProfileView]; | 1291 [container addSubview:otherProfileView]; |
1286 yOffset = NSMaxY([otherProfileView frame]); | 1292 yOffset = NSMaxY([otherProfileView frame]); |
1287 | 1293 |
1288 NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( | 1294 NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( |
1289 0, yOffset, kFixedMenuWidth, 0)]; | 1295 0, yOffset, kFixedMenuWidth, 0)]; |
1290 [container addSubview:separator]; | 1296 [container addSubview:separator]; |
(...skipping 22 matching lines...) Expand all Loading... | |
1313 [container addSubview:currentProfileAccountsView]; | 1319 [container addSubview:currentProfileAccountsView]; |
1314 yOffset = NSMaxY([currentProfileAccountsView frame]); | 1320 yOffset = NSMaxY([currentProfileAccountsView frame]); |
1315 | 1321 |
1316 NSBox* accountsSeparator = [self horizontalSeparatorWithFrame: | 1322 NSBox* accountsSeparator = [self horizontalSeparatorWithFrame: |
1317 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; | 1323 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
1318 [container addSubview:accountsSeparator]; | 1324 [container addSubview:accountsSeparator]; |
1319 yOffset = NSMaxY([accountsSeparator frame]); | 1325 yOffset = NSMaxY([accountsSeparator frame]); |
1320 } | 1326 } |
1321 | 1327 |
1322 // Active profile card. | 1328 // Active profile card. |
1323 if (currentProfileView) { | 1329 if (!isFastProfileChooser && |
1330 currentProfileView) { | |
Alexei Svitkine (slow)
2015/02/06 15:23:31
Don't wrap if it fits. Please fix throughout.
anthonyvd
2015/02/10 18:49:33
Done.
| |
1324 yOffset += kVerticalSpacing; | 1331 yOffset += kVerticalSpacing; |
1325 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1332 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
1326 [container addSubview:currentProfileView]; | 1333 [container addSubview:currentProfileView]; |
1327 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; | 1334 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; |
1328 } | 1335 } |
1329 | 1336 |
1330 if (tutorialView) { | 1337 if (!isFastProfileChooser && |
1338 tutorialView) { | |
1331 [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1339 [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; |
1332 [container addSubview:tutorialView]; | 1340 [container addSubview:tutorialView]; |
1333 yOffset = NSMaxY([tutorialView frame]); | 1341 yOffset = NSMaxY([tutorialView frame]); |
1334 //TODO(mlerman): update UMA stats for the new tutorials. | 1342 //TODO(mlerman): update UMA stats for the new tutorials. |
1335 } else { | 1343 } else { |
1336 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; | 1344 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
1337 } | 1345 } |
1338 | 1346 |
1339 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; | 1347 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
1340 return container.autorelease(); | 1348 return container.autorelease(); |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2259 } | 2267 } |
2260 | 2268 |
2261 - (bool)shouldShowGoIncognito { | 2269 - (bool)shouldShowGoIncognito { |
2262 bool incognitoAvailable = | 2270 bool incognitoAvailable = |
2263 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2271 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
2264 IncognitoModePrefs::DISABLED; | 2272 IncognitoModePrefs::DISABLED; |
2265 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2273 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
2266 } | 2274 } |
2267 | 2275 |
2268 @end | 2276 @end |
OLD | NEW |