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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "ui/gfx/canvas.h" | 41 #include "ui/gfx/canvas.h" |
42 #include "ui/gfx/font_list.h" | 42 #include "ui/gfx/font_list.h" |
43 #include "ui/gfx/image/image.h" | 43 #include "ui/gfx/image/image.h" |
44 #include "ui/gfx/image/image_skia.h" | 44 #include "ui/gfx/image/image_skia.h" |
45 #include "ui/gfx/path.h" | 45 #include "ui/gfx/path.h" |
46 #include "ui/gfx/rect_conversions.h" | 46 #include "ui/gfx/rect_conversions.h" |
47 #include "ui/views/controls/button/image_button.h" | 47 #include "ui/views/controls/button/image_button.h" |
48 #include "ui/views/controls/image_view.h" | 48 #include "ui/views/controls/image_view.h" |
49 #include "ui/views/controls/label.h" | 49 #include "ui/views/controls/label.h" |
50 #include "ui/views/layout/layout_constants.h" | 50 #include "ui/views/layout/layout_constants.h" |
| 51 #include "ui/views/views_delegate.h" |
51 #include "ui/views/widget/root_view.h" | 52 #include "ui/views/widget/root_view.h" |
52 #include "ui/views/window/frame_background.h" | 53 #include "ui/views/window/frame_background.h" |
53 #include "ui/views/window/window_shape.h" | 54 #include "ui/views/window/window_shape.h" |
54 | 55 |
55 #if defined(OS_LINUX) | 56 #if defined(OS_LINUX) |
56 #include "ui/views/controls/menu/menu_runner.h" | 57 #include "ui/views/controls/menu/menu_runner.h" |
57 #endif | 58 #endif |
58 | 59 |
59 using content::WebContents; | 60 using content::WebContents; |
60 | 61 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 | 431 |
431 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { | 432 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { |
432 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 433 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
433 // If using the system title bar, we do not want to show a second title bar | 434 // If using the system title bar, we do not want to show a second title bar |
434 // inside the client area. | 435 // inside the client area. |
435 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar)) | 436 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar)) |
436 return false; | 437 return false; |
437 #endif | 438 #endif |
438 | 439 |
439 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 440 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
440 return platform_observer_->ShouldShowTitleBar() && delegate && | 441 return ShouldShowWindowTitleBar() && delegate && |
441 delegate->ShouldShowWindowIcon(); | 442 delegate->ShouldShowWindowIcon(); |
442 } | 443 } |
443 | 444 |
444 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const { | 445 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const { |
445 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 446 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
446 // If using the system title bar, we do not want to show a second title bar | 447 // If using the system title bar, we do not want to show a second title bar |
447 // inside the client area. | 448 // inside the client area. |
448 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar)) | 449 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar)) |
449 return false; | 450 return false; |
450 #endif | 451 #endif |
451 | 452 |
452 // |delegate| may be NULL if called from callback of InputMethodChanged while | 453 // |delegate| may be NULL if called from callback of InputMethodChanged while |
453 // a window is being destroyed. | 454 // a window is being destroyed. |
454 // See more discussion at http://crosbug.com/8958 | 455 // See more discussion at http://crosbug.com/8958 |
455 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 456 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
456 return platform_observer_->ShouldShowTitleBar() && delegate && | 457 return ShouldShowWindowTitleBar() && delegate && |
457 delegate->ShouldShowWindowTitle(); | 458 delegate->ShouldShowWindowTitle(); |
458 } | 459 } |
459 | 460 |
460 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const { | 461 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const { |
461 return frame()->widget_delegate()->GetWindowTitle(); | 462 return frame()->widget_delegate()->GetWindowTitle(); |
462 } | 463 } |
463 | 464 |
464 int OpaqueBrowserFrameView::GetIconSize() const { | 465 int OpaqueBrowserFrameView::GetIconSize() const { |
465 #if defined(OS_WIN) | 466 #if defined(OS_WIN) |
466 // This metric scales up if either the titlebar height or the titlebar font | 467 // This metric scales up if either the titlebar height or the titlebar font |
467 // size are increased. | 468 // size are increased. |
468 return GetSystemMetrics(SM_CYSMICON); | 469 return GetSystemMetrics(SM_CYSMICON); |
469 #else | 470 #else |
470 return std::max(BrowserFrame::GetTitleFont().GetHeight(), kIconMinimumSize); | 471 return std::max(BrowserFrame::GetTitleFont().GetHeight(), kIconMinimumSize); |
471 #endif | 472 #endif |
472 } | 473 } |
473 | 474 |
474 bool OpaqueBrowserFrameView::ShouldLeaveOffsetNearTopBorder() const { | 475 bool OpaqueBrowserFrameView::ShouldLeaveOffsetNearTopBorder() const { |
475 return frame()->ShouldLeaveOffsetNearTopBorder(); | 476 return frame()->ShouldLeaveOffsetNearTopBorder(); |
476 } | 477 } |
477 | 478 |
478 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { | 479 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { |
479 return browser_view()->GetMinimumSize(); | 480 return browser_view()->GetMinimumSize(); |
480 } | 481 } |
481 | 482 |
482 bool OpaqueBrowserFrameView::ShouldShowCaptionButtons() const { | 483 bool OpaqueBrowserFrameView::ShouldShowCaptionButtons() const { |
| 484 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 485 // Do not show caption buttons if the system title bar is being used. |
| 486 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar)) |
| 487 return false; |
| 488 #endif |
| 489 |
483 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) | 490 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) |
484 return false; | 491 return false; |
485 return platform_observer_->ShouldShowCaptionButtons(); | 492 return ShouldShowWindowTitleBar(); |
486 } | 493 } |
487 | 494 |
488 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { | 495 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { |
489 return browser_view()->ShouldShowAvatar(); | 496 return browser_view()->ShouldShowAvatar(); |
490 } | 497 } |
491 | 498 |
492 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const { | 499 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const { |
493 return browser_view()->IsRegularOrGuestSession(); | 500 return browser_view()->IsRegularOrGuestSession(); |
494 } | 501 } |
495 | 502 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 } | 604 } |
598 | 605 |
599 int OpaqueBrowserFrameView::NonClientBorderThickness() const { | 606 int OpaqueBrowserFrameView::NonClientBorderThickness() const { |
600 return layout_->NonClientBorderThickness(); | 607 return layout_->NonClientBorderThickness(); |
601 } | 608 } |
602 | 609 |
603 gfx::Rect OpaqueBrowserFrameView::IconBounds() const { | 610 gfx::Rect OpaqueBrowserFrameView::IconBounds() const { |
604 return layout_->IconBounds(); | 611 return layout_->IconBounds(); |
605 } | 612 } |
606 | 613 |
| 614 bool OpaqueBrowserFrameView::ShouldShowWindowTitleBar() const { |
| 615 if (!views::ViewsDelegate::views_delegate) |
| 616 return true; |
| 617 return !views::ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar( |
| 618 IsMaximized()); |
| 619 } |
| 620 |
607 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { | 621 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { |
608 frame_background_->set_frame_color(GetFrameColor()); | 622 frame_background_->set_frame_color(GetFrameColor()); |
609 frame_background_->set_theme_image(GetFrameImage()); | 623 frame_background_->set_theme_image(GetFrameImage()); |
610 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); | 624 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); |
611 frame_background_->set_top_area_height(GetTopAreaHeight()); | 625 frame_background_->set_top_area_height(GetTopAreaHeight()); |
612 | 626 |
613 ui::ThemeProvider* tp = GetThemeProvider(); | 627 ui::ThemeProvider* tp = GetThemeProvider(); |
614 frame_background_->SetSideImages( | 628 frame_background_->SetSideImages( |
615 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), | 629 tp->GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE), |
616 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), | 630 tp->GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER), |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 | 924 |
911 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 925 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
912 gfx::ImageSkia* frame_image = GetFrameImage(); | 926 gfx::ImageSkia* frame_image = GetFrameImage(); |
913 int top_area_height = frame_image->height(); | 927 int top_area_height = frame_image->height(); |
914 if (browser_view()->IsTabStripVisible()) { | 928 if (browser_view()->IsTabStripVisible()) { |
915 top_area_height = std::max(top_area_height, | 929 top_area_height = std::max(top_area_height, |
916 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 930 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
917 } | 931 } |
918 return top_area_height; | 932 return top_area_height; |
919 } | 933 } |
OLD | NEW |