OLD | NEW |
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/browser_non_client_frame_view_ash.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h" |
6 | 6 |
7 #include "ash/shell_delegate.h" | 7 #include "ash/shell_delegate.h" |
8 #include "ash/wm/frame_painter.h" | 8 #include "ash/wm/frame_painter.h" |
9 #include "ash/wm/workspace/frame_maximize_button.h" | 9 #include "ash/wm/workspace/frame_maximize_button.h" |
10 #include "chrome/browser/themes/theme_properties.h" | 10 #include "chrome/browser/themes/theme_properties.h" |
11 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 11 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/immersive_fullscreen_configuration.h" | 13 #include "chrome/browser/ui/immersive_fullscreen_configuration.h" |
14 #include "chrome/browser/ui/views/avatar_label.h" | |
15 #include "chrome/browser/ui/views/avatar_menu_button.h" | 14 #include "chrome/browser/ui/views/avatar_menu_button.h" |
16 #include "chrome/browser/ui/views/frame/browser_frame.h" | 15 #include "chrome/browser/ui/views/frame/browser_frame.h" |
17 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
18 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 17 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
19 #include "chrome/browser/ui/views/tab_icon_view.h" | 18 #include "chrome/browser/ui/views/tab_icon_view.h" |
20 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 19 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
21 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
22 #include "grit/ash_resources.h" | 21 #include "grit/ash_resources.h" |
23 #include "grit/generated_resources.h" // Accessibility names | 22 #include "grit/generated_resources.h" // Accessibility names |
24 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return gfx::Rect(insets.left, insets.top, | 127 return gfx::Rect(insets.left, insets.top, |
129 std::max(0, width() - insets.left - insets.right), | 128 std::max(0, width() - insets.left - insets.right), |
130 tabstrip->GetPreferredSize().height()); | 129 tabstrip->GetPreferredSize().height()); |
131 } | 130 } |
132 | 131 |
133 BrowserNonClientFrameView::TabStripInsets | 132 BrowserNonClientFrameView::TabStripInsets |
134 BrowserNonClientFrameViewAsh::GetTabStripInsets(bool force_restored) const { | 133 BrowserNonClientFrameViewAsh::GetTabStripInsets(bool force_restored) const { |
135 int left = avatar_button() ? kAvatarSideSpacing + | 134 int left = avatar_button() ? kAvatarSideSpacing + |
136 browser_view()->GetOTRAvatarIcon().width() + kAvatarSideSpacing : | 135 browser_view()->GetOTRAvatarIcon().width() + kAvatarSideSpacing : |
137 kTabstripLeftSpacing; | 136 kTabstripLeftSpacing; |
138 if (avatar_label()) { | |
139 left += avatar_label()->GetPreferredSize().width() + | |
140 views::kRelatedControlHorizontalSpacing; | |
141 } | |
142 int right = frame_painter_->GetRightInset() + kTabstripRightSpacing; | 137 int right = frame_painter_->GetRightInset() + kTabstripRightSpacing; |
143 return TabStripInsets(NonClientTopBorderHeight(force_restored), left, right); | 138 return TabStripInsets(NonClientTopBorderHeight(force_restored), left, right); |
144 } | 139 } |
145 | 140 |
146 int BrowserNonClientFrameViewAsh::GetThemeBackgroundXInset() const { | 141 int BrowserNonClientFrameViewAsh::GetThemeBackgroundXInset() const { |
147 return frame_painter_->GetThemeBackgroundXInset(); | 142 return frame_painter_->GetThemeBackgroundXInset(); |
148 } | 143 } |
149 | 144 |
150 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) { | 145 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) { |
151 if (window_icon_) | 146 if (window_icon_) |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 | 408 |
414 if (frame()->IsFullscreen()) { | 409 if (frame()->IsFullscreen()) { |
415 ImmersiveModeController* immersive_controller = | 410 ImmersiveModeController* immersive_controller = |
416 browser_view()->immersive_mode_controller(); | 411 browser_view()->immersive_mode_controller(); |
417 // Hide the incognito icon when the top-of-window views are closed in | 412 // Hide the incognito icon when the top-of-window views are closed in |
418 // immersive mode as the tab indicators are too short for the incognito | 413 // immersive mode as the tab indicators are too short for the incognito |
419 // icon to still be recongizable. | 414 // icon to still be recongizable. |
420 if (immersive_controller->IsEnabled() && | 415 if (immersive_controller->IsEnabled() && |
421 !immersive_controller->IsRevealed()) { | 416 !immersive_controller->IsRevealed()) { |
422 avatar_button()->SetBoundsRect(gfx::Rect()); | 417 avatar_button()->SetBoundsRect(gfx::Rect()); |
423 if (avatar_label()) | |
424 avatar_label()->SetBoundsRect(gfx::Rect()); | |
425 return; | 418 return; |
426 } | 419 } |
427 } | 420 } |
428 | 421 |
429 int avatar_bottom = GetTabStripInsets(false).top + | 422 int avatar_bottom = GetTabStripInsets(false).top + |
430 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; | 423 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; |
431 int avatar_restored_y = avatar_bottom - incognito_icon.height(); | 424 int avatar_restored_y = avatar_bottom - incognito_icon.height(); |
432 int avatar_y = (frame()->IsMaximized() || frame()->IsFullscreen()) ? | 425 int avatar_y = (frame()->IsMaximized() || frame()->IsFullscreen()) ? |
433 NonClientTopBorderHeight(false) + kContentShadowHeight : | 426 NonClientTopBorderHeight(false) + kContentShadowHeight : |
434 avatar_restored_y; | 427 avatar_restored_y; |
435 gfx::Rect avatar_bounds(kAvatarSideSpacing, | 428 gfx::Rect avatar_bounds(kAvatarSideSpacing, |
436 avatar_y, | 429 avatar_y, |
437 incognito_icon.width(), | 430 incognito_icon.width(), |
438 avatar_bottom - avatar_y); | 431 avatar_bottom - avatar_y); |
439 avatar_button()->SetBoundsRect(avatar_bounds); | 432 avatar_button()->SetBoundsRect(avatar_bounds); |
440 if (avatar_label()) { | |
441 gfx::Size size = avatar_label()->GetPreferredSize(); | |
442 int label_height = std::min(avatar_bounds.height(), size.height()); | |
443 gfx::Rect label_bounds( | |
444 avatar_bounds.right() + views::kRelatedControlHorizontalSpacing, | |
445 avatar_y + (avatar_bounds.height() - label_height) / 2, | |
446 size.width(), | |
447 size.height()); | |
448 avatar_label()->SetBoundsRect(label_bounds); | |
449 } | |
450 } | 433 } |
451 | 434 |
452 bool BrowserNonClientFrameViewAsh::ShouldPaint() const { | 435 bool BrowserNonClientFrameViewAsh::ShouldPaint() const { |
453 // Immersive mode windows are fullscreen, but need to paint during a reveal. | 436 // Immersive mode windows are fullscreen, but need to paint during a reveal. |
454 return !frame()->IsFullscreen() || | 437 return !frame()->IsFullscreen() || |
455 browser_view()->immersive_mode_controller()->IsRevealed(); | 438 browser_view()->immersive_mode_controller()->IsRevealed(); |
456 } | 439 } |
457 | 440 |
458 void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) { | 441 void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) { |
459 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 442 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { | 543 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { |
561 ui::ThemeProvider* tp = GetThemeProvider(); | 544 ui::ThemeProvider* tp = GetThemeProvider(); |
562 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 545 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
563 browser_view()->IsBrowserTypeNormal() && | 546 browser_view()->IsBrowserTypeNormal() && |
564 !browser_view()->IsOffTheRecord()) { | 547 !browser_view()->IsOffTheRecord()) { |
565 return ShouldPaintAsActive() ? | 548 return ShouldPaintAsActive() ? |
566 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; | 549 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; |
567 } | 550 } |
568 return 0; | 551 return 0; |
569 } | 552 } |
OLD | NEW |