OLD | NEW |
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"; | |
22 | |
23 UserManagerUI::UserManagerUI(content::WebUI* web_ui) | |
24 : WebUIController(web_ui) { | |
25 // The web_ui object takes ownership of the handler, and will | 25 // The web_ui object takes ownership of the handler, and will |
26 // destroy it when it (the WebUI) is destroyed. | 26 // destroy it when it (the WebUI) is destroyed. |
27 user_manager_screen_handler_ = new UserManagerScreenHandler(); | 27 user_manager_screen_handler_ = new UserManagerScreenHandler(); |
| 28 signin_create_profile_handler_ = new SigninCreateProfileHandler(); |
28 web_ui->AddMessageHandler(user_manager_screen_handler_); | 29 web_ui->AddMessageHandler(user_manager_screen_handler_); |
| 30 web_ui->AddMessageHandler(signin_create_profile_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 source->AddResourcePath("control_bar.css", IDR_MD_CONTROL_BAR_CSS); |
55 source->AddResourcePath(kUserManagerJSPath, IDR_USER_MANAGER_JS); | 56 source->AddResourcePath("control_bar.html", IDR_MD_CONTROL_BAR_HTML); |
| 57 source->AddResourcePath("control_bar.js", IDR_MD_CONTROL_BAR_JS); |
| 58 source->AddResourcePath("create_profile.css", IDR_MD_CREATE_PROFILE_CSS); |
| 59 source->AddResourcePath("create_profile.html", IDR_MD_CREATE_PROFILE_HTML); |
| 60 source->AddResourcePath("create_profile.js", IDR_MD_CREATE_PROFILE_JS); |
| 61 source->AddResourcePath("profile_api.html", IDR_MD_PROFILE_API_HTML); |
| 62 source->AddResourcePath("profile_api.js", IDR_MD_PROFILE_API_JS); |
| 63 source->AddResourcePath("strings.html", IDR_MD_USER_MANAGER_STRINGS_HTML); |
| 64 source->AddResourcePath("supervised_user_learn_more.css", |
| 65 IDR_MD_SUPERVISED_USER_LEARN_MORE_CSS); |
| 66 source->AddResourcePath("supervised_user_learn_more.html", |
| 67 IDR_MD_SUPERVISED_USER_LEARN_MORE_HTML); |
| 68 source->AddResourcePath("supervised_user_learn_more.js", |
| 69 IDR_MD_SUPERVISED_USER_LEARN_MORE_JS); |
| 70 source->AddResourcePath("user_manager.css", IDR_MD_USER_MANAGER_CSS); |
| 71 source->AddResourcePath("user_manager.js", IDR_MD_USER_MANAGER_JS); |
| 72 source->AddResourcePath("user_manager_pages.css", |
| 73 IDR_MD_USER_MANAGER_PAGES_CSS); |
| 74 source->AddResourcePath("user_manager_pages.html", |
| 75 IDR_MD_USER_MANAGER_PAGES_HTML); |
| 76 source->AddResourcePath("user_manager_pages.js", |
| 77 IDR_MD_USER_MANAGER_PAGES_JS); |
| 78 source->AddResourcePath("user_manager_tutorial.css", |
| 79 IDR_MD_USER_MANAGER_TUTORIAL_CSS); |
| 80 source->AddResourcePath("user_manager_tutorial.html", |
| 81 IDR_MD_USER_MANAGER_TUTORIAL_HTML); |
| 82 source->AddResourcePath("user_manager_tutorial.js", |
| 83 IDR_MD_USER_MANAGER_TUTORIAL_JS); |
| 84 |
| 85 source->SetDefaultResource(IDR_MD_USER_MANAGER_HTML); |
56 | 86 |
57 return source; | 87 return source; |
58 } | 88 } |
59 | 89 |
60 void UserManagerUI::GetLocalizedStrings( | 90 void MDUserManagerUI::GetLocalizedStrings( |
61 base::DictionaryValue* localized_strings) { | 91 base::DictionaryValue* localized_strings) { |
62 user_manager_screen_handler_->GetLocalizedValues(localized_strings); | 92 user_manager_screen_handler_->GetLocalizedValues(localized_strings); |
| 93 signin_create_profile_handler_->GetLocalizedValues(localized_strings); |
63 const std::string& app_locale = g_browser_process->GetApplicationLocale(); | 94 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
64 webui::SetLoadTimeDataDefaults(app_locale, localized_strings); | 95 webui::SetLoadTimeDataDefaults(app_locale, localized_strings); |
65 | 96 |
66 #if defined(GOOGLE_CHROME_BUILD) | 97 #if defined(GOOGLE_CHROME_BUILD) |
67 localized_strings->SetString("buildType", "chrome"); | 98 localized_strings->SetString("buildType", "chrome"); |
68 #else | 99 #else |
69 localized_strings->SetString("buildType", "chromium"); | 100 localized_strings->SetString("buildType", "chromium"); |
70 #endif | 101 #endif |
71 } | 102 } |
72 | |
OLD | NEW |