Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view.cc

Issue 146343002: Refactor OpaqueBrowserFrameView; reduce uses of kUseSystemTitleBar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 default: 423 default:
424 NOTREACHED() << "Got a notification we didn't register for!"; 424 NOTREACHED() << "Got a notification we didn't register for!";
425 break; 425 break;
426 } 426 }
427 } 427 }
428 428
429 /////////////////////////////////////////////////////////////////////////////// 429 ///////////////////////////////////////////////////////////////////////////////
430 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: 430 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation:
431 431
432 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { 432 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const {
433 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
434 // If using the system title bar, we do not want to show a second title bar
435 // inside the client area.
436 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
437 return false;
438 #endif
439
440 views::WidgetDelegate* delegate = frame()->widget_delegate(); 433 views::WidgetDelegate* delegate = frame()->widget_delegate();
441 return ShouldShowWindowTitleBar() && delegate && 434 return ShouldShowWindowTitleBar() && delegate &&
442 delegate->ShouldShowWindowIcon(); 435 delegate->ShouldShowWindowIcon();
443 } 436 }
444 437
445 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const { 438 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const {
446 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
447 // If using the system title bar, we do not want to show a second title bar
448 // inside the client area.
449 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
450 return false;
451 #endif
452
453 // |delegate| may be NULL if called from callback of InputMethodChanged while 439 // |delegate| may be NULL if called from callback of InputMethodChanged while
454 // a window is being destroyed. 440 // a window is being destroyed.
455 // See more discussion at http://crosbug.com/8958 441 // See more discussion at http://crosbug.com/8958
456 views::WidgetDelegate* delegate = frame()->widget_delegate(); 442 views::WidgetDelegate* delegate = frame()->widget_delegate();
457 return ShouldShowWindowTitleBar() && delegate && 443 return ShouldShowWindowTitleBar() && delegate &&
458 delegate->ShouldShowWindowTitle(); 444 delegate->ShouldShowWindowTitle();
459 } 445 }
460 446
461 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const { 447 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const {
462 return frame()->widget_delegate()->GetWindowTitle(); 448 return frame()->widget_delegate()->GetWindowTitle();
(...skipping 11 matching lines...) Expand all
474 460
475 bool OpaqueBrowserFrameView::ShouldLeaveOffsetNearTopBorder() const { 461 bool OpaqueBrowserFrameView::ShouldLeaveOffsetNearTopBorder() const {
476 return frame()->ShouldLeaveOffsetNearTopBorder(); 462 return frame()->ShouldLeaveOffsetNearTopBorder();
477 } 463 }
478 464
479 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { 465 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const {
480 return browser_view()->GetMinimumSize(); 466 return browser_view()->GetMinimumSize();
481 } 467 }
482 468
483 bool OpaqueBrowserFrameView::ShouldShowCaptionButtons() const { 469 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
490 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) 470 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons())
491 return false; 471 return false;
492 return ShouldShowWindowTitleBar(); 472 return ShouldShowWindowTitleBar();
493 } 473 }
494 474
495 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { 475 bool OpaqueBrowserFrameView::ShouldShowAvatar() const {
496 return browser_view()->ShouldShowAvatar(); 476 return browser_view()->ShouldShowAvatar();
497 } 477 }
498 478
499 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const { 479 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 585
606 int OpaqueBrowserFrameView::NonClientBorderThickness() const { 586 int OpaqueBrowserFrameView::NonClientBorderThickness() const {
607 return layout_->NonClientBorderThickness(); 587 return layout_->NonClientBorderThickness();
608 } 588 }
609 589
610 gfx::Rect OpaqueBrowserFrameView::IconBounds() const { 590 gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
611 return layout_->IconBounds(); 591 return layout_->IconBounds();
612 } 592 }
613 593
614 bool OpaqueBrowserFrameView::ShouldShowWindowTitleBar() const { 594 bool OpaqueBrowserFrameView::ShouldShowWindowTitleBar() const {
595 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
596 // Do not show the custom title bar if the system title bar option is enabled.
597 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
598 return false;
599 #endif
600
601 // Do not show caption buttons if the window manager is forcefully providing a
602 // title bar (e.g., in Ubuntu Unity, if the window is maximized).
615 if (!views::ViewsDelegate::views_delegate) 603 if (!views::ViewsDelegate::views_delegate)
616 return true; 604 return true;
617 return !views::ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar( 605 return !views::ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar(
618 IsMaximized()); 606 IsMaximized());
619 } 607 }
620 608
621 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { 609 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
622 frame_background_->set_frame_color(GetFrameColor()); 610 frame_background_->set_frame_color(GetFrameColor());
623 frame_background_->set_theme_image(GetFrameImage()); 611 frame_background_->set_theme_image(GetFrameImage());
624 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); 612 frame_background_->set_theme_overlay_image(GetFrameOverlayImage());
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 912
925 int OpaqueBrowserFrameView::GetTopAreaHeight() const { 913 int OpaqueBrowserFrameView::GetTopAreaHeight() const {
926 gfx::ImageSkia* frame_image = GetFrameImage(); 914 gfx::ImageSkia* frame_image = GetFrameImage();
927 int top_area_height = frame_image->height(); 915 int top_area_height = frame_image->height();
928 if (browser_view()->IsTabStripVisible()) { 916 if (browser_view()->IsTabStripVisible()) {
929 top_area_height = std::max(top_area_height, 917 top_area_height = std::max(top_area_height,
930 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); 918 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom());
931 } 919 }
932 return top_area_height; 920 return top_area_height;
933 } 921 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698