summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/gtk/browser_titlebar.cc
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-27 18:27:14 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-27 18:27:14 +0000
commit623294c447e00b7485092cdf68d50874a9f0646e (patch)
tree53135e482180a848d3ab9b0a3643407f63c5b9cc /chrome/browser/ui/gtk/browser_titlebar.cc
parent61b4efcd2a24ed3862775093626247ebddc3f5f0 (diff)
downloadchromium_src-623294c447e00b7485092cdf68d50874a9f0646e.zip
chromium_src-623294c447e00b7485092cdf68d50874a9f0646e.tar.gz
chromium_src-623294c447e00b7485092cdf68d50874a9f0646e.tar.bz2
Add a button to exit managed mode in place of the profile avatar.
BUG=116060 TEST=none Review URL: http://codereview.chromium.org/9500003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134308 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/gtk/browser_titlebar.cc')
-rw-r--r--chrome/browser/ui/gtk/browser_titlebar.cc74
1 files changed, 37 insertions, 37 deletions
diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc
index 559045f..e646d30 100644
--- a/chrome/browser/ui/gtk/browser_titlebar.cc
+++ b/chrome/browser/ui/gtk/browser_titlebar.cc
@@ -18,7 +18,9 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/managed_mode.h"
#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profiles/avatar_menu_model.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -112,16 +114,6 @@ gboolean OnMouseMoveEvent(GtkWidget* widget, GdkEventMotion* event,
return TRUE;
}
-GdkPixbuf* GetOTRAvatar() {
- static GdkPixbuf* otr_avatar = NULL;
- if (!otr_avatar) {
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- otr_avatar = rb.GetNativeImageNamed(
- IDR_OTR_ICON, ui::ResourceBundle::RTL_ENABLED).ToGdkPixbuf();
- }
- return otr_avatar;
-}
-
// Converts a GdkColor to a color_utils::HSL.
color_utils::HSL GdkColorToHSL(const GdkColor* color) {
color_utils::HSL hsl;
@@ -150,15 +142,6 @@ GdkColor PickLuminosityContrastingColor(const GdkColor* base,
return *one;
}
-// Returns true if there are multiple profiles created. This is used to
-// determine whether to display the avatar image.
-bool HasMultipleProfiles() {
- ProfileInfoCache& cache =
- g_browser_process->profile_manager()->GetProfileInfoCache();
- return ProfileManager::IsMultipleProfilesEnabled() &&
- cache.GetNumberOfProfiles() > 1;
-}
-
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -803,11 +786,14 @@ void BrowserTitlebar::UpdateAvatar() {
if (!avatar_) {
if (IsOffTheRecord()) {
- avatar_ = gtk_image_new_from_pixbuf(GetOTRAvatar());
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ gfx::Image avatar_image =
+ rb.GetNativeImageNamed(IDR_OTR_ICON, ui::ResourceBundle::RTL_ENABLED);
+ avatar_ = gtk_image_new_from_pixbuf(avatar_image.ToGdkPixbuf());
gtk_misc_set_alignment(GTK_MISC(avatar_), 0.0, 1.0);
gtk_widget_set_size_request(avatar_, -1, 0);
} else {
- // Is using multi-profile avatar.
+ // Use a clickable avatar.
avatar_ = avatar_button_->widget();
}
}
@@ -827,23 +813,32 @@ void BrowserTitlebar::UpdateAvatar() {
if (IsOffTheRecord())
return;
- ProfileInfoCache& cache =
- g_browser_process->profile_manager()->GetProfileInfoCache();
- Profile* profile = browser_window_->browser()->profile();
- size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
- if (index != std::string::npos) {
- bool is_gaia_picture =
+ bool is_gaia_picture = false;
+ gfx::Image avatar;
+ if (ManagedMode::IsInManagedMode()) {
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ avatar = rb.GetNativeImageNamed(IDR_MANAGED_MODE_AVATAR,
+ ui::ResourceBundle::RTL_ENABLED);
+ } else {
+ ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
+ Profile* profile = browser_window_->browser()->profile();
+ size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
+ if (index == std::string::npos)
+ return;
+
+ is_gaia_picture =
cache.IsUsingGAIAPictureOfProfileAtIndex(index) &&
cache.GetGAIAPictureOfProfileAtIndex(index);
- avatar_button_->SetIcon(
- cache.GetAvatarIconOfProfileAtIndex(index), is_gaia_picture);
-
- BubbleGtk::ArrowLocationGtk arrow_location =
- display_avatar_on_left_ ^ base::i18n::IsRTL() ?
- BubbleGtk::ARROW_LOCATION_TOP_LEFT :
- BubbleGtk::ARROW_LOCATION_TOP_RIGHT;
- avatar_button_->set_menu_arrow_location(arrow_location);
+ avatar = cache.GetAvatarIconOfProfileAtIndex(index);
}
+ avatar_button_->SetIcon(avatar, is_gaia_picture);
+
+ BubbleGtk::ArrowLocationGtk arrow_location =
+ display_avatar_on_left_ ^ base::i18n::IsRTL() ?
+ BubbleGtk::ARROW_LOCATION_TOP_LEFT :
+ BubbleGtk::ARROW_LOCATION_TOP_RIGHT;
+ avatar_button_->set_menu_arrow_location(arrow_location);
}
void BrowserTitlebar::ShowFaviconMenu(GdkEventButton* event) {
@@ -1093,8 +1088,13 @@ void BrowserTitlebar::ActiveWindowChanged(GdkWindow* active_window) {
}
bool BrowserTitlebar::ShouldDisplayAvatar() {
- return (IsOffTheRecord() || HasMultipleProfiles()) &&
- browser_window_->browser()->is_type_tabbed();
+ if (IsOffTheRecord() || ManagedMode::IsInManagedMode())
+ return true;
+
+ if (!browser_window_->browser()->is_type_tabbed())
+ return false;
+
+ return AvatarMenuModel::ShouldShowAvatarMenu();
}
bool BrowserTitlebar::IsOffTheRecord() {