| Index: chrome/browser/ui/gtk/browser_titlebar.cc
|
| diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc
|
| index 9bd46d2b26161870bf6e80c61a7acee141ddf0d3..45780119b93c47bbb11039ce1b85a64ec27168ed 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"
|
| @@ -122,6 +124,16 @@ GdkPixbuf* GetOTRAvatar() {
|
| return otr_avatar;
|
| }
|
|
|
| +gfx::Image GetManagedModeAvatar() {
|
| + static gfx::Image managed_mode_avatar;
|
| + if (managed_mode_avatar.IsEmpty()) {
|
| + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| + managed_mode_avatar = rb.GetNativeImageNamed(
|
| + IDR_MANAGED_MODE_AVATAR, ui::ResourceBundle::RTL_ENABLED);
|
| + }
|
| + return managed_mode_avatar;
|
| +}
|
| +
|
| // Converts a GdkColor to a color_utils::HSL.
|
| color_utils::HSL GdkColorToHSL(const GdkColor* color) {
|
| color_utils::HSL hsl;
|
| @@ -150,15 +162,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
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -774,7 +777,7 @@ void BrowserTitlebar::UpdateAvatar() {
|
| 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();
|
| }
|
| }
|
| @@ -794,23 +797,29 @@ 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()) {
|
| + avatar = GetManagedModeAvatar();
|
| + } 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) {
|
| @@ -1057,8 +1066,11 @@ 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() {
|
|
|