summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorkoz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-27 05:17:47 +0000
committerkoz@chromium.org <koz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-27 05:17:47 +0000
commit48164f956d68e19019f76e97688a21e4fcd9b564 (patch)
treea016efcbc606ce608e0cdd18b9dd638aab811162 /ui
parent79dc4cebcc1bc19cf175f3254cfd79f1af233aa3 (diff)
downloadchromium_src-48164f956d68e19019f76e97688a21e4fcd9b564.zip
chromium_src-48164f956d68e19019f76e97688a21e4fcd9b564.tar.gz
chromium_src-48164f956d68e19019f76e97688a21e4fcd9b564.tar.bz2
Add an icon to the app list to indicate the current profile.
This icon is only visible on Windows and if there is more than one profile available. BUG=174799 Review URL: https://chromiumcodereview.appspot.com/12328002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184880 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/app_list/search_box_model.cc20
-rw-r--r--ui/app_list/search_box_model.h16
-rw-r--r--ui/app_list/search_box_model_observer.h9
-rw-r--r--ui/app_list/views/search_box_view.cc28
-rw-r--r--ui/app_list/views/search_box_view.h4
-rw-r--r--ui/resources/ui_resources.grd1
6 files changed, 76 insertions, 2 deletions
diff --git a/ui/app_list/search_box_model.cc b/ui/app_list/search_box_model.cc
index c885086..198b466 100644
--- a/ui/app_list/search_box_model.cc
+++ b/ui/app_list/search_box_model.cc
@@ -8,7 +8,8 @@
namespace app_list {
-SearchBoxModel::SearchBoxModel() {
+SearchBoxModel::SearchBoxModel()
+ : user_icon_enabled_(false) {
}
SearchBoxModel::~SearchBoxModel() {
@@ -19,6 +20,23 @@ void SearchBoxModel::SetIcon(const gfx::ImageSkia& icon) {
FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_, IconChanged());
}
+void SearchBoxModel::SetUserIcon(const gfx::ImageSkia& icon) {
+ user_icon_ = icon;
+ FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_, UserIconChanged());
+}
+
+void SearchBoxModel::SetUserIconTooltip(const string16& tooltip_text) {
+ user_icon_tooltip_ = tooltip_text;
+ FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_,
+ UserIconTooltipChanged());
+}
+
+void SearchBoxModel::SetUserIconEnabled(bool user_icon_enabled) {
+ user_icon_enabled_ = user_icon_enabled;
+ FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_,
+ UserIconEnabledChanged());
+}
+
void SearchBoxModel::SetHintText(const string16& hint_text) {
if (hint_text_ == hint_text)
return;
diff --git a/ui/app_list/search_box_model.h b/ui/app_list/search_box_model.h
index 1df1429..8df36f4 100644
--- a/ui/app_list/search_box_model.h
+++ b/ui/app_list/search_box_model.h
@@ -30,6 +30,19 @@ class APP_LIST_EXPORT SearchBoxModel {
void SetIcon(const gfx::ImageSkia& icon);
const gfx::ImageSkia& icon() const { return icon_; }
+ // Sets/gets the icon indicating which user is logged in.
+ void SetUserIcon(const gfx::ImageSkia& icon);
+ const gfx::ImageSkia& user_icon() const { return user_icon_; }
+
+ // Sets/gets the tooltip for the icon that indicates which user is logged in.
+ void SetUserIconTooltip(const string16& tooltip_text);
+ const string16& user_icon_tooltip() const { return user_icon_tooltip_; }
+
+ // Sets/gets whether or not we want to show an icon indicating which user is
+ // logged in.
+ void SetUserIconEnabled(bool user_icon_enabled);
+ bool user_icon_enabled() const { return user_icon_enabled_; }
+
// Sets/gets the hint text to display when there is in input.
void SetHintText(const string16& hint_text);
const string16& hint_text() const { return hint_text_; }
@@ -52,6 +65,9 @@ class APP_LIST_EXPORT SearchBoxModel {
string16 hint_text_;
gfx::SelectionModel selection_model_;
string16 text_;
+ gfx::ImageSkia user_icon_;
+ string16 user_icon_tooltip_;
+ bool user_icon_enabled_;
ObserverList<SearchBoxModelObserver> observers_;
diff --git a/ui/app_list/search_box_model_observer.h b/ui/app_list/search_box_model_observer.h
index b4cc40c..eb9d22c 100644
--- a/ui/app_list/search_box_model_observer.h
+++ b/ui/app_list/search_box_model_observer.h
@@ -23,6 +23,15 @@ class APP_LIST_EXPORT SearchBoxModelObserver {
// Invoked when text is changed.
virtual void TextChanged() = 0;
+ // Invoked when user icon is changed.
+ virtual void UserIconChanged() = 0;
+
+ // Invoked when text is changed.
+ virtual void UserIconTooltipChanged() = 0;
+
+ // Invoked when text is changed.
+ virtual void UserIconEnabledChanged() = 0;
+
protected:
virtual ~SearchBoxModelObserver() {}
};
diff --git a/ui/app_list/views/search_box_view.cc b/ui/app_list/views/search_box_view.cc
index 4cf7efe..6201c08 100644
--- a/ui/app_list/views/search_box_view.cc
+++ b/ui/app_list/views/search_box_view.cc
@@ -31,9 +31,11 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate)
: delegate_(delegate),
model_(NULL),
icon_view_(new views::ImageView),
+ user_icon_view_(new views::ImageView),
search_box_(new views::Textfield),
contents_view_(NULL) {
AddChildView(icon_view_);
+ AddChildView(user_icon_view_);
search_box_->RemoveBorder();
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
@@ -59,7 +61,9 @@ void SearchBoxView::SetModel(SearchBoxModel* model) {
if (model_) {
model_->AddObserver(this);
IconChanged();
+ UserIconChanged();
HintTextChanged();
+ UserIconTooltipChanged();
}
}
@@ -77,9 +81,19 @@ void SearchBoxView::Layout() {
icon_frame.set_width(icon_size.width() + 2 * kPadding);
icon_view_->SetBoundsRect(icon_frame);
+ gfx::Rect user_icon_frame(rect);
+ user_icon_frame.set_width(icon_size.width() + 2 * kPadding);
+ user_icon_frame.set_x(rect.right() - user_icon_frame.width());
+ if (!model_->user_icon_enabled()) {
+ user_icon_frame.set_width(0);
+ }
+ user_icon_view_->SetVisible(model_->user_icon_enabled());
+ user_icon_view_->SetBoundsRect(user_icon_frame);
+
gfx::Rect edit_frame(rect);
edit_frame.set_x(icon_frame.right());
- edit_frame.set_width(rect.width() - icon_frame.width() - kPadding);
+ edit_frame.set_width(
+ rect.width() - icon_frame.width() - kPadding - user_icon_frame.width());
edit_frame.ClampToCenteredSize(gfx::Size(edit_frame.width(), kEditHeight));
search_box_->SetBoundsRect(edit_frame);
}
@@ -147,4 +161,16 @@ void SearchBoxView::TextChanged() {
search_box_->SetText(model_->text());
}
+void SearchBoxView::UserIconChanged() {
+ user_icon_view_->SetImage(model_->user_icon());
+}
+
+void SearchBoxView::UserIconTooltipChanged() {
+ user_icon_view_->SetTooltipText(model_->user_icon_tooltip());
+}
+
+void SearchBoxView::UserIconEnabledChanged() {
+ InvalidateLayout();
+}
+
} // namespace app_list
diff --git a/ui/app_list/views/search_box_view.h b/ui/app_list/views/search_box_view.h
index 55c4c797..a2126c7 100644
--- a/ui/app_list/views/search_box_view.h
+++ b/ui/app_list/views/search_box_view.h
@@ -63,11 +63,15 @@ class SearchBoxView : public views::View,
virtual void HintTextChanged() OVERRIDE;
virtual void SelectionModelChanged() OVERRIDE;
virtual void TextChanged() OVERRIDE;
+ virtual void UserIconChanged() OVERRIDE;
+ virtual void UserIconTooltipChanged() OVERRIDE;
+ virtual void UserIconEnabledChanged() OVERRIDE;
SearchBoxViewDelegate* delegate_; // Not owned.
SearchBoxModel* model_; // Owned by AppListModel.
views::ImageView* icon_view_; // Owned by views hierarchy.
+ views::ImageView* user_icon_view_; // Owned by views hierarchy.
views::Textfield* search_box_; // Owned by views hierarchy.
views::View* contents_view_; // Owned by views hierarchy.
diff --git a/ui/resources/ui_resources.grd b/ui/resources/ui_resources.grd
index ff6fcf1..e36695a 100644
--- a/ui/resources/ui_resources.grd
+++ b/ui/resources/ui_resources.grd
@@ -25,6 +25,7 @@
<structure type="chrome_scaled_image" name="IDR_APP_LIST_ITEM_PROGRESS_LEFT" file="common/app_list_progress_bar_left.png" />
<structure type="chrome_scaled_image" name="IDR_APP_LIST_ITEM_PROGRESS_CENTER" file="common/app_list_progress_bar_center.png" />
<structure type="chrome_scaled_image" name="IDR_APP_LIST_ITEM_PROGRESS_RIGHT" file="common/app_list_progress_bar_right.png" />
+ <structure type="chrome_scaled_image" name="IDR_APP_LIST_USER_INDICATOR" file="common/app_list_user_indicator.png" />
</if>
<structure type="chrome_scaled_image" name="IDR_APP_TOP_CENTER" file="app_top_center.png" />
<if expr="pp_ifdef('toolkit_views')">