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

Side by Side Diff: chrome/browser/ui/webui/signin/md_user_manager_ui.cc

Issue 1716163005: MD user manager (C++ for create profile flow) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/webui/signin/user_manager_ui.h" 5 #include "chrome/browser/ui/webui/signin/md_user_manager_ui.h"
6
7 #include <string>
6 8
7 #include "base/values.h" 9 #include "base/values.h"
8 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/webui/signin/signin_create_profile_handler.h"
10 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h" 13 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h"
11 #include "chrome/browser/ui/webui/theme_source.h" 14 #include "chrome/browser/ui/webui/theme_source.h"
12 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
13 #include "content/public/browser/web_ui.h" 16 #include "content/public/browser/web_ui.h"
14 #include "content/public/browser/web_ui_data_source.h" 17 #include "content/public/browser/web_ui_data_source.h"
15 #include "grit/browser_resources.h" 18 #include "grit/browser_resources.h"
19 #include "grit/settings_resources.h"
16 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/base/webui/web_ui_util.h" 21 #include "ui/base/webui/web_ui_util.h"
18 22
19 // JS file names. 23 MDUserManagerUI::MDUserManagerUI(content::WebUI* web_ui)
20 const char kStringsJSPath[] = "strings.js"; 24 : WebUIController(web_ui),
21 const char kUserManagerJSPath[] = "user_manager.js"; 25 signin_create_profile_handler_(new SigninCreateProfileHandler()),
22 26 user_manager_screen_handler_(new UserManagerScreenHandler()) {
23 UserManagerUI::UserManagerUI(content::WebUI* web_ui) 27 // The web_ui object takes ownership of these handlers, and will
24 : WebUIController(web_ui) { 28 // destroy them when it (the WebUI) is destroyed.
25 // The web_ui object takes ownership of the handler, and will 29 web_ui->AddMessageHandler(signin_create_profile_handler_);
26 // destroy it when it (the WebUI) is destroyed.
27 user_manager_screen_handler_ = new UserManagerScreenHandler();
28 web_ui->AddMessageHandler(user_manager_screen_handler_); 30 web_ui->AddMessageHandler(user_manager_screen_handler_);
29 31
30 base::DictionaryValue localized_strings; 32 base::DictionaryValue localized_strings;
31 GetLocalizedStrings(&localized_strings); 33 GetLocalizedStrings(&localized_strings);
32 34
33 Profile* profile = Profile::FromWebUI(web_ui); 35 Profile* profile = Profile::FromWebUI(web_ui);
34 // Set up the chrome://user-chooser/ source. 36 // Set up the chrome://user-chooser/ source.
35 content::WebUIDataSource::Add(profile, CreateUIDataSource(localized_strings)); 37 content::WebUIDataSource::Add(profile, CreateUIDataSource(localized_strings));
36 38
37 #if defined(ENABLE_THEMES) 39 #if defined(ENABLE_THEMES)
38 // Set up the chrome://theme/ source 40 // Set up the chrome://theme/ source
39 ThemeSource* theme = new ThemeSource(profile); 41 ThemeSource* theme = new ThemeSource(profile);
40 content::URLDataSource::Add(profile, theme); 42 content::URLDataSource::Add(profile, theme);
41 #endif 43 #endif
42 } 44 }
43 45
44 UserManagerUI::~UserManagerUI() { 46 MDUserManagerUI::~MDUserManagerUI() {}
45 }
46 47
47 content::WebUIDataSource* UserManagerUI::CreateUIDataSource( 48 content::WebUIDataSource* MDUserManagerUI::CreateUIDataSource(
48 const base::DictionaryValue& localized_strings) { 49 const base::DictionaryValue& localized_strings) {
49 content::WebUIDataSource* source = 50 content::WebUIDataSource* source =
50 content::WebUIDataSource::Create(chrome::kChromeUIUserManagerHost); 51 content::WebUIDataSource::Create(chrome::kChromeUIMdUserManagerHost);
51 source->AddLocalizedStrings(localized_strings); 52 source->AddLocalizedStrings(localized_strings);
52 source->SetJsonPath(kStringsJSPath); 53 source->SetJsonPath("strings.js");
53 54
54 source->SetDefaultResource(IDR_USER_MANAGER_HTML); 55 // TODO(mahmadi): Add resource paths.
55 source->AddResourcePath(kUserManagerJSPath, IDR_USER_MANAGER_JS);
56 56
57 return source; 57 return source;
58 } 58 }
59 59
60 void UserManagerUI::GetLocalizedStrings( 60 void MDUserManagerUI::GetLocalizedStrings(
61 base::DictionaryValue* localized_strings) { 61 base::DictionaryValue* localized_strings) {
62 user_manager_screen_handler_->GetLocalizedValues(localized_strings); 62 user_manager_screen_handler_->GetLocalizedValues(localized_strings);
63 signin_create_profile_handler_->GetLocalizedValues(localized_strings);
63 const std::string& app_locale = g_browser_process->GetApplicationLocale(); 64 const std::string& app_locale = g_browser_process->GetApplicationLocale();
64 webui::SetLoadTimeDataDefaults(app_locale, localized_strings); 65 webui::SetLoadTimeDataDefaults(app_locale, localized_strings);
65 66
66 #if defined(GOOGLE_CHROME_BUILD) 67 #if defined(GOOGLE_CHROME_BUILD)
67 localized_strings->SetString("buildType", "chrome"); 68 localized_strings->SetString("buildType", "chrome");
68 #else 69 #else
69 localized_strings->SetString("buildType", "chromium"); 70 localized_strings->SetString("buildType", "chromium");
70 #endif 71 #endif
71 } 72 }
72
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/signin/md_user_manager_ui.h ('k') | chrome/browser/ui/webui/signin/signin_create_profile_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698