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

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

Issue 1972033002: Simplify some old avatar menu button code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reinstate ash browser test fix Created 4 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 <utility> 7 #include <utility>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/app/chrome_dll_resource.h" 12 #include "chrome/app/chrome_dll_resource.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/themes/theme_properties.h" 14 #include "chrome/browser/themes/theme_properties.h"
15 #include "chrome/browser/ui/layout_constants.h" 15 #include "chrome/browser/ui/layout_constants.h"
16 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
17 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 17 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h"
18 #include "chrome/browser/ui/views/tabs/tab.h" 18 #include "chrome/browser/ui/views/tabs/tab.h"
19 #include "chrome/browser/ui/views/tabs/tab_strip.h" 19 #include "chrome/browser/ui/views/tabs/tab_strip.h"
20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
21 #include "components/prefs/pref_service.h" 21 #include "components/prefs/pref_service.h"
22 #include "components/signin/core/browser/signin_header_helper.h" 22 #include "components/signin/core/browser/signin_header_helper.h"
23 #include "components/signin/core/common/profile_management_switches.h" 23 #include "components/signin/core/common/profile_management_switches.h"
24 #include "grit/theme_resources.h" 24 #include "grit/theme_resources.h"
25 #include "skia/ext/image_operations.h" 25 #include "skia/ext/image_operations.h"
26 #include "ui/base/material_design/material_design_controller.h" 26 #include "ui/base/material_design/material_design_controller.h"
27 #include "ui/base/resource/resource_bundle_win.h" 27 #include "ui/base/resource/resource_bundle_win.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 217
218 int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { 218 int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
219 // If the browser isn't in normal mode, we haven't customized the frame, so 219 // If the browser isn't in normal mode, we haven't customized the frame, so
220 // Windows can figure this out. If the point isn't within our bounds, then 220 // Windows can figure this out. If the point isn't within our bounds, then
221 // it's in the native portion of the frame, so again Windows can figure it 221 // it's in the native portion of the frame, so again Windows can figure it
222 // out. 222 // out.
223 if (!browser_view()->IsBrowserTypeNormal() || !bounds().Contains(point)) 223 if (!browser_view()->IsBrowserTypeNormal() || !bounds().Contains(point))
224 return HTNOWHERE; 224 return HTNOWHERE;
225 225
226 // See if the point is within the incognito icon or the profile switcher menu. 226 // See if the point is within the incognito icon or the profile switcher menu.
227 if ((avatar_button() && 227 if ((profile_indicator_icon() &&
228 avatar_button()->GetMirroredBounds().Contains(point)) || 228 profile_indicator_icon()->GetMirroredBounds().Contains(point)) ||
229 (profile_switcher_.view() && 229 (profile_switcher_.view() &&
230 profile_switcher_.view()->GetMirroredBounds().Contains(point))) 230 profile_switcher_.view()->GetMirroredBounds().Contains(point)))
231 return HTCLIENT; 231 return HTCLIENT;
232 232
233 int frame_component = frame()->client_view()->NonClientHitTest(point); 233 int frame_component = frame()->client_view()->NonClientHitTest(point);
234 234
235 // See if we're in the sysmenu region. We still have to check the tabstrip 235 // See if we're in the sysmenu region. We still have to check the tabstrip
236 // first so that clicks in a tab don't get treated as sysmenu clicks. 236 // first so that clicks in a tab don't get treated as sysmenu clicks.
237 int client_border_thickness = ClientBorderThickness(false); 237 int client_border_thickness = ClientBorderThickness(false);
238 gfx::Rect sys_menu_region(client_border_thickness, 238 gfx::Rect sys_menu_region(client_border_thickness,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (browser_view()->IsRegularOrGuestSession()) 277 if (browser_view()->IsRegularOrGuestSession())
278 LayoutProfileSwitcher(); 278 LayoutProfileSwitcher();
279 LayoutIncognitoIcon(); 279 LayoutIncognitoIcon();
280 LayoutClientView(); 280 LayoutClientView();
281 } 281 }
282 282
283 /////////////////////////////////////////////////////////////////////////////// 283 ///////////////////////////////////////////////////////////////////////////////
284 // GlassBrowserFrameView, protected: 284 // GlassBrowserFrameView, protected:
285 285
286 // BrowserNonClientFrameView: 286 // BrowserNonClientFrameView:
287 void GlassBrowserFrameView::UpdateAvatar() { 287 void GlassBrowserFrameView::UpdateProfileIcons() {
288 if (browser_view()->IsRegularOrGuestSession()) 288 if (browser_view()->IsRegularOrGuestSession())
289 profile_switcher_.Update(AvatarButtonStyle::NATIVE); 289 profile_switcher_.Update(AvatarButtonStyle::NATIVE);
290 else 290 else
291 UpdateOldAvatarButton(); 291 UpdateProfileIndicatorIcon();
292 } 292 }
293 293
294 /////////////////////////////////////////////////////////////////////////////// 294 ///////////////////////////////////////////////////////////////////////////////
295 // GlassBrowserFrameView, private: 295 // GlassBrowserFrameView, private:
296 296
297 // views::NonClientFrameView: 297 // views::NonClientFrameView:
298 bool GlassBrowserFrameView::DoesIntersectRect(const views::View* target, 298 bool GlassBrowserFrameView::DoesIntersectRect(const views::View* target,
299 const gfx::Rect& rect) const { 299 const gfx::Rect& rect) const {
300 CHECK_EQ(target, this); 300 CHECK_EQ(target, this);
301 bool hit_incognito_icon = avatar_button() && 301 bool hit_incognito_icon =
302 avatar_button()->GetMirroredBounds().Intersects(rect); 302 profile_indicator_icon() &&
303 profile_indicator_icon()->GetMirroredBounds().Intersects(rect);
303 bool hit_profile_switcher_button = 304 bool hit_profile_switcher_button =
304 profile_switcher_.view() && 305 profile_switcher_.view() &&
305 profile_switcher_.view()->GetMirroredBounds().Intersects(rect); 306 profile_switcher_.view()->GetMirroredBounds().Intersects(rect);
306 return hit_incognito_icon || hit_profile_switcher_button || 307 return hit_incognito_icon || hit_profile_switcher_button ||
307 !frame()->client_view()->bounds().Intersects(rect); 308 !frame()->client_view()->bounds().Intersects(rect);
308 } 309 }
309 310
310 int GlassBrowserFrameView::ClientBorderThickness(bool restored) const { 311 int GlassBrowserFrameView::ClientBorderThickness(bool restored) const {
311 if ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) 312 if ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored)
312 return 0; 313 return 0;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 const bool md = ui::MaterialDesignController::IsModeMaterial(); 547 const bool md = ui::MaterialDesignController::IsModeMaterial();
547 const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON)); 548 const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON));
548 const gfx::Size size(GetOTRAvatarIcon().size()); 549 const gfx::Size size(GetOTRAvatarIcon().size());
549 int x = ClientBorderThickness(false); 550 int x = ClientBorderThickness(false);
550 // In RTL, the icon needs to start after the caption buttons. 551 // In RTL, the icon needs to start after the caption buttons.
551 if (CaptionButtonsOnLeadingEdge()) { 552 if (CaptionButtonsOnLeadingEdge()) {
552 x = width() - frame()->GetMinimizeButtonOffset() + 553 x = width() - frame()->GetMinimizeButtonOffset() +
553 (profile_switcher_.view() ? (profile_switcher_.view()->width() + 554 (profile_switcher_.view() ? (profile_switcher_.view()->width() +
554 kProfileSwitcherButtonOffset) 555 kProfileSwitcherButtonOffset)
555 : 0); 556 : 0);
556 } else if (!md && !avatar_button() && IsToolbarVisible() && 557 } else if (!md && !profile_indicator_icon() && IsToolbarVisible() &&
557 (base::win::GetVersion() < base::win::VERSION_WIN10)) { 558 (base::win::GetVersion() < base::win::VERSION_WIN10)) {
558 // In non-MD before Win 10, the toolbar has a rounded corner that we don't 559 // In non-MD before Win 10, the toolbar has a rounded corner that we don't
559 // want the tabstrip to overlap. 560 // want the tabstrip to overlap.
560 x += browser_view()->GetToolbarBounds().x() - kContentEdgeShadowThickness + 561 x += browser_view()->GetToolbarBounds().x() - kContentEdgeShadowThickness +
561 GetThemeProvider()->GetImageSkiaNamed( 562 GetThemeProvider()->GetImageSkiaNamed(
562 IDR_CONTENT_TOP_LEFT_CORNER)->width(); 563 IDR_CONTENT_TOP_LEFT_CORNER)->width();
563 } 564 }
564 const int bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - 565 const int bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() -
565 insets.bottom(); 566 insets.bottom();
566 const int y = (md || !frame()->IsMaximized()) 567 const int y = (md || !frame()->IsMaximized())
567 ? (bottom - size.height()) 568 ? (bottom - size.height())
568 : FrameTopBorderThickness(false); 569 : FrameTopBorderThickness(false);
569 incognito_bounds_.SetRect(x + (avatar_button() ? insets.left() : 0), y, 570 incognito_bounds_.SetRect(x + (profile_indicator_icon() ? insets.left() : 0),
570 avatar_button() ? size.width() : 0, bottom - y); 571 y, profile_indicator_icon() ? size.width() : 0,
571 if (avatar_button()) 572 bottom - y);
572 avatar_button()->SetBoundsRect(incognito_bounds_); 573 if (profile_indicator_icon())
574 profile_indicator_icon()->SetBoundsRect(incognito_bounds_);
573 } 575 }
574 576
575 void GlassBrowserFrameView::LayoutClientView() { 577 void GlassBrowserFrameView::LayoutClientView() {
576 client_view_bounds_ = CalculateClientAreaBounds(); 578 client_view_bounds_ = CalculateClientAreaBounds();
577 } 579 }
578 580
579 gfx::Insets GlassBrowserFrameView::GetClientAreaInsets(bool restored) const { 581 gfx::Insets GlassBrowserFrameView::GetClientAreaInsets(bool restored) const {
580 if (!browser_view()->IsTabStripVisible()) 582 if (!browser_view()->IsTabStripVisible())
581 return gfx::Insets(); 583 return gfx::Insets();
582 584
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 static bool initialized = false; 670 static bool initialized = false;
669 if (!initialized) { 671 if (!initialized) {
670 for (int i = 0; i < kThrobberIconCount; ++i) { 672 for (int i = 0; i < kThrobberIconCount; ++i) {
671 throbber_icons_[i] = 673 throbber_icons_[i] =
672 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); 674 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
673 DCHECK(throbber_icons_[i]); 675 DCHECK(throbber_icons_[i]);
674 } 676 }
675 initialized = true; 677 initialized = true;
676 } 678 }
677 } 679 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/glass_browser_frame_view.h ('k') | chrome/browser/ui/views/frame/opaque_browser_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698