Chromium Code Reviews| Index: chrome/browser/ui/webui/signin/signin_error_ui.cc |
| diff --git a/chrome/browser/ui/webui/signin/signin_error_ui.cc b/chrome/browser/ui/webui/signin/signin_error_ui.cc |
| index 4277842d94742faa643a6ceaba160d2d9b5142f7..3ff5c535f43163aad1e12fb26d9171c16ab07995 100644 |
| --- a/chrome/browser/ui/webui/signin/signin_error_ui.cc |
| +++ b/chrome/browser/ui/webui/signin/signin_error_ui.cc |
| @@ -4,12 +4,15 @@ |
| #include "chrome/browser/ui/webui/signin/signin_error_ui.h" |
| +#include <vector> |
| + |
| #include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/profiles/profile_attributes_entry.h" |
| #include "chrome/browser/profiles/profile_attributes_storage.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/ui/browser_window.h" |
| +#include "chrome/browser/ui/user_manager.h" |
| #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| #include "chrome/browser/ui/webui/signin/signin_error_handler.h" |
| @@ -22,23 +25,47 @@ |
| #include "ui/base/webui/web_ui_util.h" |
| #include "ui/gfx/text_elider.h" |
| +namespace { |
| +bool IsSystemProfile(Profile* profile) { |
| + return profile->GetOriginalProfile()->IsSystemProfile(); |
| +} |
| +} // namespace |
| + |
| SigninErrorUI::SigninErrorUI(content::WebUI* web_ui) |
| - : SigninErrorUI(web_ui, new SigninErrorHandler) {} |
| + : SigninErrorUI( |
| + web_ui, |
| + new SigninErrorHandler(IsSystemProfile(Profile::FromWebUI(web_ui)))) { |
| +} |
| SigninErrorUI::SigninErrorUI(content::WebUI* web_ui, |
| SigninErrorHandler* handler) |
| : WebDialogUI(web_ui) { |
| - Profile* profile = Profile::FromWebUI(web_ui); |
| + Profile* webui_profile = Profile::FromWebUI(web_ui); |
| + Profile* signin_profile; |
| + bool is_system_profile = IsSystemProfile(webui_profile); |
| + |
| +#if !defined(OS_MACOSX) |
|
tommycli
2016/09/21 21:26:16
Please add a TODO with an explanation about the se
zmin
2016/09/21 21:52:05
Done.
|
| + if (is_system_profile) { |
| + signin_profile = g_browser_process->profile_manager()->GetProfileByPath( |
| + UserManager::GetSigninProfilePath()); |
| + } else { |
| + signin_profile = webui_profile; |
| + } |
| +#else |
| + signin_profile = webui_profile; |
| +#endif |
| + |
| content::WebUIDataSource* source = |
| content::WebUIDataSource::Create(chrome::kChromeUISigninErrorHost); |
| source->SetJsonPath("strings.js"); |
| source->SetDefaultResource(IDR_SIGNIN_ERROR_HTML); |
| source->AddResourcePath("signin_error.js", IDR_SIGNIN_ERROR_JS); |
| source->AddResourcePath("signin_shared_css.html", IDR_SIGNIN_SHARED_CSS_HTML); |
| + source->AddBoolean("isSystemProfile", is_system_profile); |
| // Retrieve the last signin error message and email used. |
| LoginUIService* login_ui_service = |
| - LoginUIServiceFactory::GetForProfile(profile); |
| + LoginUIServiceFactory::GetForProfile(signin_profile); |
| const base::string16 last_login_result( |
| login_ui_service->GetLastLoginResult()); |
| const base::string16 email = login_ui_service->GetLastLoginErrorEmail(); |
| @@ -51,9 +78,10 @@ SigninErrorUI::SigninErrorUI(content::WebUI* web_ui, |
| } |
| // Tweak the dialog UI depending on whether the signin error is |
| - // username-in-use error. |
| + // username-in-use error and the error UI is shown with a browser window. |
| base::string16 existing_name; |
| - if (last_login_result.compare( |
| + if (!is_system_profile && |
| + last_login_result.compare( |
| l10n_util::GetStringUTF16(IDS_SYNC_USER_NAME_IN_USE_ERROR)) == 0) { |
| ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| if (profile_manager) { |
| @@ -99,6 +127,6 @@ SigninErrorUI::SigninErrorUI(content::WebUI* web_ui, |
| &strings); |
| source->AddLocalizedStrings(strings); |
| - content::WebUIDataSource::Add(profile, source); |
| + content::WebUIDataSource::Add(webui_profile, source); |
| web_ui->AddMessageHandler(handler); |
| } |