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

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: Fixed tests. Created 6 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 default: 424 default:
425 NOTREACHED() << "Got a notification we didn't register for!"; 425 NOTREACHED() << "Got a notification we didn't register for!";
426 break; 426 break;
427 } 427 }
428 } 428 }
429 429
430 /////////////////////////////////////////////////////////////////////////////// 430 ///////////////////////////////////////////////////////////////////////////////
431 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: 431 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation:
432 432
433 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { 433 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const {
434 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
435 // If using the system title bar, we do not want to show a second title bar
436 // inside the client area.
437 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
438 return false;
439 #endif
440
441 views::WidgetDelegate* delegate = frame()->widget_delegate(); 434 views::WidgetDelegate* delegate = frame()->widget_delegate();
442 return ShouldShowWindowTitleBar() && delegate && 435 return ShouldShowWindowTitleBar() && delegate &&
443 delegate->ShouldShowWindowIcon(); 436 delegate->ShouldShowWindowIcon();
444 } 437 }
445 438
446 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const { 439 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const {
447 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
448 // If using the system title bar, we do not want to show a second title bar
449 // inside the client area.
450 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
451 return false;
452 #endif
453
454 // |delegate| may be NULL if called from callback of InputMethodChanged while 440 // |delegate| may be NULL if called from callback of InputMethodChanged while
455 // a window is being destroyed. 441 // a window is being destroyed.
456 // See more discussion at http://crosbug.com/8958 442 // See more discussion at http://crosbug.com/8958
457 views::WidgetDelegate* delegate = frame()->widget_delegate(); 443 views::WidgetDelegate* delegate = frame()->widget_delegate();
458 return ShouldShowWindowTitleBar() && delegate && 444 return ShouldShowWindowTitleBar() && delegate &&
459 delegate->ShouldShowWindowTitle(); 445 delegate->ShouldShowWindowTitle();
460 } 446 }
461 447
462 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const { 448 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const {
463 return frame()->widget_delegate()->GetWindowTitle(); 449 return frame()->widget_delegate()->GetWindowTitle();
(...skipping 12 matching lines...) Expand all
476 462
477 bool OpaqueBrowserFrameView::ShouldLeaveOffsetNearTopBorder() const { 463 bool OpaqueBrowserFrameView::ShouldLeaveOffsetNearTopBorder() const {
478 return frame()->ShouldLeaveOffsetNearTopBorder(); 464 return frame()->ShouldLeaveOffsetNearTopBorder();
479 } 465 }
480 466
481 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { 467 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const {
482 return browser_view()->GetMinimumSize(); 468 return browser_view()->GetMinimumSize();
483 } 469 }
484 470
485 bool OpaqueBrowserFrameView::ShouldShowCaptionButtons() const { 471 bool OpaqueBrowserFrameView::ShouldShowCaptionButtons() const {
486 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
487 // Do not show caption buttons if the system title bar is being used.
488 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
489 return false;
490 #endif
491
492 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) 472 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons())
493 return false; 473 return false;
494 return ShouldShowWindowTitleBar(); 474 return ShouldShowWindowTitleBar();
495 } 475 }
496 476
497 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { 477 bool OpaqueBrowserFrameView::ShouldShowAvatar() const {
498 return browser_view()->ShouldShowAvatar(); 478 return browser_view()->ShouldShowAvatar();
499 } 479 }
500 480
501 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const { 481 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 587
608 int OpaqueBrowserFrameView::NonClientBorderThickness() const { 588 int OpaqueBrowserFrameView::NonClientBorderThickness() const {
609 return layout_->NonClientBorderThickness(); 589 return layout_->NonClientBorderThickness();
610 } 590 }
611 591
612 gfx::Rect OpaqueBrowserFrameView::IconBounds() const { 592 gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
613 return layout_->IconBounds(); 593 return layout_->IconBounds();
614 } 594 }
615 595
616 bool OpaqueBrowserFrameView::ShouldShowWindowTitleBar() const { 596 bool OpaqueBrowserFrameView::ShouldShowWindowTitleBar() const {
597 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
598 // Do not show the custom title bar if the system title bar option is enabled.
599 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
600 return false;
601 #endif
602
603 // Do not show caption buttons if the window manager is forcefully providing a
604 // title bar (e.g., in Ubuntu Unity, if the window is maximized).
617 if (!views::ViewsDelegate::views_delegate) 605 if (!views::ViewsDelegate::views_delegate)
618 return true; 606 return true;
619 return !views::ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar( 607 return !views::ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar(
620 IsMaximized()); 608 IsMaximized());
621 } 609 }
622 610
623 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { 611 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
624 frame_background_->set_frame_color(GetFrameColor()); 612 frame_background_->set_frame_color(GetFrameColor());
625 frame_background_->set_theme_image(GetFrameImage()); 613 frame_background_->set_theme_image(GetFrameImage());
626 frame_background_->set_theme_overlay_image(GetFrameOverlayImage()); 614 frame_background_->set_theme_overlay_image(GetFrameOverlayImage());
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 914
927 int OpaqueBrowserFrameView::GetTopAreaHeight() const { 915 int OpaqueBrowserFrameView::GetTopAreaHeight() const {
928 gfx::ImageSkia* frame_image = GetFrameImage(); 916 gfx::ImageSkia* frame_image = GetFrameImage();
929 int top_area_height = frame_image->height(); 917 int top_area_height = frame_image->height();
930 if (browser_view()->IsTabStripVisible()) { 918 if (browser_view()->IsTabStripVisible()) {
931 top_area_height = std::max(top_area_height, 919 top_area_height = std::max(top_area_height,
932 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); 920 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom());
933 } 921 }
934 return top_area_height; 922 return top_area_height;
935 } 923 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698