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 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" | 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/lifetime/application_lifetime.h" | 10 #include "chrome/browser/lifetime/application_lifetime.h" |
11 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 11 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
12 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 12 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
13 #include "chrome/browser/profiles/profile_info_cache.h" | 13 #include "chrome/browser/profiles/profile_info_cache.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/profiles/profile_metrics.h" | 15 #include "chrome/browser/profiles/profile_metrics.h" |
16 #include "chrome/browser/profiles/profile_window.h" | 16 #include "chrome/browser/profiles/profile_window.h" |
17 #include "chrome/browser/profiles/profiles_state.h" | 17 #include "chrome/browser/profiles/profiles_state.h" |
18 #include "chrome/browser/signin/local_auth.h" | |
18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
19 #include "chrome/browser/signin/signin_header_helper.h" | 20 #include "chrome/browser/signin/signin_header_helper.h" |
20 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
21 #include "chrome/browser/signin/signin_promo.h" | 22 #include "chrome/browser/signin/signin_promo.h" |
22 #include "chrome/browser/signin/signin_ui_util.h" | 23 #include "chrome/browser/signin/signin_ui_util.h" |
23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_commands.h" | 25 #include "chrome/browser/ui/browser_commands.h" |
25 #include "chrome/browser/ui/browser_dialogs.h" | 26 #include "chrome/browser/ui/browser_dialogs.h" |
26 #include "chrome/browser/ui/chrome_pages.h" | 27 #include "chrome/browser/ui/chrome_pages.h" |
27 #include "chrome/browser/ui/singleton_tabs.h" | 28 #include "chrome/browser/ui/singleton_tabs.h" |
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1235 | 1236 |
1236 layout->StartRow(1, 0); | 1237 layout->StartRow(1, 0); |
1237 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1238 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1238 layout->StartRow(1, 0); | 1239 layout->StartRow(1, 0); |
1239 layout->AddView(button); | 1240 layout->AddView(button); |
1240 } | 1241 } |
1241 | 1242 |
1242 return view; | 1243 return view; |
1243 } | 1244 } |
1244 | 1245 |
1245 views::View* ProfileChooserView::CreateOptionsView(bool enable_lock) { | 1246 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { |
1246 views::View* view = new views::View(); | 1247 views::View* view = new views::View(); |
1247 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1248 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
1248 | 1249 |
1249 base::string16 text = browser_->profile()->IsGuestSession() ? | 1250 base::string16 text = browser_->profile()->IsGuestSession() ? |
1250 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : | 1251 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : |
1251 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); | 1252 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); |
1252 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1253 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
1253 users_button_ = new BackgroundColorHoverButton( | 1254 users_button_ = new BackgroundColorHoverButton( |
1254 this, | 1255 this, |
1255 text, | 1256 text, |
1256 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_AVATAR)); | 1257 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_AVATAR)); |
1257 layout->StartRow(1, 0); | 1258 layout->StartRow(1, 0); |
1258 layout->AddView(users_button_); | 1259 layout->AddView(users_button_); |
1259 | 1260 |
1260 if (ShouldShowGoIncognito()) { | 1261 if (ShouldShowGoIncognito()) { |
1261 layout->StartRow(1, 0); | 1262 layout->StartRow(1, 0); |
1262 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1263 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1263 | 1264 |
1264 go_incognito_button_ = new BackgroundColorHoverButton( | 1265 go_incognito_button_ = new BackgroundColorHoverButton( |
1265 this, | 1266 this, |
1266 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), | 1267 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), |
1267 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); | 1268 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); |
1268 layout->StartRow(1, 0); | 1269 layout->StartRow(1, 0); |
1269 layout->AddView(go_incognito_button_); | 1270 layout->AddView(go_incognito_button_); |
1270 } | 1271 } |
1271 | 1272 |
1272 if (enable_lock) { | 1273 if (display_lock) { |
1274 bool enable_lock = chrome::LocalAuthCredentialsExist(browser_->profile()); | |
msw
2014/08/22 21:46:49
ditto nit: move down to if statement below (and in
Mike Lerman
2014/08/25 14:44:31
Done, though... I've always liked this form of ess
msw
2014/08/25 17:39:55
If you only use something in an if statement, ther
Mike Lerman
2014/08/25 18:11:37
Okie. Already done.
| |
1275 | |
1273 layout->StartRow(1, 0); | 1276 layout->StartRow(1, 0); |
1274 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1277 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1275 | 1278 |
1276 lock_button_ = new BackgroundColorHoverButton( | 1279 lock_button_ = new BackgroundColorHoverButton( |
1277 this, | 1280 this, |
1278 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), | 1281 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), |
1279 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_LOCK)); | 1282 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_LOCK)); |
1283 if (!enable_lock) | |
1284 lock_button_->SetState(views::Button::STATE_DISABLED); | |
1280 layout->StartRow(1, 0); | 1285 layout->StartRow(1, 0); |
1281 layout->AddView(lock_button_); | 1286 layout->AddView(lock_button_); |
1282 } | 1287 } |
1283 return view; | 1288 return view; |
1284 } | 1289 } |
1285 | 1290 |
1286 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { | 1291 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
1287 views::View* view = new views::View(); | 1292 views::View* view = new views::View(); |
1288 views::GridLayout* layout = CreateSingleColumnLayout( | 1293 views::GridLayout* layout = CreateSingleColumnLayout( |
1289 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1294 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1635 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1640 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1636 IncognitoModePrefs::DISABLED; | 1641 IncognitoModePrefs::DISABLED; |
1637 return incognito_available && !browser_->profile()->IsGuestSession(); | 1642 return incognito_available && !browser_->profile()->IsGuestSession(); |
1638 } | 1643 } |
1639 | 1644 |
1640 void ProfileChooserView::PostActionPerformed( | 1645 void ProfileChooserView::PostActionPerformed( |
1641 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1646 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1642 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1647 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1643 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1648 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1644 } | 1649 } |
OLD | NEW |