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

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

Issue 111723012: Linux Aura: Added --use-system-title-bar flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. 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/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/profiles/profiles_state.h" 15 #include "chrome/browser/profiles/profiles_state.h"
15 #include "chrome/browser/themes/theme_properties.h" 16 #include "chrome/browser/themes/theme_properties.h"
16 #include "chrome/browser/ui/views/avatar_label.h" 17 #include "chrome/browser/ui/views/avatar_label.h"
17 #include "chrome/browser/ui/views/avatar_menu_button.h" 18 #include "chrome/browser/ui/views/avatar_menu_button.h"
18 #include "chrome/browser/ui/views/frame/browser_frame.h" 19 #include "chrome/browser/ui/views/frame/browser_frame.h"
19 #include "chrome/browser/ui/views/frame/browser_view.h" 20 #include "chrome/browser/ui/views/frame/browser_view.h"
20 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" 21 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h"
21 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci fic.h" 22 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci fic.h"
22 #include "chrome/browser/ui/views/new_avatar_button.h" 23 #include "chrome/browser/ui/views/new_avatar_button.h"
23 #include "chrome/browser/ui/views/tab_icon_view.h" 24 #include "chrome/browser/ui/views/tab_icon_view.h"
24 #include "chrome/browser/ui/views/tabs/tab_strip.h" 25 #include "chrome/browser/ui/views/tabs/tab_strip.h"
25 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 26 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
27 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
27 #include "chrome/common/profile_management_switches.h" 29 #include "chrome/common/profile_management_switches.h"
28 #include "content/public/browser/notification_service.h" 30 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
30 #include "grit/chromium_strings.h" 32 #include "grit/chromium_strings.h"
31 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
32 #include "grit/theme_resources.h" 34 #include "grit/theme_resources.h"
33 #include "grit/ui_resources.h" 35 #include "grit/ui_resources.h"
34 #include "ui/base/accessibility/accessible_view_state.h" 36 #include "ui/base/accessibility/accessible_view_state.h"
35 #include "ui/base/hit_test.h" 37 #include "ui/base/hit_test.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 new_avatar_button()->GetMirroredBounds().Contains(point))) 219 new_avatar_button()->GetMirroredBounds().Contains(point)))
218 return HTCLIENT; 220 return HTCLIENT;
219 221
220 int frame_component = frame()->client_view()->NonClientHitTest(point); 222 int frame_component = frame()->client_view()->NonClientHitTest(point);
221 223
222 // See if we're in the sysmenu region. We still have to check the tabstrip 224 // See if we're in the sysmenu region. We still have to check the tabstrip
223 // first so that clicks in a tab don't get treated as sysmenu clicks. 225 // first so that clicks in a tab don't get treated as sysmenu clicks.
224 gfx::Rect sysmenu_rect(IconBounds()); 226 gfx::Rect sysmenu_rect(IconBounds());
225 // In maximized mode we extend the rect to the screen corner to take advantage 227 // In maximized mode we extend the rect to the screen corner to take advantage
226 // of Fitts' Law. 228 // of Fitts' Law.
227 if (frame()->IsMaximized()) 229 if (layout_->IsTitleBarCondensed())
228 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); 230 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom());
229 sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect)); 231 sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect));
230 if (sysmenu_rect.Contains(point)) 232 if (sysmenu_rect.Contains(point))
231 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; 233 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU;
232 234
233 if (frame_component != HTNOWHERE) 235 if (frame_component != HTNOWHERE)
234 return frame_component; 236 return frame_component;
235 237
236 // Then see if the point is within any of the window controls. 238 // Then see if the point is within any of the window controls.
237 if (close_button_ && close_button_->visible() && 239 if (close_button_ && close_button_->visible() &&
(...skipping 18 matching lines...) Expand all
256 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, 258 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize,
257 delegate->CanResize()); 259 delegate->CanResize());
258 // Fall back to the caption if no other component matches. 260 // Fall back to the caption if no other component matches.
259 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; 261 return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
260 } 262 }
261 263
262 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, 264 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size,
263 gfx::Path* window_mask) { 265 gfx::Path* window_mask) {
264 DCHECK(window_mask); 266 DCHECK(window_mask);
265 267
266 if (frame()->IsMaximized() || frame()->IsFullscreen()) 268 if (layout_->IsTitleBarCondensed() || frame()->IsFullscreen())
267 return; 269 return;
268 270
269 views::GetDefaultWindowMask(size, window_mask); 271 views::GetDefaultWindowMask(size, window_mask);
270 } 272 }
271 273
272 void OpaqueBrowserFrameView::ResetWindowControls() { 274 void OpaqueBrowserFrameView::ResetWindowControls() {
273 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) 275 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons())
274 return; 276 return;
275 restore_button_->SetState(views::CustomButton::STATE_NORMAL); 277 restore_button_->SetState(views::CustomButton::STATE_NORMAL);
276 minimize_button_->SetState(views::CustomButton::STATE_NORMAL); 278 minimize_button_->SetState(views::CustomButton::STATE_NORMAL);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 default: 422 default:
421 NOTREACHED() << "Got a notification we didn't register for!"; 423 NOTREACHED() << "Got a notification we didn't register for!";
422 break; 424 break;
423 } 425 }
424 } 426 }
425 427
426 /////////////////////////////////////////////////////////////////////////////// 428 ///////////////////////////////////////////////////////////////////////////////
427 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: 429 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation:
428 430
429 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { 431 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const {
432 #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 // inside the client area.
435 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
436 return false;
437 #endif
438
430 views::WidgetDelegate* delegate = frame()->widget_delegate(); 439 views::WidgetDelegate* delegate = frame()->widget_delegate();
431 return platform_observer_->ShouldShowTitleBar() && delegate && 440 return platform_observer_->ShouldShowTitleBar() && delegate &&
432 delegate->ShouldShowWindowIcon(); 441 delegate->ShouldShowWindowIcon();
433 } 442 }
434 443
435 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const { 444 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const {
445 #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 // inside the client area.
448 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
449 return false;
450 #endif
451
436 // |delegate| may be NULL if called from callback of InputMethodChanged while 452 // |delegate| may be NULL if called from callback of InputMethodChanged while
437 // a window is being destroyed. 453 // a window is being destroyed.
438 // See more discussion at http://crosbug.com/8958 454 // See more discussion at http://crosbug.com/8958
439 views::WidgetDelegate* delegate = frame()->widget_delegate(); 455 views::WidgetDelegate* delegate = frame()->widget_delegate();
440 return platform_observer_->ShouldShowTitleBar() && delegate && 456 return platform_observer_->ShouldShowTitleBar() && delegate &&
441 delegate->ShouldShowWindowTitle(); 457 delegate->ShouldShowWindowTitle();
442 } 458 }
443 459
444 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const { 460 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const {
445 return frame()->widget_delegate()->GetWindowTitle(); 461 return frame()->widget_delegate()->GetWindowTitle();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 return s; 531 return s;
516 } 532 }
517 533
518 /////////////////////////////////////////////////////////////////////////////// 534 ///////////////////////////////////////////////////////////////////////////////
519 // OpaqueBrowserFrameView, views::View overrides: 535 // OpaqueBrowserFrameView, views::View overrides:
520 536
521 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { 537 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
522 if (frame()->IsFullscreen()) 538 if (frame()->IsFullscreen())
523 return; // Nothing is visible, so don't bother to paint. 539 return; // Nothing is visible, so don't bother to paint.
524 540
525 if (frame()->IsMaximized()) 541 if (layout_->IsTitleBarCondensed())
526 PaintMaximizedFrameBorder(canvas); 542 PaintMaximizedFrameBorder(canvas);
527 else 543 else
528 PaintRestoredFrameBorder(canvas); 544 PaintRestoredFrameBorder(canvas);
529 545
530 // The window icon and title are painted by their respective views. 546 // The window icon and title are painted by their respective views.
531 /* TODO(pkasting): If this window is active, we should also draw a drop 547 /* TODO(pkasting): If this window is active, we should also draw a drop
532 * shadow on the title. This is tricky, because we don't want to hardcode a 548 * shadow on the title. This is tricky, because we don't want to hardcode a
533 * shadow color (since we want to work with various themes), but we can't 549 * shadow color (since we want to work with various themes), but we can't
534 * alpha-blend either (since the Windows text APIs don't really do this). 550 * alpha-blend either (since the Windows text APIs don't really do this).
535 * So we'd need to sample the background color at the right location and 551 * So we'd need to sample the background color at the right location and
536 * synthesize a good shadow color. */ 552 * synthesize a good shadow color. */
537 553
538 if (browser_view()->IsToolbarVisible()) 554 if (browser_view()->IsToolbarVisible())
539 PaintToolbarBackground(canvas); 555 PaintToolbarBackground(canvas);
540 if (!frame()->IsMaximized()) 556 if (!layout_->IsTitleBarCondensed())
541 PaintRestoredClientEdge(canvas); 557 PaintRestoredClientEdge(canvas);
542 } 558 }
543 559
544 /////////////////////////////////////////////////////////////////////////////// 560 ///////////////////////////////////////////////////////////////////////////////
545 // OpaqueBrowserFrameView, private: 561 // OpaqueBrowserFrameView, private:
546 562
547 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton( 563 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton(
548 int normal_image_id, 564 int normal_image_id,
549 int hot_image_id, 565 int hot_image_id,
550 int pushed_image_id, 566 int pushed_image_id,
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 910
895 int OpaqueBrowserFrameView::GetTopAreaHeight() const { 911 int OpaqueBrowserFrameView::GetTopAreaHeight() const {
896 gfx::ImageSkia* frame_image = GetFrameImage(); 912 gfx::ImageSkia* frame_image = GetFrameImage();
897 int top_area_height = frame_image->height(); 913 int top_area_height = frame_image->height();
898 if (browser_view()->IsTabStripVisible()) { 914 if (browser_view()->IsTabStripVisible()) {
899 top_area_height = std::max(top_area_height, 915 top_area_height = std::max(top_area_height,
900 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); 916 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom());
901 } 917 }
902 return top_area_height; 918 return top_area_height;
903 } 919 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame.cc ('k') | chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698