Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4987)

Unified Diff: chrome/browser/ui/webui/signin/signin_error_ui.cc

Issue 2351173004: Display local signin error without browser and record the path of selected profile in user manager. (Closed)
Patch Set: cr+fix trybot Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c402ac88d1a062129dcaa7467489b302f2c50548 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,41 @@
#include "ui/base/webui/web_ui_util.h"
#include "ui/gfx/text_elider.h"
+namespace {
+bool IsSystemProfile(Profile* profile) {
+ return profile->GetOriginalProfile()->IsSystemProfile();
+}
+} // namespace
tommycli 2016/09/21 18:26:59 nit: I don't think this shortening is worth it. It
zmin 2016/09/21 21:21:37 Why not? That is still a code copy.
tommycli 2016/09/21 21:26:16 I think since it's so short, it would be easier to
zmin 2016/09/21 21:52:05 Done.
+
SigninErrorUI::SigninErrorUI(content::WebUI* web_ui)
- : SigninErrorUI(web_ui, new SigninErrorHandler) {}
+ : SigninErrorUI(web_ui,
+ SigninErrorHandler::Create(
+ 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 (is_system_profile) {
tommycli 2016/09/21 18:26:59 nit: Maybe clearer with a ternary expression? Not
zmin 2016/09/21 21:21:37 I'm personally not a fan of ternary expression. Es
tommycli 2016/09/21 21:26:15 Acknowledged.
+ signin_profile = g_browser_process->profile_manager()->GetProfileByPath(
+ UserManager::GetSigninProfilePath());
+ } else {
+ signin_profile = webui_profile;
+ }
+
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 +72,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 +121,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);
}

Powered by Google App Engine
This is Rietveld 408576698