summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-20 21:08:10 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-20 21:08:10 +0000
commit3c558d680677ccb42ce8481ae6da715f7e0cb9f0 (patch)
treefe5ae84a600216db0275df7c6cd2a1847ad12e6b /chrome
parentd1e535af433f6620de233f7e08619f8b0340d3bb (diff)
downloadchromium_src-3c558d680677ccb42ce8481ae6da715f7e0cb9f0.zip
chromium_src-3c558d680677ccb42ce8481ae6da715f7e0cb9f0.tar.gz
chromium_src-3c558d680677ccb42ce8481ae6da715f7e0cb9f0.tar.bz2
Ash: Add avatar icon for incognito mode
Implementation is similar to OpaqueBrowserFrameView but with slightly different layout. BUG=118517 TEST=visual, open incognito window, check restored and maximized windows R=sky@chromium.org Review URL: http://codereview.chromium.org/9766001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127781 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc44
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h3
2 files changed, 43 insertions, 4 deletions
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc
index 607c9ca..c4410c6 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc
@@ -7,6 +7,7 @@
#include "ash/wm/frame_painter.h"
#include "ash/wm/workspace/frame_maximize_button.h"
#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/ui/views/avatar_menu_button.h"
#include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "content/public/browser/web_contents.h"
@@ -25,6 +26,13 @@
namespace {
+// The avatar ends 2 px above the bottom of the tabstrip (which, given the
+// way the tabstrip draws its bottom edge, will appear like a 1 px gap to the
+// user).
+const int kAvatarBottomSpacing = 2;
+// There are 2 px on each side of the avatar (between the frame border and
+// it on the left, and between it and the tabstrip on the right).
+const int kAvatarSideSpacing = 2;
// Space between left edge of window and tabstrip.
const int kTabstripLeftSpacing = 4;
// Space between right edge of tabstrip and maximize button.
@@ -35,7 +43,8 @@ const int kTabstripTopSpacingRestored = 10;
// Place them flush to the top to make them clickable when the cursor is at
// the screen edge.
const int kTabstripTopSpacingMaximized = 0;
-
+// Height of the shadow of the tab images in the tab strip.
+const int kTabShadowHeight = 1;
} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -72,6 +81,9 @@ void BrowserNonClientFrameViewAura::Init() {
window_icon_->Update();
}
+ // Create incognito icon if necessary.
+ UpdateAvatarInfo();
+
// Frame painter handles layout of these buttons.
frame_painter_->Init(frame(), window_icon_, maximize_button_, close_button_);
}
@@ -83,9 +95,15 @@ gfx::Rect BrowserNonClientFrameViewAura::GetBoundsForTabStrip(
views::View* tabstrip) const {
if (!tabstrip)
return gfx::Rect();
- return gfx::Rect(kTabstripLeftSpacing,
+ int tabstrip_x =
+ avatar_button() ?
+ (avatar_button()->bounds().right() + kAvatarSideSpacing) :
+ kTabstripLeftSpacing;
+ int tabstrip_width =
+ maximize_button_->x() - kTabstripRightSpacing - tabstrip_x;
+ return gfx::Rect(tabstrip_x,
GetHorizontalTabStripVerticalOffset(false),
- std::max(0, maximize_button_->x() - kTabstripRightSpacing),
+ std::max(0, tabstrip_width),
tabstrip->GetPreferredSize().height());
}
@@ -155,7 +173,8 @@ void BrowserNonClientFrameViewAura::Layout() {
bool maximized_layout =
frame()->IsMaximized() || !browser_view()->IsBrowserTypeNormal();
frame_painter_->LayoutHeader(this, maximized_layout);
-
+ if (avatar_button())
+ LayoutAvatar();
BrowserNonClientFrameView::Layout();
}
@@ -243,6 +262,23 @@ int BrowserNonClientFrameViewAura::NonClientTopBorderHeight(
return kTabstripTopSpacingMaximized;
}
+void BrowserNonClientFrameViewAura::LayoutAvatar() {
+ DCHECK(avatar_button());
+ SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon();
+
+ int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) +
+ browser_view()->GetTabStripHeight() - kAvatarBottomSpacing;
+ int avatar_restored_y = avatar_bottom - incognito_icon.height();
+ int avatar_y = frame()->IsMaximized() ?
+ NonClientTopBorderHeight(false) + kTabShadowHeight:
+ avatar_restored_y;
+ gfx::Rect avatar_bounds(kAvatarSideSpacing,
+ avatar_y,
+ incognito_icon.width(),
+ avatar_bottom - avatar_y);
+ avatar_button()->SetBoundsRect(avatar_bounds);
+}
+
void BrowserNonClientFrameViewAura::PaintToolbarBackground(
gfx::Canvas* canvas) {
gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h
index a434754..2be2f9d 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h
@@ -62,6 +62,9 @@ class BrowserNonClientFrameViewAura : public BrowserNonClientFrameView,
// Distance between top of window and client area.
int NonClientTopBorderHeight(bool force_restored) const;
+ // Layout the incognito icon.
+ void LayoutAvatar();
+
void PaintTitleBar(gfx::Canvas* canvas);
void PaintToolbarBackground(gfx::Canvas* canvas);