Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| 8 #include "chrome/browser/profiles/profile.h" | |
| 9 | |
| 10 #include "chrome/browser/ui/webui/signin/user_chooser_screen_handler.h" | |
| 11 #include "chrome/browser/ui/webui/theme_source.h" | |
| 12 #include "chrome/common/url_constants.h" | |
| 13 #include "content/public/browser/web_ui.h" | |
| 14 #include "content/public/browser/web_ui_data_source.h" | |
| 15 #include "grit/browser_resources.h" | |
| 16 #include "ui/base/resource/resource_bundle.h" | |
| 17 #include "ui/webui/web_ui_util.h" | |
| 18 | |
| 19 namespace { | |
| 20 // JS file names. | |
| 21 const char kStringsJSPath[] = "strings.js"; | |
| 22 const char kUserChooserJSPath[] = "user_chooser.js"; | |
| 23 const char kHeaderBarJSPath[] = "header_bar.js"; | |
| 24 const char kAccountPickerJSPath[] = "screen_account_picker.js"; | |
| 25 } | |
| 26 | |
| 27 UserChooserUI::UserChooserUI(content::WebUI* web_ui) | |
| 28 : WebUIController(web_ui) { | |
| 29 | |
| 30 // The web_ui object takes ownership of the handler, and will | |
| 31 // destroy it when it (the WebUI) is destroyed. | |
| 32 user_chooser_screen_handler_ = new UserChooserScreenHandler(); | |
| 33 web_ui->AddMessageHandler(user_chooser_screen_handler_); | |
| 34 | |
| 35 base::DictionaryValue localized_strings; | |
| 36 GetLocalizedStrings(&localized_strings); | |
| 37 | |
| 38 // Set up the chrome://theme/ source | |
|
Roger Tawa OOO till Jul 10th
2013/06/05 18:53:56
Inside #if defined(ENABLE_THEMES) ?
noms
2013/06/06 19:01:36
Done.
| |
| 39 Profile* profile = Profile::FromWebUI(web_ui); | |
| 40 ThemeSource* theme = new ThemeSource(profile); | |
| 41 content::URLDataSource::Add(profile, theme); | |
| 42 | |
| 43 // Set up the chrome://user-chooser/ source. | |
| 44 content::WebUIDataSource::Add(profile, CreateUIDataSource(localized_strings)); | |
| 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 | |
| 67 user_chooser_screen_handler_->GetLocalizedValues(localized_strings); | |
| 68 webui::SetFontAndTextDirection(localized_strings); | |
| 69 | |
| 70 #if defined(GOOGLE_CHROME_BUILD) | |
| 71 localized_strings->SetString("buildType", "chrome"); | |
| 72 #else | |
| 73 localized_strings->SetString("buildType", "chromium"); | |
| 74 #endif | |
| 75 } | |
| 76 | |
| OLD | NEW |