| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 int BrowserNonClientFrameViewMus::GetThemeBackgroundXInset() const { | 164 int BrowserNonClientFrameViewMus::GetThemeBackgroundXInset() const { |
| 165 return 5; | 165 return 5; |
| 166 } | 166 } |
| 167 | 167 |
| 168 void BrowserNonClientFrameViewMus::UpdateThrobber(bool running) { | 168 void BrowserNonClientFrameViewMus::UpdateThrobber(bool running) { |
| 169 if (window_icon_) | 169 if (window_icon_) |
| 170 window_icon_->Update(); | 170 window_icon_->Update(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 views::View* BrowserNonClientFrameViewMus::GetProfileSwitcherView() const { | 173 views::MenuButton* BrowserNonClientFrameViewMus::GetProfileSwitcherButton() |
| 174 const { |
| 174 #if defined(FRAME_AVATAR_BUTTON) | 175 #if defined(FRAME_AVATAR_BUTTON) |
| 175 return profile_switcher_.view(); | 176 return profile_switcher_.button(); |
| 176 #else | 177 #else |
| 177 return nullptr; | 178 return nullptr; |
| 178 #endif | 179 #endif |
| 179 } | 180 } |
| 180 | 181 |
| 181 void BrowserNonClientFrameViewMus::UpdateClientArea() { | 182 void BrowserNonClientFrameViewMus::UpdateClientArea() { |
| 182 std::vector<gfx::Rect> additional_client_area; | 183 std::vector<gfx::Rect> additional_client_area; |
| 183 int top_container_offset = 0; | 184 int top_container_offset = 0; |
| 184 ImmersiveModeController* immersive_mode_controller = | 185 ImmersiveModeController* immersive_mode_controller = |
| 185 browser_view()->immersive_mode_controller(); | 186 browser_view()->immersive_mode_controller(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 gfx::Rect BrowserNonClientFrameViewMus::GetWindowBoundsForClientBounds( | 244 gfx::Rect BrowserNonClientFrameViewMus::GetWindowBoundsForClientBounds( |
| 244 const gfx::Rect& client_bounds) const { | 245 const gfx::Rect& client_bounds) const { |
| 245 return client_bounds; | 246 return client_bounds; |
| 246 } | 247 } |
| 247 | 248 |
| 248 int BrowserNonClientFrameViewMus::NonClientHitTest(const gfx::Point& point) { | 249 int BrowserNonClientFrameViewMus::NonClientHitTest(const gfx::Point& point) { |
| 249 // TODO(sky): figure out how this interaction should work. | 250 // TODO(sky): figure out how this interaction should work. |
| 250 int hit_test = HTCLIENT; | 251 int hit_test = HTCLIENT; |
| 251 | 252 |
| 252 #if defined(FRAME_AVATAR_BUTTON) | 253 #if defined(FRAME_AVATAR_BUTTON) |
| 253 if (hit_test == HTCAPTION && profile_switcher_.view() && | 254 views::MenuButton* avatar_button = GetProfileSwitcherButton(); |
| 254 ConvertedHitTest(this, profile_switcher_.view(), point)) { | 255 if (hit_test == HTCAPTION && avatar_button && |
| 256 ConvertedHitTest(this, avatar_button, point)) { |
| 255 return HTCLIENT; | 257 return HTCLIENT; |
| 256 } | 258 } |
| 257 #endif | 259 #endif |
| 258 | 260 |
| 259 // When the window is restored we want a large click target above the tabs | 261 // When the window is restored we want a large click target above the tabs |
| 260 // to drag the window, so redirect clicks in the tab's shadow to caption. | 262 // to drag the window, so redirect clicks in the tab's shadow to caption. |
| 261 if (hit_test == HTCLIENT && | 263 if (hit_test == HTCLIENT && |
| 262 !(frame()->IsMaximized() || frame()->IsFullscreen())) { | 264 !(frame()->IsMaximized() || frame()->IsFullscreen())) { |
| 263 // Convert point to client coordinates. | 265 // Convert point to client coordinates. |
| 264 gfx::Point client_point(point); | 266 gfx::Point client_point(point); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 PaintToolbarBackground(canvas); | 300 PaintToolbarBackground(canvas); |
| 299 else if (!UsePackagedAppHeaderStyle()) | 301 else if (!UsePackagedAppHeaderStyle()) |
| 300 PaintContentEdge(canvas); | 302 PaintContentEdge(canvas); |
| 301 } | 303 } |
| 302 | 304 |
| 303 void BrowserNonClientFrameViewMus::Layout() { | 305 void BrowserNonClientFrameViewMus::Layout() { |
| 304 if (profile_indicator_icon()) | 306 if (profile_indicator_icon()) |
| 305 LayoutIncognitoButton(); | 307 LayoutIncognitoButton(); |
| 306 | 308 |
| 307 #if defined(FRAME_AVATAR_BUTTON) | 309 #if defined(FRAME_AVATAR_BUTTON) |
| 308 if (profile_switcher_.view()) | 310 if (GetProfileSwitcherButton()) |
| 309 LayoutProfileSwitcher(); | 311 LayoutProfileSwitcher(); |
| 310 #endif | 312 #endif |
| 311 | 313 |
| 312 BrowserNonClientFrameView::Layout(); | 314 BrowserNonClientFrameView::Layout(); |
| 313 | 315 |
| 314 UpdateClientArea(); | 316 UpdateClientArea(); |
| 315 } | 317 } |
| 316 | 318 |
| 317 const char* BrowserNonClientFrameViewMus::GetClassName() const { | 319 const char* BrowserNonClientFrameViewMus::GetClassName() const { |
| 318 return kViewClassName; | 320 return kViewClassName; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 return avatar_right + kAvatarIconPadding + | 403 return avatar_right + kAvatarIconPadding + |
| 402 frame_values().normal_insets.left(); | 404 frame_values().normal_insets.left(); |
| 403 } | 405 } |
| 404 | 406 |
| 405 int BrowserNonClientFrameViewMus::GetTabStripRightInset() const { | 407 int BrowserNonClientFrameViewMus::GetTabStripRightInset() const { |
| 406 const int frame_right_insets = frame_values().normal_insets.right() + | 408 const int frame_right_insets = frame_values().normal_insets.right() + |
| 407 frame_values().max_title_bar_button_width; | 409 frame_values().max_title_bar_button_width; |
| 408 int right_inset = kTabstripRightSpacing + frame_right_insets; | 410 int right_inset = kTabstripRightSpacing + frame_right_insets; |
| 409 | 411 |
| 410 #if defined(FRAME_AVATAR_BUTTON) | 412 #if defined(FRAME_AVATAR_BUTTON) |
| 411 if (profile_switcher_.view()) { | 413 if (GetProfileSwitcherButton()) { |
| 412 right_inset += kAvatarButtonOffset + | 414 right_inset += kAvatarButtonOffset + |
| 413 profile_switcher_.view()->GetPreferredSize().width(); | 415 GetProfileSwitcherButton()->GetPreferredSize().width(); |
| 414 } | 416 } |
| 415 #endif | 417 #endif |
| 416 | 418 |
| 417 return right_inset; | 419 return right_inset; |
| 418 } | 420 } |
| 419 | 421 |
| 420 bool BrowserNonClientFrameViewMus::UsePackagedAppHeaderStyle() const { | 422 bool BrowserNonClientFrameViewMus::UsePackagedAppHeaderStyle() const { |
| 421 // Use for non tabbed trusted source windows, e.g. Settings, as well as apps. | 423 // Use for non tabbed trusted source windows, e.g. Settings, as well as apps. |
| 422 const Browser* const browser = browser_view()->browser(); | 424 const Browser* const browser = browser_view()->browser(); |
| 423 return (!browser->is_type_tabbed() && browser->is_trusted_source()) || | 425 return (!browser->is_type_tabbed() && browser->is_trusted_source()) || |
| (...skipping 13 matching lines...) Expand all Loading... |
| 437 int avatar_height = incognito_icon.height(); | 439 int avatar_height = incognito_icon.height(); |
| 438 | 440 |
| 439 gfx::Rect avatar_bounds(kAvatarIconPadding, avatar_y, incognito_icon.width(), | 441 gfx::Rect avatar_bounds(kAvatarIconPadding, avatar_y, incognito_icon.width(), |
| 440 avatar_height); | 442 avatar_height); |
| 441 profile_indicator_icon()->SetBoundsRect(avatar_bounds); | 443 profile_indicator_icon()->SetBoundsRect(avatar_bounds); |
| 442 profile_indicator_icon()->SetVisible(true); | 444 profile_indicator_icon()->SetVisible(true); |
| 443 } | 445 } |
| 444 | 446 |
| 445 void BrowserNonClientFrameViewMus::LayoutProfileSwitcher() { | 447 void BrowserNonClientFrameViewMus::LayoutProfileSwitcher() { |
| 446 #if defined(FRAME_AVATAR_BUTTON) | 448 #if defined(FRAME_AVATAR_BUTTON) |
| 447 gfx::Size button_size = profile_switcher_.view()->GetPreferredSize(); | 449 gfx::Size button_size = GetProfileSwitcherButton()->GetPreferredSize(); |
| 448 int button_x = width() - GetTabStripRightInset() + kAvatarButtonOffset; | 450 int button_x = width() - GetTabStripRightInset() + kAvatarButtonOffset; |
| 449 profile_switcher_.view()->SetBounds(button_x, 0, button_size.width(), | 451 GetProfileSwitcherButton()->SetBounds(button_x, 0, button_size.width(), |
| 450 button_size.height()); | 452 button_size.height()); |
| 451 #endif | 453 #endif |
| 452 } | 454 } |
| 453 | 455 |
| 454 bool BrowserNonClientFrameViewMus::ShouldPaint() const { | 456 bool BrowserNonClientFrameViewMus::ShouldPaint() const { |
| 455 if (!frame()->IsFullscreen()) | 457 if (!frame()->IsFullscreen()) |
| 456 return true; | 458 return true; |
| 457 | 459 |
| 458 // We need to paint when the top-of-window views are revealed in immersive | 460 // We need to paint when the top-of-window views are revealed in immersive |
| 459 // fullscreen. | 461 // fullscreen. |
| 460 ImmersiveModeController* immersive_mode_controller = | 462 ImmersiveModeController* immersive_mode_controller = |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 // TODO: move ash_layout_constants to ash/public/cpp. | 519 // TODO: move ash_layout_constants to ash/public/cpp. |
| 518 const bool restored = !frame()->IsMaximized() && !frame()->IsFullscreen(); | 520 const bool restored = !frame()->IsMaximized() && !frame()->IsFullscreen(); |
| 519 return GetAshLayoutSize(restored | 521 return GetAshLayoutSize(restored |
| 520 ? AshLayoutSize::BROWSER_RESTORED_CAPTION_BUTTON | 522 ? AshLayoutSize::BROWSER_RESTORED_CAPTION_BUTTON |
| 521 : AshLayoutSize::BROWSER_MAXIMIZED_CAPTION_BUTTON) | 523 : AshLayoutSize::BROWSER_MAXIMIZED_CAPTION_BUTTON) |
| 522 .height(); | 524 .height(); |
| 523 #else | 525 #else |
| 524 return views::WindowManagerFrameValues::instance().normal_insets.top(); | 526 return views::WindowManagerFrameValues::instance().normal_insets.top(); |
| 525 #endif | 527 #endif |
| 526 } | 528 } |
| OLD | NEW |