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

Unified Diff: chrome/browser/ui/webui/options/chromeos/accounts_options_handler.cc

Issue 9814030: get rid of old options pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/chromeos/accounts_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/chromeos/accounts_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/accounts_options_handler.cc
deleted file mode 100644
index b4c82f268a74f97c53e25ce55e2c8f9b826b0690..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/webui/options/chromeos/accounts_options_handler.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/options/chromeos/accounts_options_handler.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/json/json_reader.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chromeos/cros_settings.h"
-#include "chrome/browser/chromeos/cros_settings_names.h"
-#include "chrome/browser/chromeos/login/authenticator.h"
-#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/policy/browser_policy_connector.h"
-#include "content/public/browser/web_ui.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace chromeos {
-
-namespace {
-
-// Adds specified user to the whitelist. Returns false if that user is already
-// in the whitelist.
-bool WhitelistUser(const std::string& username) {
- CrosSettings* cros_settings = CrosSettings::Get();
- if (cros_settings->FindEmailInList(kAccountsPrefUsers, username))
- return false;
- base::StringValue username_value(username);
- cros_settings->AppendToList(kAccountsPrefUsers, &username_value);
- return true;
-}
-
-} // namespace
-
-AccountsOptionsHandler::AccountsOptionsHandler() {
-}
-
-AccountsOptionsHandler::~AccountsOptionsHandler() {
-}
-
-void AccountsOptionsHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback("whitelistUser",
- base::Bind(&AccountsOptionsHandler::HandleWhitelistUser,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback("unwhitelistUser",
- base::Bind(&AccountsOptionsHandler::HandleUnwhitelistUser,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback("whitelistExistingUsers",
- base::Bind(&AccountsOptionsHandler::HandleWhitelistExistingUsers,
- base::Unretained(this)));
-}
-
-void AccountsOptionsHandler::GetLocalizedValues(
- base::DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- RegisterTitle(localized_strings, "accountsPage",
- IDS_OPTIONS_ACCOUNTS_TAB_LABEL);
-
- localized_strings->SetString("allow_BWSI", l10n_util::GetStringUTF16(
- IDS_OPTIONS_ACCOUNTS_ALLOW_BWSI_DESCRIPTION));
- localized_strings->SetString("use_whitelist",l10n_util::GetStringUTF16(
- IDS_OPTIONS_ACCOUNTS_USE_WHITELIST_DESCRIPTION));
- localized_strings->SetString("show_user_on_signin",l10n_util::GetStringUTF16(
- IDS_OPTIONS_ACCOUNTS_SHOW_USER_NAMES_ON_SINGIN_DESCRIPTION));
- localized_strings->SetString("username_edit_hint",l10n_util::GetStringUTF16(
- IDS_OPTIONS_ACCOUNTS_USERNAME_EDIT_HINT));
- localized_strings->SetString("username_format",l10n_util::GetStringUTF16(
- IDS_OPTIONS_ACCOUNTS_USERNAME_FORMAT));
- localized_strings->SetString("add_users",l10n_util::GetStringUTF16(
- IDS_OPTIONS_ACCOUNTS_ADD_USERS));
- localized_strings->SetString("owner_only", l10n_util::GetStringUTF16(
- IDS_OPTIONS_ACCOUNTS_OWNER_ONLY));
-
- std::string owner_email;
- CrosSettings::Get()->GetString(kDeviceOwner, &owner_email);
- // Translate owner's email to the display email.
- std::string display_email =
- UserManager::Get()->GetUserDisplayEmail(owner_email);
- localized_strings->SetString("owner_user_id", UTF8ToUTF16(display_email));
-
- localized_strings->SetString("current_user_is_owner",
- UserManager::Get()->IsCurrentUserOwner() ?
- ASCIIToUTF16("true") : ASCIIToUTF16("false"));
- localized_strings->SetString("logged_in_as_guest",
- UserManager::Get()->IsLoggedInAsGuest() ?
- ASCIIToUTF16("true") : ASCIIToUTF16("false"));
- localized_strings->SetString("whitelist_is_managed",
- g_browser_process->browser_policy_connector()->IsEnterpriseManaged() ?
- ASCIIToUTF16("true") : ASCIIToUTF16("false"));
-}
-
-void AccountsOptionsHandler::HandleWhitelistUser(const base::ListValue* args) {
- std::string typed_email;
- std::string name;
- if (!args->GetString(0, &typed_email) ||
- !args->GetString(1, &name)) {
- return;
- }
-
- WhitelistUser(Authenticator::Canonicalize(typed_email));
-}
-
-void AccountsOptionsHandler::HandleUnwhitelistUser(
- const base::ListValue* args) {
- std::string email;
- if (!args->GetString(0, &email)) {
- return;
- }
-
- base::StringValue canonical_email(Authenticator::Canonicalize(email));
- CrosSettings::Get()->RemoveFromList(kAccountsPrefUsers, &canonical_email);
- UserManager::Get()->RemoveUser(email, NULL);
-}
-
-void AccountsOptionsHandler::HandleWhitelistExistingUsers(
- const base::ListValue* args) {
- DCHECK(args && args->empty());
-
- const UserList& users = UserManager::Get()->GetUsers();
- for (UserList::const_iterator it = users.begin(); it < users.end(); ++it) {
- WhitelistUser((*it)->email());
- }
-}
-
-} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698