| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/options/chromeos/accounts_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/accounts_options_handler.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/chromeos/cros_settings_names.h" | 12 #include "chrome/browser/chromeos/cros_settings_names.h" |
| 13 #include "chrome/browser/chromeos/login/authenticator.h" | 13 #include "chrome/browser/chromeos/login/authenticator.h" |
| 14 #include "chrome/browser/chromeos/login/user_manager.h" | 14 #include "chrome/browser/chromeos/login/user_manager.h" |
| 15 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 15 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" | 17 #include "chrome/browser/policy/browser_policy_connector.h" |
| 18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 20 | 20 |
| 21 namespace chromeos { | 21 namespace chromeos { |
| 22 | 22 |
| 23 AccountsOptionsHandler::AccountsOptionsHandler() | 23 AccountsOptionsHandler::AccountsOptionsHandler() |
| 24 : CrosOptionsPageUIHandler(new UserCrosSettingsProvider) { | 24 : CrosOptionsPageUIHandler(new UserCrosSettingsProvider) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 AccountsOptionsHandler::~AccountsOptionsHandler() { | 27 AccountsOptionsHandler::~AccountsOptionsHandler() { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 localized_strings->SetString("owner_user_id", UTF8ToUTF16( | 61 localized_strings->SetString("owner_user_id", UTF8ToUTF16( |
| 62 UserCrosSettingsProvider::cached_owner())); | 62 UserCrosSettingsProvider::cached_owner())); |
| 63 | 63 |
| 64 localized_strings->SetString("current_user_is_owner", | 64 localized_strings->SetString("current_user_is_owner", |
| 65 UserManager::Get()->current_user_is_owner() ? | 65 UserManager::Get()->current_user_is_owner() ? |
| 66 ASCIIToUTF16("true") : ASCIIToUTF16("false")); | 66 ASCIIToUTF16("true") : ASCIIToUTF16("false")); |
| 67 localized_strings->SetString("logged_in_as_guest", | 67 localized_strings->SetString("logged_in_as_guest", |
| 68 UserManager::Get()->IsLoggedInAsGuest() ? | 68 UserManager::Get()->IsLoggedInAsGuest() ? |
| 69 ASCIIToUTF16("true") : ASCIIToUTF16("false")); | 69 ASCIIToUTF16("true") : ASCIIToUTF16("false")); |
| 70 localized_strings->SetString("whitelist_is_managed", | 70 localized_strings->SetString("whitelist_is_managed", |
| 71 g_browser_process->local_state()->IsManagedPreference( | 71 g_browser_process->browser_policy_connector()->IsEnterpriseManaged() ? |
| 72 kAccountsPrefUsers) ? ASCIIToUTF16("true") : ASCIIToUTF16("false")); | 72 ASCIIToUTF16("true") : ASCIIToUTF16("false")); |
| 73 } | 73 } |
| 74 | 74 |
| 75 UserCrosSettingsProvider* AccountsOptionsHandler::users_settings() const { | 75 UserCrosSettingsProvider* AccountsOptionsHandler::users_settings() const { |
| 76 return static_cast<UserCrosSettingsProvider*>(settings_provider_.get()); | 76 return static_cast<UserCrosSettingsProvider*>(settings_provider_.get()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void AccountsOptionsHandler::WhitelistUser(const ListValue* args) { | 79 void AccountsOptionsHandler::WhitelistUser(const ListValue* args) { |
| 80 std::string email; | 80 std::string email; |
| 81 if (!args->GetString(0, &email)) { | 81 if (!args->GetString(0, &email)) { |
| 82 return; | 82 return; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 108 user_dict->SetString("email", email); | 108 user_dict->SetString("email", email); |
| 109 user_dict->SetBoolean("owner", false); | 109 user_dict->SetBoolean("owner", false); |
| 110 | 110 |
| 111 whitelist_users.Append(user_dict); | 111 whitelist_users.Append(user_dict); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 web_ui_->CallJavascriptFunction("AccountsOptions.addUsers", whitelist_users); | 115 web_ui_->CallJavascriptFunction("AccountsOptions.addUsers", whitelist_users); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void AccountsOptionsHandler::Initialize() { | |
| 119 DCHECK(web_ui_); | |
| 120 banner_handler_.reset( | |
| 121 OptionsManagedBannerHandler::Create(web_ui_, | |
| 122 ASCIIToUTF16("AccountsOptions"), | |
| 123 OPTIONS_PAGE_ACCOUNTS)); | |
| 124 } | |
| 125 | |
| 126 } // namespace chromeos | 118 } // namespace chromeos |
| OLD | NEW |