Chromium Code Reviews| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" | 8 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" |
| 9 #include "ash/wm/default_header_painter.h" | |
| 9 #include "ash/wm/frame_border_hit_test_controller.h" | 10 #include "ash/wm/frame_border_hit_test_controller.h" |
| 10 #include "ash/wm/header_painter.h" | 11 #include "ash/wm/header_metrics.h" |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
| 13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/views/avatar_label.h" | 15 #include "chrome/browser/ui/views/avatar_label.h" |
| 15 #include "chrome/browser/ui/views/avatar_menu_button.h" | 16 #include "chrome/browser/ui/views/avatar_menu_button.h" |
| 16 #include "chrome/browser/ui/views/frame/browser_frame.h" | 17 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 18 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h" | |
| 17 #include "chrome/browser/ui/views/frame/browser_view.h" | 19 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 18 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 20 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| 19 #include "chrome/browser/ui/views/tab_icon_view.h" | 21 #include "chrome/browser/ui/views/tab_icon_view.h" |
| 20 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 22 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 21 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 22 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 23 #include "grit/ash_resources.h" | 25 #include "grit/ash_resources.h" |
| 24 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
| 25 #include "ui/accessibility/ax_view_state.h" | 27 #include "ui/accessibility/ax_view_state.h" |
| 26 #include "ui/aura/client/aura_constants.h" | 28 #include "ui/aura/client/aura_constants.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 | 74 |
| 73 // static | 75 // static |
| 74 const char BrowserNonClientFrameViewAsh::kViewClassName[] = | 76 const char BrowserNonClientFrameViewAsh::kViewClassName[] = |
| 75 "BrowserNonClientFrameViewAsh"; | 77 "BrowserNonClientFrameViewAsh"; |
| 76 | 78 |
| 77 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( | 79 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( |
| 78 BrowserFrame* frame, BrowserView* browser_view) | 80 BrowserFrame* frame, BrowserView* browser_view) |
| 79 : BrowserNonClientFrameView(frame, browser_view), | 81 : BrowserNonClientFrameView(frame, browser_view), |
| 80 caption_button_container_(NULL), | 82 caption_button_container_(NULL), |
| 81 window_icon_(NULL), | 83 window_icon_(NULL), |
| 82 header_painter_(new ash::HeaderPainter), | |
| 83 frame_border_hit_test_controller_( | 84 frame_border_hit_test_controller_( |
| 84 new ash::FrameBorderHitTestController(frame)) { | 85 new ash::FrameBorderHitTestController(frame)) { |
| 85 } | 86 } |
| 86 | 87 |
| 87 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { | 88 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { |
| 88 } | 89 } |
| 89 | 90 |
| 90 void BrowserNonClientFrameViewAsh::Init() { | 91 void BrowserNonClientFrameViewAsh::Init() { |
| 91 caption_button_container_ = new ash::FrameCaptionButtonContainerView(frame(), | 92 caption_button_container_ = new ash::FrameCaptionButtonContainerView(frame(), |
| 92 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); | 93 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); |
| 93 AddChildView(caption_button_container_); | 94 AddChildView(caption_button_container_); |
| 94 | 95 |
| 95 // Initializing the TabIconView is expensive, so only do it if we need to. | 96 // Initializing the TabIconView is expensive, so only do it if we need to. |
| 96 if (browser_view()->ShouldShowWindowIcon()) { | 97 if (browser_view()->ShouldShowWindowIcon()) { |
| 97 window_icon_ = new TabIconView(this, NULL); | 98 window_icon_ = new TabIconView(this, NULL); |
| 98 window_icon_->set_is_light(true); | 99 window_icon_->set_is_light(true); |
| 99 AddChildView(window_icon_); | 100 AddChildView(window_icon_); |
| 100 window_icon_->Update(); | 101 window_icon_->Update(); |
| 101 } | 102 } |
| 102 | 103 |
| 103 // Create incognito icon if necessary. | 104 // Create incognito icon if necessary. |
| 104 UpdateAvatarInfo(); | 105 UpdateAvatarInfo(); |
| 105 | 106 |
| 106 // HeaderPainter handles layout. | 107 // HeaderPainter handles layout. |
| 107 ash::HeaderPainter::Style header_style = UsePackagedAppHeaderStyle() ? | 108 if (UsePackagedAppHeaderStyle()) { |
| 108 ash::HeaderPainter::STYLE_OTHER : ash::HeaderPainter::STYLE_BROWSER; | 109 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter; |
| 109 header_painter_->Init(header_style, frame(), this, window_icon_, | 110 header_painter->Init(frame(), this, window_icon_, |
| 110 caption_button_container_); | 111 caption_button_container_); |
| 112 header_painter_.reset(header_painter); | |
|
James Cook
2014/03/10 17:32:30
Out of curiosity, why reset after Init()? Does he
pkotwicz
2014/03/14 17:56:22
Init is not part of the ash::HeaderPainter interfa
James Cook
2014/03/14 18:27:15
That makes sense. It just looked odd to my reading
pkotwicz
2014/03/16 17:27:18
I swapped the order of lines 110 and 112. Hopefull
| |
| 113 } else { | |
| 114 BrowserHeaderPainterAsh* header_painter = new BrowserHeaderPainterAsh; | |
| 115 header_painter->Init(frame(), browser_view(), this, window_icon_, | |
| 116 caption_button_container_); | |
| 117 header_painter_.reset(header_painter); | |
| 118 } | |
| 111 } | 119 } |
| 112 | 120 |
| 113 /////////////////////////////////////////////////////////////////////////////// | 121 /////////////////////////////////////////////////////////////////////////////// |
| 114 // BrowserNonClientFrameView overrides: | 122 // BrowserNonClientFrameView overrides: |
| 115 | 123 |
| 116 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForTabStrip( | 124 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForTabStrip( |
| 117 views::View* tabstrip) const { | 125 views::View* tabstrip) const { |
| 118 if (!tabstrip) | 126 if (!tabstrip) |
| 119 return gfx::Rect(); | 127 return gfx::Rect(); |
| 120 | 128 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 135 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) | 143 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) |
| 136 return 0; | 144 return 0; |
| 137 | 145 |
| 138 if (browser_view()->IsTabStripVisible()) { | 146 if (browser_view()->IsTabStripVisible()) { |
| 139 if (frame()->IsMaximized() || frame()->IsFullscreen()) | 147 if (frame()->IsMaximized() || frame()->IsFullscreen()) |
| 140 return kTabstripTopSpacingShort; | 148 return kTabstripTopSpacingShort; |
| 141 else | 149 else |
| 142 return kTabstripTopSpacingTall; | 150 return kTabstripTopSpacingTall; |
| 143 } | 151 } |
| 144 | 152 |
| 153 if (UsePackagedAppHeaderStyle()) | |
| 154 return header_painter_->GetHeaderHeightForPainting(); | |
| 155 | |
| 145 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); | 156 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); |
| 146 | 157 |
| 147 // The toolbar partially overlaps the caption buttons. | 158 // The toolbar partially overlaps the caption buttons. |
| 148 if (browser_view()->IsToolbarVisible()) | 159 if (browser_view()->IsToolbarVisible()) |
| 149 return caption_buttons_bottom - kContentShadowHeight; | 160 return caption_buttons_bottom - kContentShadowHeight; |
| 150 | 161 |
| 151 int separator_thickness = UsePackagedAppHeaderStyle() ? | 162 return caption_buttons_bottom + kClientEdgeThickness; |
| 152 header_painter_->HeaderContentSeparatorSize() : kClientEdgeThickness; | |
| 153 return caption_buttons_bottom + separator_thickness; | |
| 154 } | 163 } |
| 155 | 164 |
| 156 int BrowserNonClientFrameViewAsh::GetThemeBackgroundXInset() const { | 165 int BrowserNonClientFrameViewAsh::GetThemeBackgroundXInset() const { |
| 157 return header_painter_->GetThemeBackgroundXInset(); | 166 return ash::HeaderMetrics::GetThemeBackgroundXInset(); |
| 158 } | 167 } |
| 159 | 168 |
| 160 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) { | 169 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) { |
| 161 if (window_icon_) | 170 if (window_icon_) |
| 162 window_icon_->Update(); | 171 window_icon_->Update(); |
| 163 } | 172 } |
| 164 | 173 |
| 165 /////////////////////////////////////////////////////////////////////////////// | 174 /////////////////////////////////////////////////////////////////////////////// |
| 166 // views::NonClientFrameView overrides: | 175 // views::NonClientFrameView overrides: |
| 167 | 176 |
| 168 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForClientView() const { | 177 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForClientView() const { |
| 169 // The ClientView must be flush with the top edge of the widget so that the | 178 // The ClientView must be flush with the top edge of the widget so that the |
| 170 // web contents can take up the entire screen in immersive fullscreen (with | 179 // web contents can take up the entire screen in immersive fullscreen (with |
| 171 // or without the top-of-window views revealed). When in immersive fullscreen | 180 // or without the top-of-window views revealed). When in immersive fullscreen |
| 172 // and the top-of-window views are revealed, the TopContainerView paints the | 181 // and the top-of-window views are revealed, the TopContainerView paints the |
| 173 // window header by redirecting paints from its background to | 182 // window header by redirecting paints from its background to |
| 174 // BrowserNonClientFrameViewAsh. | 183 // BrowserNonClientFrameViewAsh. |
| 175 return ash::HeaderPainter::GetBoundsForClientView(0, bounds()); | 184 return bounds(); |
| 176 } | 185 } |
| 177 | 186 |
| 178 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds( | 187 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds( |
| 179 const gfx::Rect& client_bounds) const { | 188 const gfx::Rect& client_bounds) const { |
| 180 return ash::HeaderPainter::GetWindowBoundsForClientBounds(0, client_bounds); | 189 return client_bounds; |
| 181 } | 190 } |
| 182 | 191 |
| 183 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { | 192 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { |
| 184 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, | 193 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, |
| 185 header_painter_.get(), point); | 194 caption_button_container_, point); |
| 186 | 195 |
| 187 // See if the point is actually within the avatar menu button or within | 196 // See if the point is actually within the avatar menu button or within |
| 188 // the avatar label. | 197 // the avatar label. |
| 189 if (hit_test == HTCAPTION && ((avatar_button() && | 198 if (hit_test == HTCAPTION && ((avatar_button() && |
| 190 avatar_button()->GetMirroredBounds().Contains(point)) || | 199 avatar_button()->GetMirroredBounds().Contains(point)) || |
| 191 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)))) | 200 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)))) |
| 192 return HTCLIENT; | 201 return HTCLIENT; |
| 193 | 202 |
| 194 // When the window is restored we want a large click target above the tabs | 203 // When the window is restored we want a large click target above the tabs |
| 195 // to drag the window, so redirect clicks in the tab's shadow to caption. | 204 // to drag the window, so redirect clicks in the tab's shadow to caption. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 221 caption_button_container_->ResetWindowControls(); | 230 caption_button_container_->ResetWindowControls(); |
| 222 } | 231 } |
| 223 | 232 |
| 224 void BrowserNonClientFrameViewAsh::UpdateWindowIcon() { | 233 void BrowserNonClientFrameViewAsh::UpdateWindowIcon() { |
| 225 if (window_icon_) | 234 if (window_icon_) |
| 226 window_icon_->SchedulePaint(); | 235 window_icon_->SchedulePaint(); |
| 227 } | 236 } |
| 228 | 237 |
| 229 void BrowserNonClientFrameViewAsh::UpdateWindowTitle() { | 238 void BrowserNonClientFrameViewAsh::UpdateWindowTitle() { |
| 230 if (!frame()->IsFullscreen()) | 239 if (!frame()->IsFullscreen()) |
| 231 header_painter_->SchedulePaintForTitle(BrowserFrame::GetTitleFontList()); | 240 header_painter_->SchedulePaintForTitle(); |
| 232 } | 241 } |
| 233 | 242 |
| 234 /////////////////////////////////////////////////////////////////////////////// | 243 /////////////////////////////////////////////////////////////////////////////// |
| 235 // views::View overrides: | 244 // views::View overrides: |
| 236 | 245 |
| 237 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { | 246 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { |
| 238 if (!ShouldPaint()) | 247 if (!ShouldPaint()) |
| 239 return; | 248 return; |
| 240 | 249 |
| 241 if (UseImmersiveLightbarHeaderStyle()) { | 250 if (UseImmersiveLightbarHeaderStyle()) { |
| 242 PaintImmersiveLightbarStyleHeader(canvas); | 251 PaintImmersiveLightbarStyleHeader(canvas); |
| 243 return; | 252 return; |
| 244 } | 253 } |
| 245 | 254 |
| 246 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); | 255 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); |
| 247 | 256 |
| 248 // The primary header image changes based on window activation state and | |
| 249 // theme, so we look it up for each paint. | |
| 250 int theme_frame_image_id = 0; | |
| 251 int theme_frame_overlay_image_id = 0; | |
| 252 if (browser_view()->IsTabStripVisible()) { | |
| 253 GetFrameImageIdsForTabbedBrowser(&theme_frame_image_id, | |
| 254 &theme_frame_overlay_image_id); | |
| 255 } else if (browser_view()->browser()->is_app()) { | |
| 256 theme_frame_image_id = GetFrameImageIdForHostedApp(); | |
| 257 } else { | |
| 258 theme_frame_image_id = GetFrameImageIdForBrowserPopup(); | |
| 259 } | |
| 260 | |
| 261 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? | 257 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? |
| 262 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; | 258 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; |
| 263 header_painter_->PaintHeader( | 259 header_painter_->PaintHeader(canvas, header_mode); |
| 264 canvas, | |
| 265 header_mode, | |
| 266 theme_frame_image_id, | |
| 267 theme_frame_overlay_image_id); | |
| 268 if (browser_view()->ShouldShowWindowTitle()) | |
| 269 header_painter_->PaintTitleBar(canvas, BrowserFrame::GetTitleFontList()); | |
| 270 if (browser_view()->IsToolbarVisible()) | 260 if (browser_view()->IsToolbarVisible()) |
| 271 PaintToolbarBackground(canvas); | 261 PaintToolbarBackground(canvas); |
| 272 else | 262 else if (!UsePackagedAppHeaderStyle()) |
| 273 PaintContentEdge(canvas); | 263 PaintContentEdge(canvas); |
| 274 } | 264 } |
| 275 | 265 |
| 276 void BrowserNonClientFrameViewAsh::Layout() { | 266 void BrowserNonClientFrameViewAsh::Layout() { |
| 277 // The header must be laid out before computing |header_height| because the | 267 // The header must be laid out before computing |painted_height| because the |
| 278 // computation of |header_height| for app and popup windows depends on the | 268 // computation of |painted_height| for app and popup windows depends on the |
| 279 // position of the window controls. | 269 // position of the window controls. |
| 280 header_painter_->LayoutHeader(); | 270 header_painter_->LayoutHeader(); |
| 281 | 271 |
| 282 int header_height = 0; | 272 int painted_height = 0; |
| 283 if (browser_view()->IsTabStripVisible()) { | 273 if (browser_view()->IsTabStripVisible()) { |
| 284 header_height = GetTopInset() + | 274 painted_height = GetTopInset() + |
| 285 browser_view()->tabstrip()->GetPreferredSize().height(); | 275 browser_view()->tabstrip()->GetPreferredSize().height(); |
| 286 } else if (browser_view()->IsToolbarVisible()) { | 276 } else if (browser_view()->IsToolbarVisible()) { |
| 287 // Set the header's height so that it overlaps with the toolbar because the | 277 // Paint the header so that it overlaps with the top few pixels of the |
| 288 // top few pixels of the toolbar are not opaque. | 278 // toolbar because the top few pixels of the toolbar are not opaque. |
| 289 header_height = GetTopInset() + kFrameShadowThickness * 2; | 279 painted_height = GetTopInset() + kFrameShadowThickness * 2; |
| 290 } else { | 280 } else { |
| 291 header_height = GetTopInset(); | 281 painted_height = GetTopInset(); |
| 292 } | 282 } |
| 293 header_painter_->set_header_height(header_height); | 283 header_painter_->SetHeaderHeightForPainting(painted_height); |
| 294 if (avatar_button()) | 284 if (avatar_button()) |
| 295 LayoutAvatar(); | 285 LayoutAvatar(); |
| 296 BrowserNonClientFrameView::Layout(); | 286 BrowserNonClientFrameView::Layout(); |
| 297 } | 287 } |
| 298 | 288 |
| 299 const char* BrowserNonClientFrameViewAsh::GetClassName() const { | 289 const char* BrowserNonClientFrameViewAsh::GetClassName() const { |
| 300 return kViewClassName; | 290 return kViewClassName; |
| 301 } | 291 } |
| 302 | 292 |
| 303 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { | 293 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 // Ensure that the minimum width is enough to hold a minimum width tab strip | 329 // Ensure that the minimum width is enough to hold a minimum width tab strip |
| 340 // at its usual insets. | 330 // at its usual insets. |
| 341 int min_tabstrip_width = | 331 int min_tabstrip_width = |
| 342 browser_view()->tabstrip()->GetMinimumSize().width(); | 332 browser_view()->tabstrip()->GetMinimumSize().width(); |
| 343 min_width = std::max(min_width, | 333 min_width = std::max(min_width, |
| 344 min_tabstrip_width + GetTabStripLeftInset() + GetTabStripRightInset()); | 334 min_tabstrip_width + GetTabStripLeftInset() + GetTabStripRightInset()); |
| 345 } | 335 } |
| 346 return gfx::Size(min_width, min_client_view_size.height()); | 336 return gfx::Size(min_width, min_client_view_size.height()); |
| 347 } | 337 } |
| 348 | 338 |
| 349 void BrowserNonClientFrameViewAsh::OnThemeChanged() { | |
| 350 BrowserNonClientFrameView::OnThemeChanged(); | |
| 351 header_painter_->OnThemeChanged(); | |
| 352 } | |
| 353 | |
| 354 /////////////////////////////////////////////////////////////////////////////// | 339 /////////////////////////////////////////////////////////////////////////////// |
| 355 // chrome::TabIconViewModel overrides: | 340 // chrome::TabIconViewModel overrides: |
| 356 | 341 |
| 357 bool BrowserNonClientFrameViewAsh::ShouldTabIconViewAnimate() const { | 342 bool BrowserNonClientFrameViewAsh::ShouldTabIconViewAnimate() const { |
| 358 // This function is queried during the creation of the window as the | 343 // This function is queried during the creation of the window as the |
| 359 // TabIconView we host is initialized, so we need to NULL check the selected | 344 // TabIconView we host is initialized, so we need to NULL check the selected |
| 360 // WebContents because in this condition there is not yet a selected tab. | 345 // WebContents because in this condition there is not yet a selected tab. |
| 361 content::WebContents* current_tab = browser_view()->GetActiveWebContents(); | 346 content::WebContents* current_tab = browser_view()->GetActiveWebContents(); |
| 362 return current_tab ? current_tab->IsLoading() : false; | 347 return current_tab ? current_tab->IsLoading() : false; |
| 363 } | 348 } |
| 364 | 349 |
| 365 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { | 350 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { |
| 366 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 351 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
| 367 if (!delegate) | 352 if (!delegate) |
| 368 return gfx::ImageSkia(); | 353 return gfx::ImageSkia(); |
| 369 return delegate->GetWindowIcon(); | 354 return delegate->GetWindowIcon(); |
| 370 } | 355 } |
| 371 | 356 |
| 372 /////////////////////////////////////////////////////////////////////////////// | 357 /////////////////////////////////////////////////////////////////////////////// |
| 373 // BrowserNonClientFrameViewAsh, private: | 358 // BrowserNonClientFrameViewAsh, private: |
| 374 | 359 |
| 375 int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const { | 360 int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const { |
| 376 return avatar_button() ? kAvatarSideSpacing + | 361 return avatar_button() ? kAvatarSideSpacing + |
| 377 browser_view()->GetOTRAvatarIcon().width() + kAvatarSideSpacing : | 362 browser_view()->GetOTRAvatarIcon().width() + kAvatarSideSpacing : |
| 378 kTabstripLeftSpacing; | 363 kTabstripLeftSpacing; |
| 379 } | 364 } |
| 380 | 365 |
| 381 int BrowserNonClientFrameViewAsh::GetTabStripRightInset() const { | 366 int BrowserNonClientFrameViewAsh::GetTabStripRightInset() const { |
| 382 return header_painter_->GetRightInset() + kTabstripRightSpacing; | 367 return caption_button_container_->GetPreferredSize().width() + |
| 368 kTabstripRightSpacing; | |
| 383 } | 369 } |
| 384 | 370 |
| 385 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { | 371 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { |
| 386 ImmersiveModeController* immersive_controller = | 372 ImmersiveModeController* immersive_controller = |
| 387 browser_view()->immersive_mode_controller(); | 373 browser_view()->immersive_mode_controller(); |
| 388 return immersive_controller->IsEnabled() && | 374 return immersive_controller->IsEnabled() && |
| 389 !immersive_controller->IsRevealed() && | 375 !immersive_controller->IsRevealed() && |
| 390 browser_view()->IsTabStripVisible(); | 376 browser_view()->IsTabStripVisible(); |
| 391 } | 377 } |
| 392 | 378 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 canvas->FillRect( | 500 canvas->FillRect( |
| 515 gfx::Rect(x + kClientEdgeThickness, | 501 gfx::Rect(x + kClientEdgeThickness, |
| 516 toolbar_bounds.bottom() - kClientEdgeThickness, | 502 toolbar_bounds.bottom() - kClientEdgeThickness, |
| 517 w - (2 * kClientEdgeThickness), | 503 w - (2 * kClientEdgeThickness), |
| 518 kClientEdgeThickness), | 504 kClientEdgeThickness), |
| 519 ThemeProperties::GetDefaultColor( | 505 ThemeProperties::GetDefaultColor( |
| 520 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 506 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 521 } | 507 } |
| 522 | 508 |
| 523 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { | 509 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { |
| 524 if (UsePackagedAppHeaderStyle()) { | 510 DCHECK(!UsePackagedAppHeaderStyle()); |
| 525 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? | 511 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), |
| 526 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; | 512 width(), kClientEdgeThickness), |
| 527 header_painter_->PaintHeaderContentSeparator(canvas, header_mode); | 513 ThemeProperties::GetDefaultColor( |
| 528 } else { | 514 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 529 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), | |
| 530 width(), kClientEdgeThickness), | |
| 531 ThemeProperties::GetDefaultColor( | |
| 532 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | |
| 533 } | |
| 534 } | 515 } |
| 535 | |
| 536 void BrowserNonClientFrameViewAsh::GetFrameImageIdsForTabbedBrowser( | |
| 537 int* frame_image_id, | |
| 538 int* frame_overlay_image_id) const { | |
| 539 *frame_overlay_image_id = 0; | |
| 540 | |
| 541 bool is_incognito = !browser_view()->IsRegularOrGuestSession(); | |
| 542 ui::ThemeProvider* tp = GetThemeProvider(); | |
| 543 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | |
| 544 !is_incognito) { | |
| 545 *frame_overlay_image_id = ShouldPaintAsActive() ? | |
| 546 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; | |
| 547 } | |
| 548 | |
| 549 if (ShouldPaintAsActive()) { | |
| 550 *frame_image_id = is_incognito ? | |
| 551 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME; | |
| 552 } else { | |
| 553 *frame_image_id = is_incognito ? | |
| 554 IDR_THEME_FRAME_INCOGNITO_INACTIVE : IDR_THEME_FRAME_INACTIVE; | |
| 555 } | |
| 556 | |
| 557 if ((frame()->IsMaximized() || frame()->IsFullscreen()) && | |
| 558 !tp->HasCustomImage(IDR_THEME_FRAME) && | |
| 559 !tp->HasCustomImage(*frame_image_id) && | |
| 560 *frame_overlay_image_id == 0) { | |
| 561 *frame_image_id = IDR_AURA_BROWSER_WINDOW_HEADER_BASE_MAXIMIZED; | |
| 562 } | |
| 563 } | |
| 564 | |
| 565 int BrowserNonClientFrameViewAsh::GetFrameImageIdForBrowserPopup() const { | |
| 566 // Browser popups are not themeable. | |
| 567 if (frame()->IsMaximized() || frame()->IsFullscreen()) | |
| 568 return IDR_AURA_BROWSER_WINDOW_HEADER_BASE_MAXIMIZED; | |
| 569 | |
| 570 bool is_incognito = !browser_view()->IsRegularOrGuestSession(); | |
| 571 if (ShouldPaintAsActive()) { | |
| 572 return is_incognito ? | |
| 573 IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_INCOGNITO_ACTIVE : | |
| 574 IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_ACTIVE; | |
| 575 } | |
| 576 return is_incognito ? | |
| 577 IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_INCOGNITO_INACTIVE : | |
| 578 IDR_AURA_BROWSER_WINDOW_HEADER_BASE_RESTORED_INACTIVE; | |
| 579 } | |
| 580 | |
| 581 int BrowserNonClientFrameViewAsh::GetFrameImageIdForHostedApp() const { | |
| 582 if (UsePackagedAppHeaderStyle()) { | |
| 583 return ShouldPaintAsActive() ? | |
| 584 IDR_AURA_WINDOW_HEADER_BASE_ACTIVE : | |
| 585 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; | |
| 586 } | |
| 587 return GetFrameImageIdForBrowserPopup(); | |
| 588 } | |
| OLD | NEW |