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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 gfx::ImageSkia CreateSquarePlaceholderImage(int size) { | 92 gfx::ImageSkia CreateSquarePlaceholderImage(int size) { |
93 SkBitmap bitmap; | 93 SkBitmap bitmap; |
94 bitmap.setConfig(SkBitmap::kA8_Config, size, size); | 94 bitmap.setConfig(SkBitmap::kA8_Config, size, size); |
95 bitmap.allocPixels(); | 95 bitmap.allocPixels(); |
96 bitmap.eraseARGB(0, 0, 0, 0); | 96 bitmap.eraseARGB(0, 0, 0, 0); |
97 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 97 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
98 } | 98 } |
99 | 99 |
| 100 // Note that guest mode profiles won't have a token service. |
| 101 const SigninErrorController* GetSigninErrorController(Profile* profile) { |
| 102 const ProfileOAuth2TokenService* token_service = |
| 103 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 104 return token_service ? token_service->signin_error_controller() : NULL; |
| 105 } |
| 106 |
100 bool HasAuthError(Profile* profile) { | 107 bool HasAuthError(Profile* profile) { |
101 SigninErrorController* error = | 108 const SigninErrorController* error = GetSigninErrorController(profile); |
102 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> | |
103 signin_error_controller(); | |
104 return error && error->HasError(); | 109 return error && error->HasError(); |
105 } | 110 } |
106 | 111 |
107 std::string GetAuthErrorAccountId(Profile* profile) { | 112 std::string GetAuthErrorAccountId(Profile* profile) { |
108 SigninErrorController* error = | 113 const SigninErrorController* error = GetSigninErrorController(profile); |
109 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> | |
110 signin_error_controller(); | |
111 if (!error) | 114 if (!error) |
112 return std::string(); | 115 return std::string(); |
113 | 116 |
114 return error->error_account_id(); | 117 return error->error_account_id(); |
115 } | 118 } |
116 | 119 |
117 std::string GetAuthErrorUsername(Profile* profile) { | 120 std::string GetAuthErrorUsername(Profile* profile) { |
118 SigninErrorController* error = | 121 const SigninErrorController* error = GetSigninErrorController(profile); |
119 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> | |
120 signin_error_controller(); | |
121 if (!error) | 122 if (!error) |
122 return std::string(); | 123 return std::string(); |
123 | 124 |
124 return error->error_username(); | 125 return error->error_username(); |
125 } | 126 } |
126 | 127 |
127 // BackgroundColorHoverButton ------------------------------------------------- | 128 // BackgroundColorHoverButton ------------------------------------------------- |
128 | 129 |
129 // A custom button that allows for setting a background color when hovered over. | 130 // A custom button that allows for setting a background color when hovered over. |
130 class BackgroundColorHoverButton : public views::LabelButton { | 131 class BackgroundColorHoverButton : public views::LabelButton { |
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 layout->StartRowWithPadding( | 1402 layout->StartRowWithPadding( |
1402 1, 0, 0, views::kUnrelatedControlVerticalSpacing); | 1403 1, 0, 0, views::kUnrelatedControlVerticalSpacing); |
1403 layout->AddView(end_preview_and_relaunch_button_); | 1404 layout->AddView(end_preview_and_relaunch_button_); |
1404 | 1405 |
1405 TitleCard* title_card = new TitleCard( | 1406 TitleCard* title_card = new TitleCard( |
1406 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); | 1407 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); |
1407 return TitleCard::AddPaddedTitleCard( | 1408 return TitleCard::AddPaddedTitleCard( |
1408 view, title_card, kFixedAccountRemovalViewWidth); | 1409 view, title_card, kFixedAccountRemovalViewWidth); |
1409 } | 1410 } |
1410 | 1411 |
OLD | NEW |