diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-04 13:33:26 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-04 13:33:26 +0000 |
commit | 80aebf36b362eff1ff616a482a554db362f4efda (patch) | |
tree | 6e0cef71931bd9792005d5ac2257f4a60eb2d143 | |
parent | 5e9ccbb74fbb0642c4e136b0d2937a7166d2ab93 (diff) | |
download | chromium_src-80aebf36b362eff1ff616a482a554db362f4efda.zip chromium_src-80aebf36b362eff1ff616a482a554db362f4efda.tar.gz chromium_src-80aebf36b362eff1ff616a482a554db362f4efda.tar.bz2 |
Add multiprofile tag for opaque and themed browsers.
Review URL: http://codereview.chromium.org/6902004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84054 0039d316-1c4b-4281-b951-d872f2087c98
18 files changed, 291 insertions, 93 deletions
diff --git a/chrome/app/theme/profile_tag_center.png b/chrome/app/theme/profile_tag_center.png Binary files differdeleted file mode 100644 index 407f9ff..0000000 --- a/chrome/app/theme/profile_tag_center.png +++ /dev/null diff --git a/chrome/app/theme/profile_tag_inactive_center.png b/chrome/app/theme/profile_tag_inactive_center.png Binary files differdeleted file mode 100644 index 09dd158..0000000 --- a/chrome/app/theme/profile_tag_inactive_center.png +++ /dev/null diff --git a/chrome/app/theme/profile_tag_inactive_left.png b/chrome/app/theme/profile_tag_inactive_left.png Binary files differdeleted file mode 100644 index cec460a..0000000 --- a/chrome/app/theme/profile_tag_inactive_left.png +++ /dev/null diff --git a/chrome/app/theme/profile_tag_inactive_right.png b/chrome/app/theme/profile_tag_inactive_right.png Binary files differdeleted file mode 100644 index 208def6a..0000000 --- a/chrome/app/theme/profile_tag_inactive_right.png +++ /dev/null diff --git a/chrome/app/theme/profile_tag_left.png b/chrome/app/theme/profile_tag_left.png Binary files differdeleted file mode 100644 index 206d081..0000000 --- a/chrome/app/theme/profile_tag_left.png +++ /dev/null diff --git a/chrome/app/theme/profile_tag_right.png b/chrome/app/theme/profile_tag_right.png Binary files differdeleted file mode 100644 index 3f26f11..0000000 --- a/chrome/app/theme/profile_tag_right.png +++ /dev/null diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index b5ec429..0993f7c 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -207,12 +207,18 @@ <!-- NOTE: product_logo_*.* files beyond what's listed above are referenced by installer code; don't remove them unless you know what you're doing! --> - <include name="IDR_PROFILE_TAG_CENTER" file="profile_tag_center.png" type="BINDATA" /> - <include name="IDR_PROFILE_TAG_LEFT" file="profile_tag_left.png" type="BINDATA" /> - <include name="IDR_PROFILE_TAG_RIGHT" file="profile_tag_right.png" type="BINDATA" /> - <include name="IDR_PROFILE_TAG_INACTIVE_CENTER" file="profile_tag_inactive_center.png" type="BINDATA" /> - <include name="IDR_PROFILE_TAG_INACTIVE_LEFT" file="profile_tag_inactive_left.png" type="BINDATA" /> - <include name="IDR_PROFILE_TAG_INACTIVE_RIGHT" file="profile_tag_inactive_right.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_CENTER_AERO" file="profile_tag_center_aero.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_LEFT_AERO" file="profile_tag_left_aero.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_RIGHT_AERO" file="profile_tag_right_aero.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_INACTIVE_CENTER_AERO" file="profile_tag_inactive_center_aero.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_INACTIVE_LEFT_AERO" file="profile_tag_inactive_left_aero.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_INACTIVE_RIGHT_AERO" file="profile_tag_inactive_right_aero.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_CENTER_THEMED" file="profile_tag_center_opaque.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_LEFT_THEMED" file="profile_tag_left_opaque.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_RIGHT_THEMED" file="profile_tag_right_opaque.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_CENTER_MASK" file="profile_tag_center_mask.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_LEFT_MASK" file="profile_tag_left_mask.png" type="BINDATA" /> + <include name="IDR_PROFILE_TAG_RIGHT_MASK" file="profile_tag_right_mask.png" type="BINDATA" /> <include name="IDR_RESTORE_BUTTON_MASK" file="restore_button_mask.png" type="BINDATA" /> <include name="IDR_SAD_FAVICON" file="sadfavicon.png" type="BINDATA" /> <include name="IDR_SAD_TAB" file="sadtab.png" type="BINDATA" /> diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc index b93542e..dfb34e1 100644 --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc @@ -93,11 +93,10 @@ GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame, if (browser_command_line.HasSwitch(switches::kMultiProfiles) && !browser_view->ShouldShowOffTheRecordAvatar()) { RegisterLoginNotifications(); - profile_button_.reset(new views::ProfileMenuButton(NULL, std::wstring(), - this)); + profile_button_.reset(new ProfileMenuButton(NULL, std::wstring(), + this, browser_view_->browser()->profile())); profile_button_->SetVisible(false); - profile_tag_.reset(new views::ProfileTagView(frame_, - profile_button_.get())); + profile_tag_.reset(new ProfileTagView(frame_, profile_button_.get())); profile_tag_->SetVisible(false); AddChildView(profile_tag_.get()); AddChildView(profile_button_.get()); @@ -138,7 +137,7 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( kNewTabCaptionMaximizedSpacing + (show_profile_button() && profile_button_->IsVisible() ? profile_button_->GetPreferredSize().width() + - views::ProfileMenuButton::kProfileTagHorizontalSpacing : 0); + ProfileMenuButton::kProfileTagHorizontalSpacing : 0); int tabstrip_width = minimize_button_offset - tabstrip_x - (frame_->GetWindow()->IsMaximized() ? maximized_spacing : kNewTabCaptionRestoredSpacing); @@ -237,7 +236,7 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { // GlassBrowserFrameView, views::ViewMenuDelegate implementation: void GlassBrowserFrameView::RunMenu(views::View *source, const gfx::Point &pt) { if (profile_menu_model_ == NULL) - profile_menu_model_.reset(new views::ProfileMenuModel); + profile_menu_model_.reset(new ProfileMenuModel); gfx::Point menu_point(pt.x(), pt.y() + kMenuDisplayOffset); profile_menu_model_->RunMenuAt(menu_point); @@ -521,24 +520,22 @@ void GlassBrowserFrameView::LayoutProfileTag() { // The x position of minimize button in the frame frame_->GetMinimizeButtonOffset() - // - the space between the minimize button and the profile button - views::ProfileMenuButton::kProfileTagHorizontalSpacing - + ProfileMenuButton::kProfileTagHorizontalSpacing - // - the width of the profile button profile_button_->GetPreferredSize().width(); + int y_maximized_offset = frame_->GetWindow()->IsMaximized() ? + kProfileElementMaximizedYOffset : 0; profile_button_->SetBounds( x_tag, - kProfileButtonYPosition + - (frame_->GetWindow()->IsMaximized() ? - kProfileElementMaximizedYOffset : 0), + kProfileButtonYPosition + y_maximized_offset, profile_button_->GetPreferredSize().width(), profile_button_->GetPreferredSize().height()); profile_tag_->SetVisible(true); profile_tag_->SetBounds( x_tag, - kProfileTagYPosition + - (frame_->GetWindow()->IsMaximized() ? - kProfileElementMaximizedYOffset : 0), + kProfileTagYPosition + y_maximized_offset, profile_button_->GetPreferredSize().width(), - views::ProfileTagView::kProfileTagHeight); + ProfileTagView::kProfileTagHeight); } else { profile_button_->SetVisible(false); profile_tag_->SetVisible(false); diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.h b/chrome/browser/ui/views/frame/glass_browser_frame_view.h index ba24a01..4137648 100644 --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.h +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.h @@ -15,13 +15,10 @@ #include "views/window/non_client_view.h" class BrowserView; -class SkBitmap; - -namespace views { class ProfileMenuButton; class ProfileMenuModel; class ProfileTagView; -} +class SkBitmap; class GlassBrowserFrameView : public BrowserNonClientFrameView, public NotificationObserver, @@ -117,13 +114,13 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView, gfx::Rect client_view_bounds_; // Menu button that displays user's name and multi-profile menu. - scoped_ptr<views::ProfileMenuButton> profile_button_; + scoped_ptr<ProfileMenuButton> profile_button_; // Image tag displayed on frame beneath profile_button_. - scoped_ptr<views::ProfileTagView> profile_tag_; + scoped_ptr<ProfileTagView> profile_tag_; // Multi-profile menu for profile_button_. - scoped_ptr<views::ProfileMenuModel> profile_menu_model_; + scoped_ptr<ProfileMenuModel> profile_menu_model_; // Whether or not the window throbber is currently animating. bool throbber_running_; diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index 3b7fef7..56241de 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -4,14 +4,23 @@ #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" +#include "base/command_line.h" #include "base/compiler_specific.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/frame/browser_view.h" +#include "chrome/browser/ui/views/profile_menu_button.h" +#include "chrome/browser/ui/views/profile_menu_model.h" +#include "chrome/browser/ui/views/profile_tag_view.h" #include "chrome/browser/ui/views/tabs/tab_strip.h" #include "chrome/browser/ui/views/toolbar_view.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/common/pref_names.h" #include "content/browser/tab_contents/tab_contents.h" +#include "content/common/notification_service.h" #include "grit/app_resources.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -90,6 +99,13 @@ const int kTabStripIndent = 1; // Inset from the top of the toolbar/tabstrip to the shadow. Used only for // vertical tabs. const int kVerticalTabBorderInset = 3; +// Menu should display below the profile button tag image on the frame. This +// offset size depends on whether the frame is in glass or opaque mode. +const int kMenuDisplayOffset = 7; +// Y position for profile tag inside the frame. +const int kProfileTagYPosition = 1; +// Offset y position of profile button and tag by this amount when maximized. +const int kProfileElementMaximizedYOffset = 6; } /////////////////////////////////////////////////////////////////////////////// @@ -176,6 +192,20 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, AddChildView(window_icon_); window_icon_->Update(); } + + // If multi-profile is enabled set up profile button and login notifications. + const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); + if (browser_command_line.HasSwitch(switches::kMultiProfiles) && + !browser_view_->ShouldShowOffTheRecordAvatar()) { + RegisterLoginNotifications(); + profile_button_.reset(new ProfileMenuButton(NULL, std::wstring(), + this, browser_view_->browser()->profile())); + profile_button_->SetVisible(false); + profile_tag_.reset(new ProfileTagView(frame_, profile_button_.get())); + profile_tag_->SetVisible(false); + AddChildView(profile_tag_.get()); + AddChildView(profile_button_.get()); + } } OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { @@ -238,9 +268,14 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( (otr_avatar_bounds_.right() + kOTRSideSpacing) : NonClientBorderThickness() + kTabStripIndent; + int maximized_spacing = + kNewTabCaptionMaximizedSpacing + + (show_profile_button() && profile_button_->IsVisible() ? + profile_button_->GetPreferredSize().width() + + ProfileMenuButton::kProfileTagHorizontalSpacing : 0); int tabstrip_width = minimize_button_->x() - tabstrip_x - (frame_->GetWindow()->IsMaximized() ? - kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); + maximized_spacing : kNewTabCaptionRestoredSpacing); int tabstrip_height = 0; if (tabstrip) tabstrip_height = tabstrip->GetPreferredSize().height(); @@ -342,6 +377,11 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { minimize_button_->GetMirroredBounds().Contains(point)) return HTMINBUTTON; + // See if the point is within the profile menu button. + if (show_profile_button() && profile_button_->IsVisible() && + profile_button_->GetMirroredBounds().Contains(point)) + return HTCLIENT; + views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate(); if (!delegate) { LOG(WARNING) << "delegate is NULL, returning safe default."; @@ -380,6 +420,17 @@ void OpaqueBrowserFrameView::UpdateWindowIcon() { } /////////////////////////////////////////////////////////////////////////////// +// OpaqueBrowserFrameView, views::ViewMenuDelegate overrides: +void OpaqueBrowserFrameView::RunMenu(views::View* source, + const gfx::Point &pt) { + if (profile_menu_model_ == NULL) + profile_menu_model_.reset(new ProfileMenuModel); + gfx::Point menu_point(pt.x(), + pt.y() + kMenuDisplayOffset); + profile_menu_model_->RunMenuAt(menu_point); +} + +/////////////////////////////////////////////////////////////////////////////// // OpaqueBrowserFrameView, views::View overrides: void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { @@ -404,6 +455,7 @@ void OpaqueBrowserFrameView::Layout() { LayoutWindowControls(); LayoutTitleBar(); LayoutOTRAvatar(); + LayoutProfileTag(); client_view_bounds_ = CalculateClientAreaBounds(width(), height()); } @@ -1095,6 +1147,44 @@ void OpaqueBrowserFrameView::LayoutOTRAvatar() { browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0); } +void OpaqueBrowserFrameView::LayoutProfileTag() { + if (!show_profile_button()) + return; + + string16 profile_name = UTF8ToUTF16(browser_view_->browser()->profile()-> + GetPrefs()->GetString(prefs::kGoogleServicesUsername)); + if (!profile_name.empty()) { + profile_button_->SetText(UTF16ToWideHack(profile_name)); + profile_button_->ClearMaxTextSize(); + profile_button_->SetVisible(true); + int x_tag = + // The x position of minimize button in the frame + minimize_button_->x() - + // - the space between the minimize button and the profile button + ProfileMenuButton::kProfileTagHorizontalSpacing - + // - the width of the profile button + profile_button_->GetPreferredSize().width(); + // Adjust for different default font sizes on different Windows platforms. + int y_tag = profile_button_->font().GetHeight() < 14 ? 2 : 0; + int y_maximized_offset = frame_->GetWindow()->IsMaximized() ? + kProfileElementMaximizedYOffset : 0; + profile_button_->SetBounds( + x_tag, + y_tag + y_maximized_offset, + profile_button_->GetPreferredSize().width(), + profile_button_->GetPreferredSize().height()); + profile_tag_->SetVisible(true); + profile_tag_->SetBounds( + x_tag, + kProfileTagYPosition + y_maximized_offset, + profile_button_->GetPreferredSize().width(), + ProfileTagView::kProfileTagHeight); + } else { + profile_button_->SetVisible(false); + profile_tag_->SetVisible(false); + } +} + gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, int height) const { int top_height = NonClientTopBorderHeight(false, false); @@ -1104,3 +1194,18 @@ gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, std::max(0, height - GetReservedHeight() - top_height - border_thickness)); } + +void OpaqueBrowserFrameView::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + DCHECK_EQ(NotificationType::PREF_CHANGED, type.value); + std::string* name = Details<std::string>(details).ptr(); + if (prefs::kGoogleServicesUsername == *name) + LayoutProfileTag(); +} + +void OpaqueBrowserFrameView::RegisterLoginNotifications() { + PrefService* pref_service = browser_view_->browser()->profile()->GetPrefs(); + DCHECK(pref_service); + username_pref_.Init(prefs::kGoogleServicesUsername, pref_service, this); +} diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h index 77b2114..088040e3 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h @@ -6,16 +6,22 @@ #define CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ #pragma once +#include "base/scoped_ptr.h" +#include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" #include "chrome/browser/ui/views/tab_icon_view.h" #include "views/controls/button/button.h" +#include "views/controls/menu/view_menu_delegate.h" #include "views/window/non_client_view.h" class BrowserView; namespace gfx { class Font; } +class ProfileMenuButton; +class ProfileMenuModel; +class ProfileTagView; class TabContents; namespace views { class ImageButton; @@ -23,7 +29,9 @@ class ImageView; } class OpaqueBrowserFrameView : public BrowserNonClientFrameView, + public NotificationObserver, public views::ButtonListener, + public views::ViewMenuDelegate, public TabIconView::TabIconViewModel { public: // Constructs a non-client view for an BrowserFrame. @@ -82,6 +90,9 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView, virtual void ResetWindowControls() OVERRIDE; virtual void UpdateWindowIcon() OVERRIDE; + // Overridden from views::ViewMenuDelegate: + virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; + // Overridden from views::View: virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; virtual void Layout() OVERRIDE; @@ -141,10 +152,22 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView, void LayoutWindowControls(); void LayoutTitleBar(); void LayoutOTRAvatar(); + void LayoutProfileTag(); // Returns the bounds of the client area for the specified view size. gfx::Rect CalculateClientAreaBounds(int width, int height) const; + // NotificationObserver implementation: + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) OVERRIDE; + + // Receive notifications when the user's Google services user name changes. + void RegisterLoginNotifications(); + + // Returns true if the ProfileButton has been created. + bool show_profile_button() const { return profile_button_.get() != NULL; } + // The layout rect of the title, if visible. gfx::Rect title_bounds_; @@ -169,6 +192,18 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView, // The bounds of the ClientView. gfx::Rect client_view_bounds_; + // Menu button that displays user's name and multi-profile menu. + scoped_ptr<ProfileMenuButton> profile_button_; + + // Image tag displayed on frame beneath profile_button_. + scoped_ptr<ProfileTagView> profile_tag_; + + // Multi-profile menu for profile_button_. + scoped_ptr<ProfileMenuModel> profile_menu_model_; + + // The Google services user name associated with this BrowserView's profile. + StringPrefMember username_pref_; + DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameView); }; diff --git a/chrome/browser/ui/views/profile_menu_button.cc b/chrome/browser/ui/views/profile_menu_button.cc index 7cf6340..f322aaa 100644 --- a/chrome/browser/ui/views/profile_menu_button.cc +++ b/chrome/browser/ui/views/profile_menu_button.cc @@ -4,6 +4,8 @@ #include "chrome/browser/ui/views/profile_menu_button.h" +#include "chrome/browser/themes/theme_service.h" +#include "chrome/browser/themes/theme_service_factory.h" #include "ui/base/text/text_elider.h" #include "ui/gfx/color_utils.h" #include "views/controls/button/button.h" @@ -11,10 +13,13 @@ namespace { -// ActiveTextShadow is a darkened version of hsl_active_shift. -const SkColor kActiveTextShadow = 0xFF708DB3; -// InactiveTextShadow is slightly darker than grey-white inactive background. -const SkColor kInactiveTextShadow = SK_ColorLTGRAY; +// DefaultActiveTextShadow is a darkened blue color that works with Windows +// default theme background coloring. +const SkColor kDefaultActiveTextShadow = 0xFF708DB3; +// InactiveTextShadow is a light gray for inactive default themed buttons. +const SkColor kDefaultInactiveTextShadow = SK_ColorLTGRAY; +// DarkTextShadow is used to shadow names on themed browser frames. +const SkColor kDarkTextShadow = SK_ColorDKGRAY; // TextHover is slightly darker than enabled color, for a subtle hover shift. const SkColor kTextHover = 0xFFDDDDDD; const SkColor kTextEnabled = SK_ColorWHITE; @@ -28,17 +33,23 @@ const int kProfileButtonBorderSpacing = 10; const int kMaxTextWidth = 200; } -namespace views { - -ProfileMenuButton::ProfileMenuButton(ButtonListener* listener, +ProfileMenuButton::ProfileMenuButton(views::ButtonListener* listener, const std::wstring& text, - ViewMenuDelegate* menu_delegate) : - MenuButton(listener, text, menu_delegate, true) { + views::ViewMenuDelegate* menu_delegate, + Profile* profile) + : MenuButton(listener, text, menu_delegate, true) { // Turn off hover highlighting and position button in the center of the // underlying profile tag image. set_border(views::Border::CreateEmptyBorder( 0, kProfileButtonBorderSpacing, 0, kProfileButtonBorderSpacing)); - SetTextShadowColors(kActiveTextShadow, kInactiveTextShadow); + + ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); + if (theme_service->UsingDefaultTheme() || + theme_service->UsingNativeTheme()) { + SetTextShadowColors(kDefaultActiveTextShadow, kDefaultInactiveTextShadow); + } else { + SetTextShadowColors(kDarkTextShadow, kDarkTextShadow); + } SetHoverColor(kTextHover); SetEnabledColor(kTextEnabled); SetHighlightColor(kTextHighlighted); @@ -47,8 +58,7 @@ ProfileMenuButton::ProfileMenuButton(ButtonListener* listener, ProfileMenuButton::~ProfileMenuButton() {} void ProfileMenuButton::SetText(const std::wstring& text) { - MenuButton::SetText(ui::ElideText(text, font(), kMaxTextWidth, false)); + MenuButton::SetText(UTF16ToWideHack(ui::ElideText(WideToUTF16Hack(text), + font(), kMaxTextWidth, false))); } -} // namespace views - diff --git a/chrome/browser/ui/views/profile_menu_button.h b/chrome/browser/ui/views/profile_menu_button.h index e7fc4b6..3295c55 100644 --- a/chrome/browser/ui/views/profile_menu_button.h +++ b/chrome/browser/ui/views/profile_menu_button.h @@ -10,25 +10,26 @@ #include "views/controls/button/menu_button.h" +class Profile; + namespace gfx { class Canvas; } -namespace views { - // ProfileMenuButton // // Shows the button for the multiprofile menu with an image layered // underneath that displays the profile tag. -class ProfileMenuButton : public MenuButton { +class ProfileMenuButton : public views::MenuButton { public: // Space between window controls and end of profile tag. static const int kProfileTagHorizontalSpacing = 5; - ProfileMenuButton(ButtonListener* listener, + ProfileMenuButton(views::ButtonListener* listener, const std::wstring& text, - ViewMenuDelegate* menu_delegate); + views::ViewMenuDelegate* menu_delegate, + Profile* profile); virtual ~ProfileMenuButton(); @@ -39,7 +40,5 @@ class ProfileMenuButton : public MenuButton { DISALLOW_COPY_AND_ASSIGN(ProfileMenuButton); }; -} // namespace views - #endif // CHROME_BROWSER_UI_VIEWS_PROFILE_MENU_BUTTON_H_ diff --git a/chrome/browser/ui/views/profile_menu_model.cc b/chrome/browser/ui/views/profile_menu_model.cc index 8c29c3a..1371371 100644 --- a/chrome/browser/ui/views/profile_menu_model.cc +++ b/chrome/browser/ui/views/profile_menu_model.cc @@ -12,8 +12,6 @@ #include "ui/base/models/simple_menu_model.h" #include "views/controls/menu/menu_2.h" -namespace views { - ProfileMenuModel::ProfileMenuModel() : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)) { AddItem(COMMAND_CREATE_NEW_PROFILE, l10n_util::GetStringUTF16( @@ -51,5 +49,3 @@ void ProfileMenuModel::ExecuteCommand(int command_id) { break; } } - -} // namespace views diff --git a/chrome/browser/ui/views/profile_menu_model.h b/chrome/browser/ui/views/profile_menu_model.h index 7ee2203..fdda706 100644 --- a/chrome/browser/ui/views/profile_menu_model.h +++ b/chrome/browser/ui/views/profile_menu_model.h @@ -15,6 +15,7 @@ class Accelerator; namespace views { class Menu2; +} // ProfileMenuModel // @@ -47,8 +48,6 @@ class ProfileMenuModel : public ui::SimpleMenuModel, DISALLOW_COPY_AND_ASSIGN(ProfileMenuModel); }; -} // namespace views - #endif // CHROME_BROWSER_UI_VIEWS_PROFILE_MENU_MODEL_H_ diff --git a/chrome/browser/ui/views/profile_tag_view.cc b/chrome/browser/ui/views/profile_tag_view.cc index eab9e41..ae65925 100644 --- a/chrome/browser/ui/views/profile_tag_view.cc +++ b/chrome/browser/ui/views/profile_tag_view.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ui/views/profile_tag_view.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/profile_menu_button.h" #include "grit/theme_resources.h" @@ -18,10 +19,8 @@ namespace { color_utils::HSL hsl_active_shift = { 0.594, 0.5, 0.5 }; } -namespace views { - ProfileTagView::ProfileTagView(BrowserFrame* frame, - views::ProfileMenuButton* profile_menu_button) + ProfileMenuButton* profile_menu_button) : profile_tag_bitmaps_created_(false), frame_(frame), profile_menu_button_(profile_menu_button) { @@ -36,8 +35,6 @@ void ProfileTagView::OnPaint(gfx::Canvas* canvas) { int tag_width = profile_menu_button_->GetPreferredSize().width(); int center_tag_width = tag_width - active_profile_tag_left_.width() - active_profile_tag_right_.width(); - int tag_x = frame_->GetMinimizeButtonOffset() - tag_width - - views::ProfileMenuButton::kProfileTagHorizontalSpacing; bool is_active = GetWidget()->IsActive(); SkBitmap* profile_tag_left = is_active ? &active_profile_tag_left_ : @@ -47,6 +44,18 @@ void ProfileTagView::OnPaint(gfx::Canvas* canvas) { SkBitmap* profile_tag_right = is_active ? &active_profile_tag_right_ : &inactive_profile_tag_right_; + if (!active_profile_tag_left_background_.empty()) { + canvas->DrawBitmapInt(active_profile_tag_left_background_, 0, 0); + canvas->DrawBitmapInt(active_profile_tag_center_background_, 0, 0, + profile_tag_center->width(), + profile_tag_center->height(), + profile_tag_left->width(), 0, + center_tag_width, + profile_tag_center->height(), true); + canvas->DrawBitmapInt(active_profile_tag_right_background_, + profile_tag_left->width() + center_tag_width, 0); + } + canvas->DrawBitmapInt(*profile_tag_left, 0, 0); canvas->DrawBitmapInt(*profile_tag_center, 0, 0, profile_tag_center->width(), @@ -66,27 +75,67 @@ void ProfileTagView::CreateProfileTagBitmaps() { profile_tag_bitmaps_created_ = true; ui::ThemeProvider* theme_provider = frame_->GetThemeProviderForFrame(); - SkBitmap* profile_tag_center = theme_provider->GetBitmapNamed( - IDR_PROFILE_TAG_CENTER); - SkBitmap* profile_tag_left = theme_provider->GetBitmapNamed( - IDR_PROFILE_TAG_LEFT); - SkBitmap* profile_tag_right = theme_provider->GetBitmapNamed( - IDR_PROFILE_TAG_RIGHT); - inactive_profile_tag_center_ = *theme_provider->GetBitmapNamed( - IDR_PROFILE_TAG_INACTIVE_CENTER); - inactive_profile_tag_left_ = *theme_provider->GetBitmapNamed( - IDR_PROFILE_TAG_INACTIVE_LEFT); - inactive_profile_tag_right_ = *theme_provider->GetBitmapNamed( - IDR_PROFILE_TAG_INACTIVE_RIGHT); + bool aero = theme_provider->ShouldUseNativeFrame(); + SkBitmap* profile_tag_center = aero ? + theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_CENTER_AERO) : + theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_CENTER_THEMED); + SkBitmap* profile_tag_left = aero ? + theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_LEFT_AERO) : + theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_LEFT_THEMED); + SkBitmap* profile_tag_right = aero ? + theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_RIGHT_AERO) : + theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_RIGHT_THEMED); + inactive_profile_tag_center_ = aero ? + *theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_INACTIVE_CENTER_AERO) : + *theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_CENTER_THEMED); + inactive_profile_tag_left_ = aero ? + *theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_INACTIVE_LEFT_AERO) : + *theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_LEFT_THEMED); + inactive_profile_tag_right_ = aero ? + *theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_INACTIVE_RIGHT_AERO) : + *theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_RIGHT_THEMED); - // Color active bitmap according to profile. TODO(mirandac): add theming - // and multi-profile color schemes. - active_profile_tag_center_ = SkBitmapOperations::CreateHSLShiftedBitmap( - *profile_tag_center, hsl_active_shift); - active_profile_tag_left_ = SkBitmapOperations::CreateHSLShiftedBitmap( - *profile_tag_left, hsl_active_shift); - active_profile_tag_right_ = SkBitmapOperations::CreateHSLShiftedBitmap( - *profile_tag_right, hsl_active_shift); -} + // Color if we're using the Aero theme; otherwise the tag will be given by + // the window controls background from the theme. + if (theme_provider->ShouldUseNativeFrame()) { + active_profile_tag_center_ = SkBitmapOperations::CreateHSLShiftedBitmap( + *profile_tag_center, hsl_active_shift); + active_profile_tag_left_ = SkBitmapOperations::CreateHSLShiftedBitmap( + *profile_tag_left, hsl_active_shift); + active_profile_tag_right_ = SkBitmapOperations::CreateHSLShiftedBitmap( + *profile_tag_right, hsl_active_shift); -} // namespace views + // No backgrounds used in Aero theme. + active_profile_tag_center_background_.reset(); + active_profile_tag_left_background_.reset(); + active_profile_tag_center_background_.reset(); + } else { + active_profile_tag_center_ = *profile_tag_center; + active_profile_tag_left_ = *profile_tag_left; + active_profile_tag_right_ = *profile_tag_right; + + SkBitmap* background = theme_provider->GetBitmapNamed( + IDR_THEME_WINDOW_CONTROL_BACKGROUND); + if (!background) { + active_profile_tag_center_background_.reset(); + active_profile_tag_left_background_.reset(); + active_profile_tag_center_background_.reset(); + } else { + active_profile_tag_center_background_ = + SkBitmapOperations::CreateButtonBackground( + theme_provider->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND), + *background, + *(theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_CENTER_MASK))); + active_profile_tag_left_background_ = + SkBitmapOperations::CreateButtonBackground( + theme_provider->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND), + *background, + *(theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_LEFT_MASK))); + active_profile_tag_right_background_ = + SkBitmapOperations::CreateButtonBackground( + theme_provider->GetColor(ThemeService::COLOR_BUTTON_BACKGROUND), + *background, + *(theme_provider->GetBitmapNamed(IDR_PROFILE_TAG_RIGHT_MASK))); + } + } +} diff --git a/chrome/browser/ui/views/profile_tag_view.h b/chrome/browser/ui/views/profile_tag_view.h index a3652c3..8012cb4 100644 --- a/chrome/browser/ui/views/profile_tag_view.h +++ b/chrome/browser/ui/views/profile_tag_view.h @@ -10,26 +10,23 @@ #include "views/view.h" class BrowserFrame; +class ProfileMenuButton; namespace gfx { class Canvas; } -namespace views { - -class ProfileMenuButton; - // ProfileTag // // Displays the tinted button image underneath the ProfileMenuButton. -class ProfileTagView : public View { +class ProfileTagView : public views::View { public: // Height of profile tag. static const int kProfileTagHeight = 20; ProfileTagView(BrowserFrame* frame, - views::ProfileMenuButton* profile_menu_button); + ProfileMenuButton* profile_menu_button); ~ProfileTagView() {} // Paint the profile tag background image on the given canvas. @@ -49,17 +46,19 @@ class ProfileTagView : public View { SkBitmap inactive_profile_tag_center_; SkBitmap inactive_profile_tag_left_; SkBitmap inactive_profile_tag_right_; + // Bitmaps used for a themed profile background. + SkBitmap active_profile_tag_center_background_; + SkBitmap active_profile_tag_left_background_; + SkBitmap active_profile_tag_right_background_; // The frame that hosts this view. BrowserFrame* frame_; // The button to be displayed above this view. - views::ProfileMenuButton* profile_menu_button_; + ProfileMenuButton* profile_menu_button_; DISALLOW_COPY_AND_ASSIGN(ProfileTagView); }; -} // namespace views - #endif // CHROME_BROWSER_UI_VIEWS_PROFILE_TAG_VIEW_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 7c5dffe..876fde5 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -3088,12 +3088,12 @@ 'browser/ui/views/page_info_bubble_view.h', 'browser/ui/views/pinned_contents_info_bubble.cc', 'browser/ui/views/pinned_contents_info_bubble.h', - 'browser/ui/views/profile_menu_button.h', 'browser/ui/views/profile_menu_button.cc', - 'browser/ui/views/profile_menu_model.h', + 'browser/ui/views/profile_menu_button.h', 'browser/ui/views/profile_menu_model.cc', - 'browser/ui/views/profile_tag_view.h', + 'browser/ui/views/profile_menu_model.h', 'browser/ui/views/profile_tag_view.cc', + 'browser/ui/views/profile_tag_view.h', 'browser/ui/views/reload_button.cc', 'browser/ui/views/reload_button.h', 'browser/ui/views/repost_form_warning_view.cc', @@ -4096,6 +4096,12 @@ ['include', '^browser/ui/views/panels/panel_scroller_header.h'], ['include', '^browser/ui/views/pinned_contents_info_bubble.cc'], ['include', '^browser/ui/views/pinned_contents_info_bubble.h'], + ['include', '^browser/ui/views/profile_menu_button.cc'], + ['include', '^browser/ui/views/profile_menu_button.h'], + ['include', '^browser/ui/views/profile_menu_model.cc'], + ['include', '^browser/ui/views/profile_menu_model.h'], + ['include', '^browser/ui/views/profile_tag_view.cc'], + ['include', '^browser/ui/views/profile_tag_view.h'], ['include', '^browser/ui/views/reload_button.cc'], ['include', '^browser/ui/views/reload_button.h'], ['include', '^browser/ui/views/restart_message_box.cc'], |