Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(784)

Side by Side Diff: chrome/browser/ui/views/frame/glass_browser_frame_view.cc

Issue 2851543002: Update avatar button to MD (part 1) (Closed)
Patch Set: Merged ThemedAvatarButton and Win10NativeAvatarButton into the base AvatarButton class Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 namespace { 42 namespace {
43 // Thickness of the frame edge between the non-client area and the web content. 43 // Thickness of the frame edge between the non-client area and the web content.
44 const int kClientBorderThickness = 3; 44 const int kClientBorderThickness = 3;
45 // Besides the frame border, there's empty space atop the window in restored 45 // Besides the frame border, there's empty space atop the window in restored
46 // mode, to use to drag the window around. 46 // mode, to use to drag the window around.
47 const int kNonClientRestoredExtraThickness = 11; 47 const int kNonClientRestoredExtraThickness = 11;
48 // At the window corners the resize area is not actually bigger, but the 16 48 // At the window corners the resize area is not actually bigger, but the 16
49 // pixels at the end of the top and bottom edges trigger diagonal resizing. 49 // pixels at the end of the top and bottom edges trigger diagonal resizing.
50 const int kResizeCornerWidth = 16; 50 const int kResizeCornerWidth = 16;
51 // How far the profile switcher button is from the left of the minimize button. 51 // How far the profile switcher button is from the left of the minimize button.
52 const int kProfileSwitcherButtonOffset = 5; 52 const int kProfileSwitcherButtonOffset = 1;
53 // The content edge images have a shadow built into them. 53 // The content edge images have a shadow built into them.
54 const int kContentEdgeShadowThickness = 2; 54 const int kContentEdgeShadowThickness = 2;
55 // In restored mode, the New Tab button isn't at the same height as the caption 55 // In restored mode, the New Tab button isn't at the same height as the caption
56 // buttons, but the space will look cluttered if it actually slides under them, 56 // buttons, but the space will look cluttered if it actually slides under them,
57 // so we stop it when the gap between the two is down to 5 px. 57 // so we stop it when the gap between the two is down to 5 px.
58 const int kNewTabCaptionRestoredSpacing = 5; 58 const int kNewTabCaptionRestoredSpacing = 5;
59 // In maximized mode, where the New Tab button and the caption buttons are at 59 // In maximized mode, where the New Tab button and the caption buttons are at
60 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid 60 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid
61 // looking too cluttered. 61 // looking too cluttered.
62 const int kNewTabCaptionMaximizedSpacing = 16; 62 const int kNewTabCaptionMaximizedSpacing = 16;
63 // Height of the profile switcher button. Same as the height of the Windows 7/8
64 // caption buttons.
65 // TODO(bsep): Windows 10 caption buttons look very different and we would like
66 // the profile switcher button to match on that platform.
67 const int kProfileSwitcherButtonHeight = 20;
68 // There is a small one-pixel strip right above the caption buttons in which the 63 // There is a small one-pixel strip right above the caption buttons in which the
69 // resize border "peeks" through. 64 // resize border "peeks" through.
70 const int kCaptionButtonTopInset = 1; 65 const int kCaptionButtonTopInset = 1;
71 66
72 // Converts the |image| to a Windows icon and returns the corresponding HICON 67 // Converts the |image| to a Windows icon and returns the corresponding HICON
73 // handle. |image| is resized to desired |width| and |height| if needed. 68 // handle. |image| is resized to desired |width| and |height| if needed.
74 base::win::ScopedHICON CreateHICONFromSkBitmapSizedTo( 69 base::win::ScopedHICON CreateHICONFromSkBitmapSizedTo(
75 const gfx::ImageSkia& image, 70 const gfx::ImageSkia& image,
76 int width, 71 int width,
77 int height) { 72 int height) {
(...skipping 14 matching lines...) Expand all
92 BrowserView* browser_view) 87 BrowserView* browser_view)
93 : BrowserNonClientFrameView(frame, browser_view), 88 : BrowserNonClientFrameView(frame, browser_view),
94 window_icon_(nullptr), 89 window_icon_(nullptr),
95 window_title_(nullptr), 90 window_title_(nullptr),
96 profile_switcher_(this), 91 profile_switcher_(this),
97 minimize_button_(nullptr), 92 minimize_button_(nullptr),
98 maximize_button_(nullptr), 93 maximize_button_(nullptr),
99 restore_button_(nullptr), 94 restore_button_(nullptr),
100 close_button_(nullptr), 95 close_button_(nullptr),
101 throbber_running_(false), 96 throbber_running_(false),
102 throbber_frame_(0) { 97 throbber_frame_(0),
98 tab_strip_(nullptr) {
103 // We initialize all fields despite some of them being unused in some modes, 99 // We initialize all fields despite some of them being unused in some modes,
104 // since it's possible for modes to flip dynamically (e.g. if the user enables 100 // since it's possible for modes to flip dynamically (e.g. if the user enables
105 // a high-contrast theme). Throbber icons are only used when ShowSystemIcon() 101 // a high-contrast theme). Throbber icons are only used when ShowSystemIcon()
106 // is true. Everything else here is only used when 102 // is true. Everything else here is only used when
107 // ShouldCustomDrawSystemTitlebar() is true. 103 // ShouldCustomDrawSystemTitlebar() is true.
108 104
109 if (browser_view->ShouldShowWindowIcon()) { 105 if (browser_view->ShouldShowWindowIcon()) {
110 InitThrobberIcons(); 106 InitThrobberIcons();
111 107
112 window_icon_ = new TabIconView(this, nullptr); 108 window_icon_ = new TabIconView(this, nullptr);
(...skipping 12 matching lines...) Expand all
125 AddChildView(window_title_); 121 AddChildView(window_title_);
126 } 122 }
127 123
128 minimize_button_ = CreateCaptionButton(VIEW_ID_MINIMIZE_BUTTON); 124 minimize_button_ = CreateCaptionButton(VIEW_ID_MINIMIZE_BUTTON);
129 maximize_button_ = CreateCaptionButton(VIEW_ID_MAXIMIZE_BUTTON); 125 maximize_button_ = CreateCaptionButton(VIEW_ID_MAXIMIZE_BUTTON);
130 restore_button_ = CreateCaptionButton(VIEW_ID_RESTORE_BUTTON); 126 restore_button_ = CreateCaptionButton(VIEW_ID_RESTORE_BUTTON);
131 close_button_ = CreateCaptionButton(VIEW_ID_CLOSE_BUTTON); 127 close_button_ = CreateCaptionButton(VIEW_ID_CLOSE_BUTTON);
132 } 128 }
133 129
134 GlassBrowserFrameView::~GlassBrowserFrameView() { 130 GlassBrowserFrameView::~GlassBrowserFrameView() {
131 if (tab_strip_) {
132 tab_strip_->RemoveObserver(this);
133 tab_strip_ = nullptr;
Evan Stade 2017/05/04 15:56:28 not sure I understand why nulling this out is nece
Peter Kasting 2017/05/06 02:23:08 This; also, ScopedObserver (as Evan wisely suggest
emx 2017/05/09 16:26:51 OK, now using ScopedObserver, so the destructor is
134 }
135 } 135 }
136 136
137 /////////////////////////////////////////////////////////////////////////////// 137 ///////////////////////////////////////////////////////////////////////////////
138 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: 138 // GlassBrowserFrameView, BrowserNonClientFrameView implementation:
139 139
140 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( 140 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
141 views::View* tabstrip) const { 141 views::View* tabstrip) const {
142 const int x = incognito_bounds_.right() + kAvatarIconPadding; 142 const int x = incognito_bounds_.right() + kAvatarIconPadding;
143 int end_x = width() - ClientBorderThickness(false); 143 int end_x = width() - ClientBorderThickness(false);
144 if (!CaptionButtonsOnLeadingEdge()) { 144 if (!CaptionButtonsOnLeadingEdge()) {
145 end_x = std::min(MinimizeButtonX(), end_x) - 145 end_x = std::min(MinimizeButtonX(), end_x) -
146 (IsMaximized() ? kNewTabCaptionMaximizedSpacing 146 (IsMaximized() ? kNewTabCaptionMaximizedSpacing
147 : kNewTabCaptionRestoredSpacing); 147 : kNewTabCaptionRestoredSpacing);
148 148
149 // The profile switcher button is optionally displayed to the left of the 149 // The profile switcher button is optionally displayed to the left of the
150 // minimize button. 150 // minimize button.
151 if (profile_switcher_.view()) { 151 views::View* button_view = GetProfileSwitcherView();
Peter Kasting 2017/05/06 02:23:08 Nit: |profile_switcher| seems like a better name.
emx 2017/05/09 16:26:51 Done.
152 if (button_view) {
152 const int old_end_x = end_x; 153 const int old_end_x = end_x;
153 end_x -= profile_switcher_.view()->width() + kProfileSwitcherButtonOffset; 154 end_x -= button_view->width() + kProfileSwitcherButtonOffset;
154 155
155 // In non-maximized mode, allow the new tab button to slide completely 156 // In non-maximized mode, allow the new tab button to slide completely
156 // under the profile switcher button. 157 // under the profile switcher button.
158 // Note that the button should be "cozy" then, even if it's an MD button.
Peter Kasting 2017/05/06 02:23:08 What does "cozy" mean, and why would it being or n
emx 2017/05/09 16:26:51 Removed the line.
157 if (!IsMaximized()) { 159 if (!IsMaximized()) {
158 end_x = std::min(end_x + GetLayoutSize(NEW_TAB_BUTTON).width() + 160 end_x = std::min(end_x + GetLayoutSize(NEW_TAB_BUTTON).width() +
159 kNewTabCaptionRestoredSpacing, 161 kNewTabCaptionRestoredSpacing,
160 old_end_x); 162 old_end_x);
161 } 163 }
162 } 164 }
163 } 165 }
164 return gfx::Rect(x, TopAreaHeight(false), std::max(0, end_x - x), 166 return gfx::Rect(x, TopAreaHeight(false), std::max(0, end_x - x),
165 tabstrip->GetPreferredSize().height()); 167 tabstrip->GetPreferredSize().height());
166 } 168 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 min_size.set_width(std::max(min_tabstrip_area_width, min_size.width())); 212 min_size.set_width(std::max(min_tabstrip_area_width, min_size.width()));
211 } 213 }
212 214
213 return min_size; 215 return min_size;
214 } 216 }
215 217
216 views::View* GlassBrowserFrameView::GetProfileSwitcherView() const { 218 views::View* GlassBrowserFrameView::GetProfileSwitcherView() const {
217 return profile_switcher_.view(); 219 return profile_switcher_.view();
218 } 220 }
219 221
222 void GlassBrowserFrameView::OnBrowserViewInitViewsComplete() {
223 DCHECK(browser_view()->tabstrip());
Peter Kasting 2017/05/06 02:23:08 Are you sure you always get a tabstrip? What abou
emx 2017/05/09 16:26:51 I got a tabstrip even in a pop-up on that page, bu
224 DCHECK(!tab_strip_);
225 tab_strip_ = browser_view()->tabstrip();
Evan Stade 2017/05/04 15:56:28 why do you need this instead of just referencing b
emx 2017/05/09 16:26:51 Done.
226 tab_strip_->AddObserver(this);
227 }
228
220 /////////////////////////////////////////////////////////////////////////////// 229 ///////////////////////////////////////////////////////////////////////////////
221 // GlassBrowserFrameView, views::NonClientFrameView implementation: 230 // GlassBrowserFrameView, views::NonClientFrameView implementation:
222 231
223 gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const { 232 gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const {
224 return client_view_bounds_; 233 return client_view_bounds_;
225 } 234 }
226 235
227 gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds( 236 gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds(
228 const gfx::Rect& client_bounds) const { 237 const gfx::Rect& client_bounds) const {
229 HWND hwnd = views::HWNDForWidget(frame()); 238 HWND hwnd = views::HWNDForWidget(frame());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 return HTNOWHERE; 272 return HTNOWHERE;
264 273
265 // If the point isn't within our bounds, then it's in the native portion of 274 // If the point isn't within our bounds, then it's in the native portion of
266 // the frame so again Windows can figure it out. 275 // the frame so again Windows can figure it out.
267 if (!bounds().Contains(point)) 276 if (!bounds().Contains(point))
268 return HTNOWHERE; 277 return HTNOWHERE;
269 278
270 // See if the point is within the incognito icon or the profile switcher menu. 279 // See if the point is within the incognito icon or the profile switcher menu.
271 if ((profile_indicator_icon() && 280 if ((profile_indicator_icon() &&
272 profile_indicator_icon()->GetMirroredBounds().Contains(point)) || 281 profile_indicator_icon()->GetMirroredBounds().Contains(point)) ||
273 (profile_switcher_.view() && 282 (GetProfileSwitcherView() &&
Peter Kasting 2017/05/06 02:23:08 Nit: I'm not a huge fan of changes like this in th
emx 2017/05/09 16:26:51 Reverted.
274 profile_switcher_.view()->GetMirroredBounds().Contains(point))) 283 GetProfileSwitcherView()->GetMirroredBounds().Contains(point)))
275 return HTCLIENT; 284 return HTCLIENT;
276 285
277 int frame_component = frame()->client_view()->NonClientHitTest(point); 286 int frame_component = frame()->client_view()->NonClientHitTest(point);
278 287
279 // See if we're in the sysmenu region. We still have to check the tabstrip 288 // See if we're in the sysmenu region. We still have to check the tabstrip
280 // first so that clicks in a tab don't get treated as sysmenu clicks. 289 // first so that clicks in a tab don't get treated as sysmenu clicks.
281 int client_border_thickness = ClientBorderThickness(false); 290 int client_border_thickness = ClientBorderThickness(false);
282 gfx::Rect sys_menu_region( 291 gfx::Rect sys_menu_region(
283 client_border_thickness, 292 client_border_thickness,
284 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CYSIZEFRAME), 293 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CYSIZEFRAME),
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 // must be called prior to LayoutProfileSwitcher(). 408 // must be called prior to LayoutProfileSwitcher().
400 LayoutCaptionButtons(); 409 LayoutCaptionButtons();
401 LayoutTitleBar(); 410 LayoutTitleBar();
402 } 411 }
403 if (browser_view()->IsRegularOrGuestSession()) 412 if (browser_view()->IsRegularOrGuestSession())
404 LayoutProfileSwitcher(); 413 LayoutProfileSwitcher();
405 LayoutIncognitoIcon(); 414 LayoutIncognitoIcon();
406 LayoutClientView(); 415 LayoutClientView();
407 } 416 }
408 417
418 void GlassBrowserFrameView::ChildPreferredSizeChanged(views::View* child) {
419 if (child == GetProfileSwitcherView()) {
420 // Need to layout the root view here, too, as the avatar button may change
421 // between the text and the icon when a profile is added or removed, which
422 // may in turn cause it to change between "tall" and "cozy" if it's right
423 // near the end of the tabstrip. LayoutProfileSwitcher() is not enough
424 // here - it does not re-draw the line below the tabstrip properly when a
425 // profile is added or removed and the avatar button changes between tall
426 // and cozy as a result.
Peter Kasting 2017/05/06 02:23:08 This comment helps, but I'm still a bit confused b
emx 2017/05/09 16:26:51 No, in this case the tabstrip bounds don't change,
427 frame()->GetRootView()->Layout();
Peter Kasting 2017/05/06 02:23:08 Do we really need to layout the root view? If the
emx 2017/05/09 16:26:51 I don't know enough to answer that. What I can say
Peter Kasting 2017/05/09 17:40:28 Then while I don't want to burden you, I think you
emx 2017/05/10 17:38:48 I tried adding SchedulePaint(); and that's still n
Peter Kasting 2017/05/11 01:03:42 OK. Let's leave it doing a Layout on the root vie
emx 2017/05/11 12:56:10 Done.
Evan Stade 2017/05/11 14:29:09 I'm not the right one to dig deeper on this Window
Peter Kasting 2017/05/11 15:04:34 OK, for now have bsep own this.
428 }
429 }
430
409 /////////////////////////////////////////////////////////////////////////////// 431 ///////////////////////////////////////////////////////////////////////////////
410 // GlassBrowserFrameView, protected: 432 // GlassBrowserFrameView, protected:
411 433
412 // BrowserNonClientFrameView: 434 // BrowserNonClientFrameView:
413 void GlassBrowserFrameView::UpdateProfileIcons() { 435 void GlassBrowserFrameView::UpdateProfileIcons() {
414 if (browser_view()->IsRegularOrGuestSession()) 436 if (browser_view()->IsRegularOrGuestSession())
415 profile_switcher_.Update(AvatarButtonStyle::NATIVE); 437 profile_switcher_.Update(AvatarButtonStyle::NATIVE);
416 else 438 else
417 UpdateProfileIndicatorIcon(); 439 UpdateProfileIndicatorIcon();
418 } 440 }
419 441
420 /////////////////////////////////////////////////////////////////////////////// 442 ///////////////////////////////////////////////////////////////////////////////
421 // GlassBrowserFrameView, private: 443 // GlassBrowserFrameView, private:
422 444
423 // views::NonClientFrameView: 445 // views::NonClientFrameView:
424 bool GlassBrowserFrameView::DoesIntersectRect(const views::View* target, 446 bool GlassBrowserFrameView::DoesIntersectRect(const views::View* target,
425 const gfx::Rect& rect) const { 447 const gfx::Rect& rect) const {
426 if (ShouldCustomDrawSystemTitlebar()) 448 if (ShouldCustomDrawSystemTitlebar())
427 return BrowserNonClientFrameView::DoesIntersectRect(target, rect); 449 return BrowserNonClientFrameView::DoesIntersectRect(target, rect);
428 450
429 // TODO(bsep): This override has "dead zones" where you can't click on the 451 // TODO(bsep): This override has "dead zones" where you can't click on the
430 // custom titlebar buttons. It's not clear why it's necessary at all. 452 // custom titlebar buttons. It's not clear why it's necessary at all.
431 // Investigate tearing this out. 453 // Investigate tearing this out.
432 CHECK_EQ(target, this); 454 CHECK_EQ(target, this);
433 bool hit_incognito_icon = 455 bool hit_incognito_icon =
434 profile_indicator_icon() && 456 profile_indicator_icon() &&
435 profile_indicator_icon()->GetMirroredBounds().Intersects(rect); 457 profile_indicator_icon()->GetMirroredBounds().Intersects(rect);
436 bool hit_profile_switcher_button = 458 bool hit_profile_switcher_button =
437 profile_switcher_.view() && 459 GetProfileSwitcherView() &&
438 profile_switcher_.view()->GetMirroredBounds().Intersects(rect); 460 GetProfileSwitcherView()->GetMirroredBounds().Intersects(rect);
439 return hit_incognito_icon || hit_profile_switcher_button || 461 return hit_incognito_icon || hit_profile_switcher_button ||
440 !frame()->client_view()->bounds().Intersects(rect); 462 !frame()->client_view()->bounds().Intersects(rect);
441 } 463 }
442 464
443 int GlassBrowserFrameView::ClientBorderThickness(bool restored) const { 465 int GlassBrowserFrameView::ClientBorderThickness(bool restored) const {
444 // The frame ends abruptly at the 1 pixel window border drawn by Windows 10. 466 // The frame ends abruptly at the 1 pixel window border drawn by Windows 10.
445 if (!browser_view()->HasClientEdge()) 467 if (!browser_view()->HasClientEdge())
446 return 0; 468 return 0;
447 469
448 if ((IsMaximized() || frame()->IsFullscreen()) && !restored) 470 if ((IsMaximized() || frame()->IsFullscreen()) && !restored)
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 gfx::Canvas* canvas) const { 730 gfx::Canvas* canvas) const {
709 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness, 731 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness,
710 bottom + kClientEdgeThickness - y); 732 bottom + kClientEdgeThickness - y);
711 canvas->FillRect(side, color); 733 canvas->FillRect(side, color);
712 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness), 734 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness),
713 color); 735 color);
714 side.set_x(right); 736 side.set_x(right);
715 canvas->FillRect(side, color); 737 canvas->FillRect(side, color);
716 } 738 }
717 739
740 void GlassBrowserFrameView::TabStripMaxXChanged(TabStrip* tab_strip) {
741 // May switch between cozy and tall MD avatar button here.
Peter Kasting 2017/05/06 02:23:08 Nit: Avoid referring to "MD" in code ever, since i
emx 2017/05/09 16:26:51 Done.
742 DCHECK_EQ(tab_strip, tab_strip_);
Peter Kasting 2017/05/06 02:23:08 Nit: I'd remove this DCHECK and the similar ones b
emx 2017/05/09 16:26:51 Done.
743 LayoutProfileSwitcher();
744 }
745
746 void GlassBrowserFrameView::TabStripRemovedTabAt(TabStrip* tab_strip,
747 int index) {
748 // May switch between cozy and tall button here, too. TabStripMaxXChanged
749 // is not enough when a tab other than the last tab is closed.
Peter Kasting 2017/05/06 02:23:08 Hrm. This seems like it means that closing the la
emx 2017/05/09 16:26:51 Acknowledged.
750 DCHECK_EQ(tab_strip, tab_strip_);
751 LayoutProfileSwitcher();
752 }
753
754 void GlassBrowserFrameView::TabStripDeleted(TabStrip* tab_strip) {
Peter Kasting 2017/05/06 02:23:08 Does this happen before frame destruction?
emx 2017/05/09 16:26:51 I've never seen this method called at all, but I c
Peter Kasting 2017/05/09 17:40:28 Hmm. I think you should ask the author/OWNERs of
emx 2017/05/10 17:38:48 OK, I've asked him (it was sky@) and he said that
emx 2017/05/11 12:56:10 I've replaced the contents with a NOTREACHED().
755 DCHECK_EQ(tab_strip, tab_strip_);
756 DCHECK(tab_strip_);
757 tab_strip_->RemoveObserver(this);
758 tab_strip_ = nullptr;
759 }
760
718 void GlassBrowserFrameView::LayoutProfileSwitcher() { 761 void GlassBrowserFrameView::LayoutProfileSwitcher() {
719 DCHECK(browser_view()->IsRegularOrGuestSession()); 762 DCHECK(browser_view()->IsRegularOrGuestSession());
720 if (!profile_switcher_.view()) 763
764 View* button_view = GetProfileSwitcherView();
765 if (!button_view)
721 return; 766 return;
722 767
723 gfx::Size label_size = profile_switcher_.view()->GetPreferredSize(); 768 gfx::Size button_size = button_view->GetPreferredSize();
769 int button_width = button_size.width();
770 int button_height = button_size.height();
724 771
725 int button_x; 772 int button_x;
726 if (CaptionButtonsOnLeadingEdge()) { 773 if (CaptionButtonsOnLeadingEdge()) {
727 button_x = width() - frame()->GetMinimizeButtonOffset() + 774 button_x = width() - frame()->GetMinimizeButtonOffset() +
728 kProfileSwitcherButtonOffset; 775 kProfileSwitcherButtonOffset;
729 } else { 776 } else {
730 button_x = 777 button_x = MinimizeButtonX() - kProfileSwitcherButtonOffset - button_width;
731 MinimizeButtonX() - kProfileSwitcherButtonOffset - label_size.width();
732 } 778 }
733 779
734 int button_y = WindowTopY(); 780 int button_y = WindowTopY();
735 if (IsMaximized()) { 781 if (IsMaximized()) {
736 // In maximized mode the caption buttons appear only 19 pixels high, but 782 // In maximized mode the caption buttons appear only 19 pixels high, but
737 // their contents are aligned as if they were 20 pixels high and extended 783 // their contents are aligned as if they were 20 pixels high and extended
738 // 1 pixel off the top of the screen. We position the profile switcher 784 // 1 pixel off the top of the screen. We position the profile switcher
739 // button the same way to match. 785 // button the same way to match.
740 button_y -= 1; 786 button_y -= 1;
741 } 787 }
742 profile_switcher_.view()->SetBounds(button_x, button_y, label_size.width(), 788
743 kProfileSwitcherButtonHeight); 789 // Does the button need to slide over the tabstrip? If so, use its minimum
790 // height. In RTL the new tab button is on the left, so it can never slide
Peter Kasting 2017/05/06 02:23:08 Nit: First two sentences could just be "Shrink the
emx 2017/05/09 16:26:51 Done.
791 // under the avatar button (which is still on the right).
Peter Kasting 2017/05/06 02:23:08 Nit: You might want to note that caption buttons b
emx 2017/05/09 16:26:51 I've added a comment about that bug, which already
Peter Kasting 2017/05/09 17:40:28 Oh? What's particularly daunting about it? It se
emx 2017/05/10 17:38:48 For one, I'm not sure that there is agreement on w
Peter Kasting 2017/05/11 01:03:42 Yes, your objections are fair. If this were to be
792 if (tab_strip_ && !base::i18n::IsRTL() && tab_strip_->max_x() >= button_x)
793 button_height = button_view->GetMinimumSize().height();
794
795 button_view->SetBounds(button_x, button_y, button_width, button_height);
744 } 796 }
745 797
746 void GlassBrowserFrameView::LayoutIncognitoIcon() { 798 void GlassBrowserFrameView::LayoutIncognitoIcon() {
747 const gfx::Size size(GetIncognitoAvatarIcon().size()); 799 const gfx::Size size(GetIncognitoAvatarIcon().size());
748 int x = ClientBorderThickness(false); 800 int x = ClientBorderThickness(false);
749 // In RTL, the icon needs to start after the caption buttons. 801 // In RTL, the icon needs to start after the caption buttons.
750 if (CaptionButtonsOnLeadingEdge()) { 802 if (CaptionButtonsOnLeadingEdge()) {
751 x = width() - frame()->GetMinimizeButtonOffset() + 803 x = width() - frame()->GetMinimizeButtonOffset() +
752 (profile_switcher_.view() ? (profile_switcher_.view()->width() + 804 (GetProfileSwitcherView() ? (GetProfileSwitcherView()->width() +
753 kProfileSwitcherButtonOffset) 805 kProfileSwitcherButtonOffset)
754 : 0); 806 : 0);
755 } 807 }
756 const int bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - 808 const int bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() -
757 kAvatarIconPadding; 809 kAvatarIconPadding;
758 incognito_bounds_.SetRect( 810 incognito_bounds_.SetRect(
759 x + (profile_indicator_icon() ? kAvatarIconPadding : 0), 811 x + (profile_indicator_icon() ? kAvatarIconPadding : 0),
760 bottom - size.height(), profile_indicator_icon() ? size.width() : 0, 812 bottom - size.height(), profile_indicator_icon() ? size.width() : 0,
761 size.height()); 813 size.height());
762 if (profile_indicator_icon()) 814 if (profile_indicator_icon())
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 static bool initialized = false; 967 static bool initialized = false;
916 if (!initialized) { 968 if (!initialized) {
917 for (int i = 0; i < kThrobberIconCount; ++i) { 969 for (int i = 0; i < kThrobberIconCount; ++i) {
918 throbber_icons_[i] = 970 throbber_icons_[i] =
919 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); 971 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
920 DCHECK(throbber_icons_[i]); 972 DCHECK(throbber_icons_[i]);
921 } 973 }
922 initialized = true; 974 initialized = true;
923 } 975 }
924 } 976 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698