| 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/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/profiles/profiles_state.h" | 13 #include "chrome/browser/profiles/profiles_state.h" |
| 14 #include "chrome/browser/themes/theme_properties.h" | 14 #include "chrome/browser/themes/theme_properties.h" |
| 15 #include "chrome/browser/themes/theme_service_factory.h" | 15 #include "chrome/browser/themes/theme_service_factory.h" |
| 16 #include "chrome/browser/ui/views/frame/browser_frame.h" | 16 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 17 #include "chrome/browser/ui/views/frame/browser_view.h" | 17 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 18 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" | 18 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
| 19 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci
fic.h" | 19 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci
fic.h" |
| 20 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 20 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h" |
| 21 #include "chrome/browser/ui/views/tab_icon_view.h" | 21 #include "chrome/browser/ui/views/tab_icon_view.h" |
| 22 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 22 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 23 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 23 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 24 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
| 25 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
| 26 #include "components/signin/core/browser/signin_header_helper.h" | 26 #include "components/signin/core/browser/signin_header_helper.h" |
| 27 #include "components/signin/core/common/profile_management_switches.h" | 27 #include "components/signin/core/common/profile_management_switches.h" |
| 28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 30 #include "grit/components_strings.h" | 30 #include "grit/components_strings.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 return layout_->client_view_bounds(); | 181 return layout_->client_view_bounds(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( | 184 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( |
| 185 const gfx::Rect& client_bounds) const { | 185 const gfx::Rect& client_bounds) const { |
| 186 return layout_->GetWindowBoundsForClientBounds(client_bounds); | 186 return layout_->GetWindowBoundsForClientBounds(client_bounds); |
| 187 } | 187 } |
| 188 | 188 |
| 189 bool OpaqueBrowserFrameView::IsWithinAvatarMenuButtons( | 189 bool OpaqueBrowserFrameView::IsWithinAvatarMenuButtons( |
| 190 const gfx::Point& point) const { | 190 const gfx::Point& point) const { |
| 191 if (avatar_button() && | 191 if (profile_indicator_icon() && |
| 192 avatar_button()->GetMirroredBounds().Contains(point)) { | 192 profile_indicator_icon()->GetMirroredBounds().Contains(point)) { |
| 193 return true; | 193 return true; |
| 194 } | 194 } |
| 195 if (profile_switcher_.view() && | 195 if (profile_switcher_.view() && |
| 196 profile_switcher_.view()->GetMirroredBounds().Contains(point)) { | 196 profile_switcher_.view()->GetMirroredBounds().Contains(point)) { |
| 197 return true; | 197 return true; |
| 198 } | 198 } |
| 199 | 199 |
| 200 return false; | 200 return false; |
| 201 } | 201 } |
| 202 | 202 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 } | 373 } |
| 374 | 374 |
| 375 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { | 375 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { |
| 376 return browser_view()->GetMinimumSize(); | 376 return browser_view()->GetMinimumSize(); |
| 377 } | 377 } |
| 378 | 378 |
| 379 bool OpaqueBrowserFrameView::ShouldShowCaptionButtons() const { | 379 bool OpaqueBrowserFrameView::ShouldShowCaptionButtons() const { |
| 380 return ShouldShowWindowTitleBar(); | 380 return ShouldShowWindowTitleBar(); |
| 381 } | 381 } |
| 382 | 382 |
| 383 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { | |
| 384 return browser_view()->ShouldShowAvatar(); | |
| 385 } | |
| 386 | |
| 387 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const { | 383 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const { |
| 388 return browser_view()->IsRegularOrGuestSession(); | 384 return browser_view()->IsRegularOrGuestSession(); |
| 389 } | 385 } |
| 390 | 386 |
| 391 gfx::ImageSkia OpaqueBrowserFrameView::GetOTRAvatarIcon() const { | 387 gfx::ImageSkia OpaqueBrowserFrameView::GetOTRAvatarIcon() const { |
| 392 return BrowserNonClientFrameView::GetOTRAvatarIcon(); | 388 return BrowserNonClientFrameView::GetOTRAvatarIcon(); |
| 393 } | 389 } |
| 394 | 390 |
| 395 bool OpaqueBrowserFrameView::IsMaximized() const { | 391 bool OpaqueBrowserFrameView::IsMaximized() const { |
| 396 return frame()->IsMaximized(); | 392 return frame()->IsMaximized(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 PaintClientEdge(canvas); | 451 PaintClientEdge(canvas); |
| 456 } | 452 } |
| 457 | 453 |
| 458 // BrowserNonClientFrameView: | 454 // BrowserNonClientFrameView: |
| 459 bool OpaqueBrowserFrameView::ShouldPaintAsThemed() const { | 455 bool OpaqueBrowserFrameView::ShouldPaintAsThemed() const { |
| 460 // Theme app and popup windows if |platform_observer_| wants it. | 456 // Theme app and popup windows if |platform_observer_| wants it. |
| 461 return browser_view()->IsBrowserTypeNormal() || | 457 return browser_view()->IsBrowserTypeNormal() || |
| 462 platform_observer_->IsUsingSystemTheme(); | 458 platform_observer_->IsUsingSystemTheme(); |
| 463 } | 459 } |
| 464 | 460 |
| 465 void OpaqueBrowserFrameView::UpdateAvatar() { | 461 void OpaqueBrowserFrameView::UpdateProfileIcons() { |
| 466 if (browser_view()->IsRegularOrGuestSession()) | 462 if (browser_view()->IsRegularOrGuestSession()) |
| 467 profile_switcher_.Update(AvatarButtonStyle::THEMED); | 463 profile_switcher_.Update(AvatarButtonStyle::THEMED); |
| 468 else | 464 else |
| 469 UpdateOldAvatarButton(); | 465 UpdateProfileIndicatorIcon(); |
| 470 } | 466 } |
| 471 | 467 |
| 472 /////////////////////////////////////////////////////////////////////////////// | 468 /////////////////////////////////////////////////////////////////////////////// |
| 473 // OpaqueBrowserFrameView, private: | 469 // OpaqueBrowserFrameView, private: |
| 474 | 470 |
| 475 // views::NonClientFrameView: | 471 // views::NonClientFrameView: |
| 476 bool OpaqueBrowserFrameView::DoesIntersectRect(const views::View* target, | 472 bool OpaqueBrowserFrameView::DoesIntersectRect(const views::View* target, |
| 477 const gfx::Rect& rect) const { | 473 const gfx::Rect& rect) const { |
| 478 CHECK_EQ(target, this); | 474 CHECK_EQ(target, this); |
| 479 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { | 475 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 gfx::Rect side(x, y, kClientEdgeThickness, h); | 822 gfx::Rect side(x, y, kClientEdgeThickness, h); |
| 827 canvas->FillRect(side, color); | 823 canvas->FillRect(side, color); |
| 828 if (draw_bottom) { | 824 if (draw_bottom) { |
| 829 canvas->FillRect(gfx::Rect(x, y + h, w + (2 * kClientEdgeThickness), | 825 canvas->FillRect(gfx::Rect(x, y + h, w + (2 * kClientEdgeThickness), |
| 830 kClientEdgeThickness), | 826 kClientEdgeThickness), |
| 831 color); | 827 color); |
| 832 } | 828 } |
| 833 side.Offset(w + kClientEdgeThickness, 0); | 829 side.Offset(w + kClientEdgeThickness, 0); |
| 834 canvas->FillRect(side, color); | 830 canvas->FillRect(side, color); |
| 835 } | 831 } |
| OLD | NEW |