diff options
author | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-06 12:34:02 +0000 |
---|---|---|
committer | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-06 12:34:02 +0000 |
commit | 23c4534fa99432a65d427d2e417c1b5713c0cc30 (patch) | |
tree | f097565bd8309b6b6ea03aec01f79c95d81d5e8e /ash | |
parent | 98d3c686ee6d19e50b12557969416739d7f6a44f (diff) | |
download | chromium_src-23c4534fa99432a65d427d2e417c1b5713c0cc30.zip chromium_src-23c4534fa99432a65d427d2e417c1b5713c0cc30.tar.gz chromium_src-23c4534fa99432a65d427d2e417c1b5713c0cc30.tar.bz2 |
Create helper function to determine label for sign-out button
This CL moves the code that determines the label for the sign-out button
shown in the aura bar context menu to a helper function. This will allow
the code to be shared with the upcoming aura bar sign-out button for
public accounts, ensuring the labels on both buttons are always in sync.
BUG=152929
Review URL: https://chromiumcodereview.appspot.com/11338041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166194 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/ash.gyp | 1 | ||||
-rw-r--r-- | ash/system/user/login_status.cc | 30 | ||||
-rw-r--r-- | ash/system/user/login_status.h | 4 | ||||
-rw-r--r-- | ash/system/user/tray_user.cc | 12 |
4 files changed, 37 insertions, 10 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index e1d4eae..b7af253 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -237,6 +237,7 @@ 'system/tray_caps_lock.h', 'system/tray_update.cc', 'system/tray_update.h', + 'system/user/login_status.cc', 'system/user/login_status.h', 'system/user/tray_user.cc', 'system/user/tray_user.h', diff --git a/ash/system/user/login_status.cc b/ash/system/user/login_status.cc new file mode 100644 index 0000000..d24185d --- /dev/null +++ b/ash/system/user/login_status.cc @@ -0,0 +1,30 @@ +// 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 "ash/system/user/login_status.h" + +#include "grit/ash_strings.h" +#include "ui/base/resource/resource_bundle.h" + +namespace ash { +namespace user { + +string16 GetLocalizedSignOutStringForStatus(LoginStatus status) { + int message_id; + switch (status) { + case LOGGED_IN_GUEST: + message_id = IDS_ASH_STATUS_TRAY_EXIT_GUEST; + break; + case LOGGED_IN_KIOSK: + message_id = IDS_ASH_STATUS_TRAY_EXIT_KIOSK; + break; + default: + message_id = IDS_ASH_STATUS_TRAY_SIGN_OUT; + break; + } + return ui::ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); +} + +} // namespace user +} // namespace ash diff --git a/ash/system/user/login_status.h b/ash/system/user/login_status.h index 635ff20..0d470d2 100644 --- a/ash/system/user/login_status.h +++ b/ash/system/user/login_status.h @@ -5,6 +5,8 @@ #ifndef ASH_SYSTEM_USER_LOGIN_STATUS_H_ #define ASH_SYSTEM_USER_LOGIN_STATUS_H_ +#include "base/string16.h" + namespace ash { namespace user { @@ -17,6 +19,8 @@ enum LoginStatus { LOGGED_IN_NONE, // Not logged in. }; +string16 GetLocalizedSignOutStringForStatus(LoginStatus status); + } // namespace user } // namespace ash diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc index 9576072..b291296 100644 --- a/ash/system/user/tray_user.cc +++ b/ash/system/user/tray_user.cc @@ -129,16 +129,8 @@ class UserView : public views::View, // Create container for buttons. void AddButtonContainer() { - bool guest = login_ == ash::user::LOGGED_IN_GUEST; - bool kiosk = login_ == ash::user::LOGGED_IN_KIOSK; - - ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); - - TrayPopupTextButton* button = - new TrayPopupTextButton(this, bundle.GetLocalizedString( - guest ? IDS_ASH_STATUS_TRAY_EXIT_GUEST : - kiosk ? IDS_ASH_STATUS_TRAY_EXIT_KIOSK : - IDS_ASH_STATUS_TRAY_SIGN_OUT)); + TrayPopupTextButton* button = new TrayPopupTextButton(this, + ash::user::GetLocalizedSignOutStringForStatus(login_)); container_->AddTextButton(button); signout_ = button; } |