| 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()) || isFastProfileChooser) { |
| 1281 // Other profiles switcher. The profiles have already been sorted | 1286 // Other profiles switcher. The profiles have already been sorted |
| 1282 // by their y-coordinate, so they can be added in the existing order. | 1287 // by their y-coordinate, so they can be added in the existing order. |
| 1283 for (NSView *otherProfileView in otherProfiles.get()) { | 1288 for (NSView *otherProfileView in otherProfiles.get()) { |
| 1284 [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1289 [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| 1285 [container addSubview:otherProfileView]; | 1290 [container addSubview:otherProfileView]; |
| 1286 yOffset = NSMaxY([otherProfileView frame]); | 1291 yOffset = NSMaxY([otherProfileView frame]); |
| 1287 | 1292 |
| 1288 NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( | 1293 NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( |
| 1289 0, yOffset, kFixedMenuWidth, 0)]; | 1294 0, yOffset, kFixedMenuWidth, 0)]; |
| 1290 [container addSubview:separator]; | 1295 [container addSubview:separator]; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1313 [container addSubview:currentProfileAccountsView]; | 1318 [container addSubview:currentProfileAccountsView]; |
| 1314 yOffset = NSMaxY([currentProfileAccountsView frame]); | 1319 yOffset = NSMaxY([currentProfileAccountsView frame]); |
| 1315 | 1320 |
| 1316 NSBox* accountsSeparator = [self horizontalSeparatorWithFrame: | 1321 NSBox* accountsSeparator = [self horizontalSeparatorWithFrame: |
| 1317 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; | 1322 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
| 1318 [container addSubview:accountsSeparator]; | 1323 [container addSubview:accountsSeparator]; |
| 1319 yOffset = NSMaxY([accountsSeparator frame]); | 1324 yOffset = NSMaxY([accountsSeparator frame]); |
| 1320 } | 1325 } |
| 1321 | 1326 |
| 1322 // Active profile card. | 1327 // Active profile card. |
| 1323 if (currentProfileView) { | 1328 if (!isFastProfileChooser && currentProfileView) { |
| 1324 yOffset += kVerticalSpacing; | 1329 yOffset += kVerticalSpacing; |
| 1325 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1330 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| 1326 [container addSubview:currentProfileView]; | 1331 [container addSubview:currentProfileView]; |
| 1327 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; | 1332 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; |
| 1328 } | 1333 } |
| 1329 | 1334 |
| 1330 if (tutorialView) { | 1335 if (!isFastProfileChooser && tutorialView) { |
| 1331 [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1336 [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| 1332 [container addSubview:tutorialView]; | 1337 [container addSubview:tutorialView]; |
| 1333 yOffset = NSMaxY([tutorialView frame]); | 1338 yOffset = NSMaxY([tutorialView frame]); |
| 1334 //TODO(mlerman): update UMA stats for the new tutorials. | 1339 //TODO(mlerman): update UMA stats for the new tutorials. |
| 1335 } else { | 1340 } else { |
| 1336 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; | 1341 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
| 1337 } | 1342 } |
| 1338 | 1343 |
| 1339 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; | 1344 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
| 1340 return container.autorelease(); | 1345 return container.autorelease(); |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2259 } | 2264 } |
| 2260 | 2265 |
| 2261 - (bool)shouldShowGoIncognito { | 2266 - (bool)shouldShowGoIncognito { |
| 2262 bool incognitoAvailable = | 2267 bool incognitoAvailable = |
| 2263 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2268 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2264 IncognitoModePrefs::DISABLED; | 2269 IncognitoModePrefs::DISABLED; |
| 2265 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2270 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
| 2266 } | 2271 } |
| 2267 | 2272 |
| 2268 @end | 2273 @end |
| OLD | NEW |