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/profile_oauth2_token_service_factory.h" | 18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 19 #include "chrome/browser/signin/signin_error_controller_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" |
28 #include "chrome/browser/ui/user_manager.h" | 29 #include "chrome/browser/ui/user_manager.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 109 |
109 gfx::ImageSkia CreateSquarePlaceholderImage(int size) { | 110 gfx::ImageSkia CreateSquarePlaceholderImage(int size) { |
110 SkBitmap bitmap; | 111 SkBitmap bitmap; |
111 bitmap.allocPixels(SkImageInfo::MakeA8(size, size)); | 112 bitmap.allocPixels(SkImageInfo::MakeA8(size, size)); |
112 bitmap.eraseARGB(0, 0, 0, 0); | 113 bitmap.eraseARGB(0, 0, 0, 0); |
113 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 114 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
114 } | 115 } |
115 | 116 |
116 bool HasAuthError(Profile* profile) { | 117 bool HasAuthError(Profile* profile) { |
117 const SigninErrorController* error = | 118 const SigninErrorController* error = |
118 profiles::GetSigninErrorController(profile); | 119 SigninErrorControllerFactory::GetForProfile(profile); |
119 return error && error->HasError(); | 120 return error && error->HasError(); |
120 } | 121 } |
121 | 122 |
122 std::string GetAuthErrorAccountId(Profile* profile) { | 123 std::string GetAuthErrorAccountId(Profile* profile) { |
123 const SigninErrorController* error = | 124 const SigninErrorController* error = |
124 profiles::GetSigninErrorController(profile); | 125 SigninErrorControllerFactory::GetForProfile(profile); |
125 if (!error) | 126 if (!error) |
126 return std::string(); | 127 return std::string(); |
127 | 128 |
128 return error->error_account_id(); | 129 return error->error_account_id(); |
129 } | 130 } |
130 | 131 |
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 ------------------------------------------------- | 132 // BackgroundColorHoverButton ------------------------------------------------- |
141 | 133 |
142 // A custom button that allows for setting a background color when hovered over. | 134 // A custom button that allows for setting a background color when hovered over. |
143 class BackgroundColorHoverButton : public views::LabelButton { | 135 class BackgroundColorHoverButton : public views::LabelButton { |
144 public: | 136 public: |
145 BackgroundColorHoverButton(views::ButtonListener* listener, | 137 BackgroundColorHoverButton(views::ButtonListener* listener, |
146 const base::string16& text, | 138 const base::string16& text, |
147 const gfx::ImageSkia& icon) | 139 const gfx::ImageSkia& icon) |
148 : views::LabelButton(listener, text) { | 140 : views::LabelButton(listener, text) { |
149 SetImageLabelSpacing(views::kItemLabelSpacing); | 141 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: | 1474 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
1483 url = signin::GetPromoURL( | 1475 url = signin::GetPromoURL( |
1484 signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT, | 1476 signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT, |
1485 false /* auto_close */, | 1477 false /* auto_close */, |
1486 true /* is_constrained */); | 1478 true /* is_constrained */); |
1487 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; | 1479 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; |
1488 break; | 1480 break; |
1489 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { | 1481 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { |
1490 DCHECK(HasAuthError(browser_->profile())); | 1482 DCHECK(HasAuthError(browser_->profile())); |
1491 url = signin::GetReauthURL(browser_->profile(), | 1483 url = signin::GetReauthURL(browser_->profile(), |
1492 GetAuthErrorUsername(browser_->profile())); | 1484 GetAuthErrorAccountId(browser_->profile())); |
1493 message_id = IDS_PROFILES_GAIA_REAUTH_TITLE; | 1485 message_id = IDS_PROFILES_GAIA_REAUTH_TITLE; |
1494 break; | 1486 break; |
1495 } | 1487 } |
1496 default: | 1488 default: |
1497 NOTREACHED() << "Called with invalid mode=" << view_mode_; | 1489 NOTREACHED() << "Called with invalid mode=" << view_mode_; |
1498 return NULL; | 1490 return NULL; |
1499 } | 1491 } |
1500 | 1492 |
1501 // Adds Gaia signin webview | 1493 // Adds Gaia signin webview |
1502 Profile* profile = browser_->profile(); | 1494 Profile* profile = browser_->profile(); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1704 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1713 IncognitoModePrefs::DISABLED; | 1705 IncognitoModePrefs::DISABLED; |
1714 return incognito_available && !browser_->profile()->IsGuestSession(); | 1706 return incognito_available && !browser_->profile()->IsGuestSession(); |
1715 } | 1707 } |
1716 | 1708 |
1717 void ProfileChooserView::PostActionPerformed( | 1709 void ProfileChooserView::PostActionPerformed( |
1718 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1710 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1719 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1711 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1720 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1712 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1721 } | 1713 } |
OLD | NEW |