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" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 bitmap.eraseARGB(0, 0, 0, 0); | 112 bitmap.eraseARGB(0, 0, 0, 0); |
113 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 113 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
114 } | 114 } |
115 | 115 |
116 bool HasAuthError(Profile* profile) { | 116 bool HasAuthError(Profile* profile) { |
117 const SigninErrorController* error = | 117 const SigninErrorController* error = |
118 profiles::GetSigninErrorController(profile); | 118 profiles::GetSigninErrorController(profile); |
119 return error && error->HasError(); | 119 return error && error->HasError(); |
120 } | 120 } |
121 | 121 |
122 std::string GetAuthErrorAccountId(Profile* profile) { | 122 std::string GetAuthErrorAccountId(Profile* profile) { |
Mike Lerman
2015/04/24 19:36:26
nit: it's odd at that this a helper method, while
Roger Tawa OOO till Jul 10th
2015/04/27 20:31:59
Make helper function.
| |
123 const SigninErrorController* error = | 123 const SigninErrorController* error = |
124 profiles::GetSigninErrorController(profile); | 124 profiles::GetSigninErrorController(profile); |
125 if (!error) | 125 if (!error) |
126 return std::string(); | 126 return std::string(); |
127 | 127 |
128 return error->error_account_id(); | 128 return error->error_account_id(); |
129 } | 129 } |
130 | 130 |
131 std::string GetAuthErrorUsername(Profile* profile) { | |
132 const SigninErrorController* error = | |
133 profiles::GetSigninErrorController(profile); | |
134 if (!error) | |
135 return std::string(); | |
136 | |
137 return error->error_username(); | |
138 } | |
139 | |
140 // BackgroundColorHoverButton ------------------------------------------------- | 131 // BackgroundColorHoverButton ------------------------------------------------- |
141 | 132 |
142 // A custom button that allows for setting a background color when hovered over. | 133 // A custom button that allows for setting a background color when hovered over. |
143 class BackgroundColorHoverButton : public views::LabelButton { | 134 class BackgroundColorHoverButton : public views::LabelButton { |
144 public: | 135 public: |
145 BackgroundColorHoverButton(views::ButtonListener* listener, | 136 BackgroundColorHoverButton(views::ButtonListener* listener, |
146 const base::string16& text, | 137 const base::string16& text, |
147 const gfx::ImageSkia& icon) | 138 const gfx::ImageSkia& icon) |
148 : views::LabelButton(listener, text) { | 139 : views::LabelButton(listener, text) { |
149 SetImageLabelSpacing(views::kItemLabelSpacing); | 140 SetImageLabelSpacing(views::kItemLabelSpacing); |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1482 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: | 1473 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
1483 url = signin::GetPromoURL( | 1474 url = signin::GetPromoURL( |
1484 signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT, | 1475 signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT, |
1485 false /* auto_close */, | 1476 false /* auto_close */, |
1486 true /* is_constrained */); | 1477 true /* is_constrained */); |
1487 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; | 1478 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; |
1488 break; | 1479 break; |
1489 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { | 1480 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { |
1490 DCHECK(HasAuthError(browser_->profile())); | 1481 DCHECK(HasAuthError(browser_->profile())); |
1491 url = signin::GetReauthURL(browser_->profile(), | 1482 url = signin::GetReauthURL(browser_->profile(), |
1492 GetAuthErrorUsername(browser_->profile())); | 1483 GetAuthErrorAccountId(browser_->profile())); |
1493 message_id = IDS_PROFILES_GAIA_REAUTH_TITLE; | 1484 message_id = IDS_PROFILES_GAIA_REAUTH_TITLE; |
1494 break; | 1485 break; |
1495 } | 1486 } |
1496 default: | 1487 default: |
1497 NOTREACHED() << "Called with invalid mode=" << view_mode_; | 1488 NOTREACHED() << "Called with invalid mode=" << view_mode_; |
1498 return NULL; | 1489 return NULL; |
1499 } | 1490 } |
1500 | 1491 |
1501 // Adds Gaia signin webview | 1492 // Adds Gaia signin webview |
1502 Profile* profile = browser_->profile(); | 1493 Profile* profile = browser_->profile(); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1712 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1703 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1713 IncognitoModePrefs::DISABLED; | 1704 IncognitoModePrefs::DISABLED; |
1714 return incognito_available && !browser_->profile()->IsGuestSession(); | 1705 return incognito_available && !browser_->profile()->IsGuestSession(); |
1715 } | 1706 } |
1716 | 1707 |
1717 void ProfileChooserView::PostActionPerformed( | 1708 void ProfileChooserView::PostActionPerformed( |
1718 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1709 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1719 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1710 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1720 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1711 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1721 } | 1712 } |
OLD | NEW |