| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser_non_client_frame_view_mus.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_mus.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/profiles/profiles_state.h" | 9 #include "chrome/browser/profiles/profiles_state.h" |
| 10 #include "chrome/browser/themes/theme_properties.h" | 10 #include "chrome/browser/themes/theme_properties.h" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 void BrowserNonClientFrameViewMus::TabStripMaxXChanged(TabStrip* tab_strip) { | 364 void BrowserNonClientFrameViewMus::TabStripMaxXChanged(TabStrip* tab_strip) { |
| 365 UpdateClientArea(); | 365 UpdateClientArea(); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void BrowserNonClientFrameViewMus::TabStripDeleted(TabStrip* tab_strip) { | 368 void BrowserNonClientFrameViewMus::TabStripDeleted(TabStrip* tab_strip) { |
| 369 tab_strip_->RemoveObserver(this); | 369 tab_strip_->RemoveObserver(this); |
| 370 tab_strip_ = nullptr; | 370 tab_strip_ = nullptr; |
| 371 } | 371 } |
| 372 | 372 |
| 373 int BrowserNonClientFrameViewMus::GetTabStripLeftInset() const { | 373 int BrowserNonClientFrameViewMus::GetTabStripLeftInset() const { |
| 374 const int pad = GetLayoutConstant(AVATAR_ICON_PADDING); | 374 const int avatar_right = |
| 375 const int avatar_right = profile_indicator_icon() | 375 profile_indicator_icon() |
| 376 ? (pad + GetIncognitoAvatarIcon().width()) | 376 ? (kAvatarIconPadding + GetIncognitoAvatarIcon().width()) |
| 377 : 0; | 377 : 0; |
| 378 return avatar_right + pad + frame_values().normal_insets.left(); | 378 return avatar_right + kAvatarIconPadding + |
| 379 frame_values().normal_insets.left(); |
| 379 } | 380 } |
| 380 | 381 |
| 381 int BrowserNonClientFrameViewMus::GetTabStripRightInset() const { | 382 int BrowserNonClientFrameViewMus::GetTabStripRightInset() const { |
| 382 const int frame_right_insets = frame_values().normal_insets.right() + | 383 const int frame_right_insets = frame_values().normal_insets.right() + |
| 383 frame_values().max_title_bar_button_width; | 384 frame_values().max_title_bar_button_width; |
| 384 int right_inset = kTabstripRightSpacing + frame_right_insets; | 385 int right_inset = kTabstripRightSpacing + frame_right_insets; |
| 385 | 386 |
| 386 #if defined(FRAME_AVATAR_BUTTON) | 387 #if defined(FRAME_AVATAR_BUTTON) |
| 387 if (profile_switcher_.view()) { | 388 if (profile_switcher_.view()) { |
| 388 right_inset += kAvatarButtonOffset + | 389 right_inset += kAvatarButtonOffset + |
| (...skipping 28 matching lines...) Expand all Loading... |
| 417 Browser::FEATURE_WEBAPPFRAME); | 418 Browser::FEATURE_WEBAPPFRAME); |
| 418 } | 419 } |
| 419 | 420 |
| 420 void BrowserNonClientFrameViewMus::LayoutIncognitoButton() { | 421 void BrowserNonClientFrameViewMus::LayoutIncognitoButton() { |
| 421 DCHECK(profile_indicator_icon()); | 422 DCHECK(profile_indicator_icon()); |
| 422 #if !defined(OS_CHROMEOS) | 423 #if !defined(OS_CHROMEOS) |
| 423 // ChromeOS shows avatar on V1 app. | 424 // ChromeOS shows avatar on V1 app. |
| 424 DCHECK(browser_view()->IsTabStripVisible()); | 425 DCHECK(browser_view()->IsTabStripVisible()); |
| 425 #endif | 426 #endif |
| 426 gfx::ImageSkia incognito_icon = GetIncognitoAvatarIcon(); | 427 gfx::ImageSkia incognito_icon = GetIncognitoAvatarIcon(); |
| 427 const int pad = GetLayoutConstant(AVATAR_ICON_PADDING); | 428 int avatar_bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - |
| 428 int avatar_bottom = | 429 kAvatarIconPadding; |
| 429 GetTopInset(false) + browser_view()->GetTabStripHeight() - pad; | |
| 430 int avatar_y = avatar_bottom - incognito_icon.height(); | 430 int avatar_y = avatar_bottom - incognito_icon.height(); |
| 431 | 431 |
| 432 // Hide the incognito icon in immersive fullscreen when the tab light bar is | 432 // Hide the incognito icon in immersive fullscreen when the tab light bar is |
| 433 // visible because the header is too short for the icognito icon to be | 433 // visible because the header is too short for the icognito icon to be |
| 434 // recognizable. | 434 // recognizable. |
| 435 bool avatar_visible = !UseImmersiveLightbarHeaderStyle(); | 435 bool avatar_visible = !UseImmersiveLightbarHeaderStyle(); |
| 436 int avatar_height = avatar_visible ? incognito_icon.height() : 0; | 436 int avatar_height = avatar_visible ? incognito_icon.height() : 0; |
| 437 | 437 |
| 438 gfx::Rect avatar_bounds(pad, avatar_y, incognito_icon.width(), avatar_height); | 438 gfx::Rect avatar_bounds(kAvatarIconPadding, avatar_y, incognito_icon.width(), |
| 439 avatar_height); |
| 439 profile_indicator_icon()->SetBoundsRect(avatar_bounds); | 440 profile_indicator_icon()->SetBoundsRect(avatar_bounds); |
| 440 profile_indicator_icon()->SetVisible(avatar_visible); | 441 profile_indicator_icon()->SetVisible(avatar_visible); |
| 441 } | 442 } |
| 442 | 443 |
| 443 void BrowserNonClientFrameViewMus::LayoutProfileSwitcher() { | 444 void BrowserNonClientFrameViewMus::LayoutProfileSwitcher() { |
| 444 #if defined(FRAME_AVATAR_BUTTON) | 445 #if defined(FRAME_AVATAR_BUTTON) |
| 445 gfx::Size button_size = profile_switcher_.view()->GetPreferredSize(); | 446 gfx::Size button_size = profile_switcher_.view()->GetPreferredSize(); |
| 446 int button_x = width() - GetTabStripRightInset() + kAvatarButtonOffset; | 447 int button_x = width() - GetTabStripRightInset() + kAvatarButtonOffset; |
| 447 profile_switcher_.view()->SetBounds(button_x, 0, button_size.width(), | 448 profile_switcher_.view()->SetBounds(button_x, 0, button_size.width(), |
| 448 button_size.height()); | 449 button_size.height()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 } | 508 } |
| 508 | 509 |
| 509 void BrowserNonClientFrameViewMus::PaintContentEdge(gfx::Canvas* canvas) { | 510 void BrowserNonClientFrameViewMus::PaintContentEdge(gfx::Canvas* canvas) { |
| 510 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); | 511 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); |
| 511 const int bottom = frame_values().normal_insets.bottom(); | 512 const int bottom = frame_values().normal_insets.bottom(); |
| 512 canvas->FillRect( | 513 canvas->FillRect( |
| 513 gfx::Rect(0, bottom, width(), kClientEdgeThickness), | 514 gfx::Rect(0, bottom, width(), kClientEdgeThickness), |
| 514 GetThemeProvider()->GetColor( | 515 GetThemeProvider()->GetColor( |
| 515 ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR)); | 516 ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR)); |
| 516 } | 517 } |
| OLD | NEW |