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

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

Issue 16104008: First try at a user management screen for the desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix rebase disaster and some review comments Created 7 years, 5 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
(Empty)
1 // Copyright (c) 2013 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/user_chooser_ui.h"
6
7 #include "base/values.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/webui/signin/user_chooser_screen_handler.h"
10 #include "chrome/browser/ui/webui/theme_source.h"
11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/web_ui.h"
13 #include "content/public/browser/web_ui_data_source.h"
14 #include "grit/browser_resources.h"
15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/webui/web_ui_util.h"
17
18 namespace {
19 // JS file names.
20 const char kStringsJSPath[] = "strings.js";
21 const char kUserChooserJSPath[] = "user_chooser.js";
22 const char kHeaderBarJSPath[] = "header_bar.js";
23 const char kAccountPickerJSPath[] = "screen_account_picker.js";
24 }
25
26 UserChooserUI::UserChooserUI(content::WebUI* web_ui)
27 : WebUIController(web_ui) {
28 // The web_ui object takes ownership of the handler, and will
29 // destroy it when it (the WebUI) is destroyed.
30 user_chooser_screen_handler_ = new UserChooserScreenHandler();
31 web_ui->AddMessageHandler(user_chooser_screen_handler_);
32
33 base::DictionaryValue localized_strings;
34 GetLocalizedStrings(&localized_strings);
35
36 Profile* profile = Profile::FromWebUI(web_ui);
37 // Set up the chrome://user-chooser/ source.
38 content::WebUIDataSource::Add(profile, CreateUIDataSource(localized_strings));
39
40 #if defined(ENABLE_THEMES)
41 // Set up the chrome://theme/ source
42 ThemeSource* theme = new ThemeSource(profile);
43 content::URLDataSource::Add(profile, theme);
44 #endif
45 }
46
47 UserChooserUI::~UserChooserUI() {
48 }
49
50 content::WebUIDataSource* UserChooserUI::CreateUIDataSource(
51 const base::DictionaryValue& localized_strings) {
52 content::WebUIDataSource* source =
53 content::WebUIDataSource::Create(chrome::kChromeUIUserChooserHost);
54 source->SetUseJsonJSFormatV2();
55 source->AddLocalizedStrings(localized_strings);
56 source->SetJsonPath(kStringsJSPath);
57
58 source->SetDefaultResource(IDR_USER_CHOOSER_HTML);
59 source->AddResourcePath(kUserChooserJSPath, IDR_USER_CHOOSER_JS);
60
61 return source;
62 }
63
64 void UserChooserUI::GetLocalizedStrings(
65 base::DictionaryValue* localized_strings) {
66 user_chooser_screen_handler_->GetLocalizedValues(localized_strings);
67 webui::SetFontAndTextDirection(localized_strings);
68
69 #if defined(GOOGLE_CHROME_BUILD)
70 localized_strings->SetString("buildType", "chrome");
71 #else
72 localized_strings->SetString("buildType", "chromium");
73 #endif
74 }
75
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698