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

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

Issue 1630903002: material design user manager with create profile flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed the comments Created 4 years, 11 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/md_user_manager_ui.cc
diff --git a/chrome/browser/ui/webui/signin/md_user_manager_ui.cc b/chrome/browser/ui/webui/signin/md_user_manager_ui.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e80de273333c0d3e69eb13c8dfc0ddb090a3461a
--- /dev/null
+++ b/chrome/browser/ui/webui/signin/md_user_manager_ui.cc
@@ -0,0 +1,102 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
tommycli 2016/02/03 01:13:22 Try using --similarity=40 or lower so git cl uploa
Moe 2016/02/05 17:58:39 Thanks for the tip!
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/signin/md_user_manager_ui.h"
+
+#include "base/values.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/signin/signin_create_profile_handler.h"
+#include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h"
+#include "chrome/browser/ui/webui/theme_source.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "grit/browser_resources.h"
+#include "grit/settings_resources.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/webui/web_ui_util.h"
+
+MDUserManagerUI::MDUserManagerUI(content::WebUI* web_ui)
+ : WebUIController(web_ui) {
+ // The web_ui object takes ownership of the handler, and will
+ // destroy it when it (the WebUI) is destroyed.
+ user_manager_screen_handler_ = new UserManagerScreenHandler();
+ signin_create_profile_handler_ = new SigninCreateProfileHandler();
+ web_ui->AddMessageHandler(user_manager_screen_handler_);
+ web_ui->AddMessageHandler(signin_create_profile_handler_);
+
+ base::DictionaryValue localized_strings;
+ GetLocalizedStrings(&localized_strings);
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ // Set up the chrome://user-chooser/ source.
+ content::WebUIDataSource::Add(profile, CreateUIDataSource(localized_strings));
+
+#if defined(ENABLE_THEMES)
+ // Set up the chrome://theme/ source
+ ThemeSource* theme = new ThemeSource(profile);
+ content::URLDataSource::Add(profile, theme);
+#endif
+}
+
+MDUserManagerUI::~MDUserManagerUI() {
+}
+
+content::WebUIDataSource* MDUserManagerUI::CreateUIDataSource(
+ const base::DictionaryValue& localized_strings) {
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUIMDUserManagerHost);
+ source->AddLocalizedStrings(localized_strings);
+ source->SetJsonPath("strings.js");
+
+ source->AddResourcePath("control_bar.css", IDR_MD_CONTROL_BAR_CSS);
+ source->AddResourcePath("control_bar.html", IDR_MD_CONTROL_BAR_HTML);
+ source->AddResourcePath("control_bar.js", IDR_MD_CONTROL_BAR_JS);
+ source->AddResourcePath("create_profile.css", IDR_MD_CREATE_PROFILE_CSS);
+ source->AddResourcePath("create_profile.html", IDR_MD_CREATE_PROFILE_HTML);
+ source->AddResourcePath("create_profile.js", IDR_MD_CREATE_PROFILE_JS);
+ source->AddResourcePath("profile_api.html", IDR_MD_PROFILE_API_HTML);
+ source->AddResourcePath("profile_api.js", IDR_MD_PROFILE_API_JS);
+ source->AddResourcePath("strings.html", IDR_MD_USER_MANAGER_STRINGS_HTML);
+ source->AddResourcePath("supervised_user_learn_more.css",
+ IDR_MD_SUPERVISED_USER_LEARN_MORE_CSS);
+ source->AddResourcePath("supervised_user_learn_more.html",
+ IDR_MD_SUPERVISED_USER_LEARN_MORE_HTML);
+ source->AddResourcePath("supervised_user_learn_more.js",
+ IDR_MD_SUPERVISED_USER_LEARN_MORE_JS);
+ source->AddResourcePath("user_manager.css", IDR_MD_USER_MANAGER_CSS);
+ source->AddResourcePath("user_manager.js", IDR_MD_USER_MANAGER_JS);
+ source->AddResourcePath("user_manager_pages.css",
+ IDR_MD_USER_MANAGER_PAGES_CSS);
+ source->AddResourcePath("user_manager_pages.html",
+ IDR_MD_USER_MANAGER_PAGES_HTML);
+ source->AddResourcePath("user_manager_pages.js",
+ IDR_MD_USER_MANAGER_PAGES_JS);
+ source->AddResourcePath("user_manager_tutorial.css",
+ IDR_MD_USER_MANAGER_TUTORIAL_CSS);
+ source->AddResourcePath("user_manager_tutorial.html",
+ IDR_MD_USER_MANAGER_TUTORIAL_HTML);
+ source->AddResourcePath("user_manager_tutorial.js",
+ IDR_MD_USER_MANAGER_TUTORIAL_JS);
+
+ source->SetDefaultResource(IDR_MD_USER_MANAGER_HTML);
+
+ return source;
+}
+
+void MDUserManagerUI::GetLocalizedStrings(
+ base::DictionaryValue* localized_strings) {
+ user_manager_screen_handler_->GetLocalizedValues(localized_strings);
+ signin_create_profile_handler_->GetLocalizedValues(localized_strings);
+ const std::string& app_locale = g_browser_process->GetApplicationLocale();
+ webui::SetLoadTimeDataDefaults(app_locale, localized_strings);
+
+#if defined(GOOGLE_CHROME_BUILD)
+ localized_strings->SetString("buildType", "chrome");
+#else
+ localized_strings->SetString("buildType", "chromium");
+#endif
+}
+

Powered by Google App Engine
This is Rietveld 408576698