OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/webui/signin/md_user_manager_ui.h" | |
6 | |
7 #include "base/values.h" | |
8 #include "chrome/browser/browser_process.h" | |
9 #include "chrome/browser/profiles/profile.h" | |
10 #include "chrome/browser/ui/webui/signin/signin_create_profile_handler.h" | |
11 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h" | |
12 #include "chrome/browser/ui/webui/theme_source.h" | |
13 #include "chrome/common/url_constants.h" | |
14 #include "content/public/browser/web_ui.h" | |
15 #include "content/public/browser/web_ui_data_source.h" | |
16 #include "grit/browser_resources.h" | |
17 #include "grit/settings_resources.h" | |
18 #include "ui/base/resource/resource_bundle.h" | |
19 #include "ui/base/webui/web_ui_util.h" | |
20 | |
21 MDUserManagerUI::MDUserManagerUI(content::WebUI* web_ui) | |
22 : WebUIController(web_ui) { | |
23 // The web_ui object takes ownership of the handler, and will | |
24 // destroy it when it (the WebUI) is destroyed. | |
25 user_manager_screen_handler_ = new UserManagerScreenHandler(); | |
26 signin_create_profile_handler_ = new SigninCreateProfileHandler(); | |
27 web_ui->AddMessageHandler(user_manager_screen_handler_); | |
28 web_ui->AddMessageHandler(signin_create_profile_handler_); | |
29 | |
30 base::DictionaryValue localized_strings; | |
31 GetLocalizedStrings(&localized_strings); | |
32 | |
33 Profile* profile = Profile::FromWebUI(web_ui); | |
34 // Set up the chrome://user-chooser/ source. | |
35 content::WebUIDataSource::Add(profile, CreateUIDataSource(localized_strings)); | |
36 | |
37 #if defined(ENABLE_THEMES) | |
38 // Set up the chrome://theme/ source | |
39 ThemeSource* theme = new ThemeSource(profile); | |
40 content::URLDataSource::Add(profile, theme); | |
41 #endif | |
42 } | |
43 | |
44 MDUserManagerUI::~MDUserManagerUI() { | |
45 } | |
46 | |
47 content::WebUIDataSource* MDUserManagerUI::CreateUIDataSource( | |
48 const base::DictionaryValue& localized_strings) { | |
49 content::WebUIDataSource* source = | |
50 content::WebUIDataSource::Create(chrome::kChromeUIMDUserManagerHost); | |
51 source->AddLocalizedStrings(localized_strings); | |
52 source->SetJsonPath("strings.js"); | |
53 | |
54 source->AddResourcePath("control_bar.css", IDR_MD_CONTROL_BAR_CSS); | |
55 source->AddResourcePath("control_bar.html", IDR_MD_CONTROL_BAR_HTML); | |
56 source->AddResourcePath("control_bar.js", IDR_MD_CONTROL_BAR_JS); | |
57 source->AddResourcePath("create_profile.css", IDR_MD_CREATE_PROFILE_CSS); | |
58 source->AddResourcePath("create_profile.html", IDR_MD_CREATE_PROFILE_HTML); | |
59 source->AddResourcePath("create_profile.js", IDR_MD_CREATE_PROFILE_JS); | |
60 source->AddResourcePath("profile_api.html", IDR_MD_PROFILE_API_HTML); | |
61 source->AddResourcePath("profile_api.js", IDR_MD_PROFILE_API_JS); | |
62 source->AddResourcePath("strings.html", IDR_MD_USER_MANAGER_STRINGS_HTML); | |
63 source->AddResourcePath("supervised_user_learn_more.css", | |
64 IDR_MD_SUPERVISED_USER_LEARN_MORE_CSS); | |
65 source->AddResourcePath("supervised_user_learn_more.html", | |
66 IDR_MD_SUPERVISED_USER_LEARN_MORE_HTML); | |
67 source->AddResourcePath("supervised_user_learn_more.js", | |
68 IDR_MD_SUPERVISED_USER_LEARN_MORE_JS); | |
69 source->AddResourcePath("user_manager.css", IDR_MD_USER_MANAGER_CSS); | |
70 source->AddResourcePath("user_manager.js", IDR_MD_USER_MANAGER_JS); | |
71 source->AddResourcePath("user_manager_pages.css", | |
72 IDR_MD_USER_MANAGER_PAGES_CSS); | |
73 source->AddResourcePath("user_manager_pages.html", | |
74 IDR_MD_USER_MANAGER_PAGES_HTML); | |
75 source->AddResourcePath("user_manager_pages.js", | |
76 IDR_MD_USER_MANAGER_PAGES_JS); | |
77 source->AddResourcePath("user_manager_tutorial.css", | |
78 IDR_MD_USER_MANAGER_TUTORIAL_CSS); | |
79 source->AddResourcePath("user_manager_tutorial.html", | |
80 IDR_MD_USER_MANAGER_TUTORIAL_HTML); | |
81 source->AddResourcePath("user_manager_tutorial.js", | |
82 IDR_MD_USER_MANAGER_TUTORIAL_JS); | |
83 | |
84 source->SetDefaultResource(IDR_MD_USER_MANAGER_HTML); | |
85 | |
86 return source; | |
87 } | |
88 | |
89 void MDUserManagerUI::GetLocalizedStrings( | |
90 base::DictionaryValue* localized_strings) { | |
91 user_manager_screen_handler_->GetLocalizedValues(localized_strings); | |
92 signin_create_profile_handler_->GetLocalizedValues(localized_strings); | |
93 const std::string& app_locale = g_browser_process->GetApplicationLocale(); | |
94 webui::SetLoadTimeDataDefaults(app_locale, localized_strings); | |
95 | |
96 #if defined(GOOGLE_CHROME_BUILD) | |
97 localized_strings->SetString("buildType", "chrome"); | |
anthonyvd
2016/01/29 15:50:17
I'm fairly confident there's a string defined as t
Moe
2016/02/01 01:11:13
I couldn't find the string you're referring to. Co
| |
98 #else | |
99 localized_strings->SetString("buildType", "chromium"); | |
100 #endif | |
101 } | |
102 | |
OLD | NEW |