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

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: Fixing jamescook nits. Created 7 years 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 new_avatar_button()->GetMirroredBounds().Contains(point))) 215 new_avatar_button()->GetMirroredBounds().Contains(point)))
214 return HTCLIENT; 216 return HTCLIENT;
215 217
216 int frame_component = frame()->client_view()->NonClientHitTest(point); 218 int frame_component = frame()->client_view()->NonClientHitTest(point);
217 219
218 // See if we're in the sysmenu region. We still have to check the tabstrip 220 // See if we're in the sysmenu region. We still have to check the tabstrip
219 // first so that clicks in a tab don't get treated as sysmenu clicks. 221 // first so that clicks in a tab don't get treated as sysmenu clicks.
220 gfx::Rect sysmenu_rect(IconBounds()); 222 gfx::Rect sysmenu_rect(IconBounds());
221 // In maximized mode we extend the rect to the screen corner to take advantage 223 // In maximized mode we extend the rect to the screen corner to take advantage
222 // of Fitts' Law. 224 // of Fitts' Law.
223 if (frame()->IsMaximized()) 225 if (layout_->IsTitleBarCondensed())
224 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); 226 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom());
225 sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect)); 227 sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect));
226 if (sysmenu_rect.Contains(point)) 228 if (sysmenu_rect.Contains(point))
227 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; 229 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU;
228 230
229 if (frame_component != HTNOWHERE) 231 if (frame_component != HTNOWHERE)
230 return frame_component; 232 return frame_component;
231 233
232 // Then see if the point is within any of the window controls. 234 // Then see if the point is within any of the window controls.
233 if (close_button_ && close_button_->visible() && 235 if (close_button_ && close_button_->visible() &&
(...skipping 18 matching lines...) Expand all
252 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, 254 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize,
253 delegate->CanResize()); 255 delegate->CanResize());
254 // Fall back to the caption if no other component matches. 256 // Fall back to the caption if no other component matches.
255 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; 257 return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
256 } 258 }
257 259
258 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, 260 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size,
259 gfx::Path* window_mask) { 261 gfx::Path* window_mask) {
260 DCHECK(window_mask); 262 DCHECK(window_mask);
261 263
262 if (frame()->IsMaximized() || frame()->IsFullscreen()) 264 if (layout_->IsTitleBarCondensed() || frame()->IsFullscreen())
263 return; 265 return;
264 266
265 views::GetDefaultWindowMask(size, window_mask); 267 views::GetDefaultWindowMask(size, window_mask);
266 } 268 }
267 269
268 void OpaqueBrowserFrameView::ResetWindowControls() { 270 void OpaqueBrowserFrameView::ResetWindowControls() {
269 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) 271 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons())
270 return; 272 return;
271 restore_button_->SetState(views::CustomButton::STATE_NORMAL); 273 restore_button_->SetState(views::CustomButton::STATE_NORMAL);
272 minimize_button_->SetState(views::CustomButton::STATE_NORMAL); 274 minimize_button_->SetState(views::CustomButton::STATE_NORMAL);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 default: 405 default:
404 NOTREACHED() << "Got a notification we didn't register for!"; 406 NOTREACHED() << "Got a notification we didn't register for!";
405 break; 407 break;
406 } 408 }
407 } 409 }
408 410
409 /////////////////////////////////////////////////////////////////////////////// 411 ///////////////////////////////////////////////////////////////////////////////
410 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: 412 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation:
411 413
412 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { 414 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const {
415 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
416 // If using the system title bar, we do not want to show a second title bar
417 // inside the client area.
418 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
419 return false;
420 #endif
421
413 views::WidgetDelegate* delegate = frame()->widget_delegate(); 422 views::WidgetDelegate* delegate = frame()->widget_delegate();
414 return delegate && delegate->ShouldShowWindowIcon(); 423 return delegate && delegate->ShouldShowWindowIcon();
415 } 424 }
416 425
417 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const { 426 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const {
427 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
428 // If using the system title bar, we do not want to show a second title bar
429 // inside the client area.
430 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar))
431 return false;
432 #endif
433
418 // |delegate| may be NULL if called from callback of InputMethodChanged while 434 // |delegate| may be NULL if called from callback of InputMethodChanged while
419 // a window is being destroyed. 435 // a window is being destroyed.
420 // See more discussion at http://crosbug.com/8958 436 // See more discussion at http://crosbug.com/8958
421 views::WidgetDelegate* delegate = frame()->widget_delegate(); 437 views::WidgetDelegate* delegate = frame()->widget_delegate();
422 return delegate && delegate->ShouldShowWindowTitle(); 438 return delegate && delegate->ShouldShowWindowTitle();
423 } 439 }
424 440
425 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const { 441 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const {
426 return frame()->widget_delegate()->GetWindowTitle(); 442 return frame()->widget_delegate()->GetWindowTitle();
427 } 443 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 return s; 514 return s;
499 } 515 }
500 516
501 /////////////////////////////////////////////////////////////////////////////// 517 ///////////////////////////////////////////////////////////////////////////////
502 // OpaqueBrowserFrameView, views::View overrides: 518 // OpaqueBrowserFrameView, views::View overrides:
503 519
504 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { 520 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
505 if (frame()->IsFullscreen()) 521 if (frame()->IsFullscreen())
506 return; // Nothing is visible, so don't bother to paint. 522 return; // Nothing is visible, so don't bother to paint.
507 523
508 if (frame()->IsMaximized()) 524 if (layout_->IsTitleBarCondensed())
509 PaintMaximizedFrameBorder(canvas); 525 PaintMaximizedFrameBorder(canvas);
510 else 526 else
511 PaintRestoredFrameBorder(canvas); 527 PaintRestoredFrameBorder(canvas);
512 528
513 // The window icon and title are painted by their respective views. 529 // The window icon and title are painted by their respective views.
514 /* TODO(pkasting): If this window is active, we should also draw a drop 530 /* TODO(pkasting): If this window is active, we should also draw a drop
515 * shadow on the title. This is tricky, because we don't want to hardcode a 531 * shadow on the title. This is tricky, because we don't want to hardcode a
516 * shadow color (since we want to work with various themes), but we can't 532 * shadow color (since we want to work with various themes), but we can't
517 * alpha-blend either (since the Windows text APIs don't really do this). 533 * alpha-blend either (since the Windows text APIs don't really do this).
518 * So we'd need to sample the background color at the right location and 534 * So we'd need to sample the background color at the right location and
519 * synthesize a good shadow color. */ 535 * synthesize a good shadow color. */
520 536
521 if (browser_view()->IsToolbarVisible()) 537 if (browser_view()->IsToolbarVisible())
522 PaintToolbarBackground(canvas); 538 PaintToolbarBackground(canvas);
523 if (!frame()->IsMaximized()) 539 if (!layout_->IsTitleBarCondensed())
524 PaintRestoredClientEdge(canvas); 540 PaintRestoredClientEdge(canvas);
525 } 541 }
526 542
527 /////////////////////////////////////////////////////////////////////////////// 543 ///////////////////////////////////////////////////////////////////////////////
528 // OpaqueBrowserFrameView, private: 544 // OpaqueBrowserFrameView, private:
529 545
530 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton( 546 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton(
531 int normal_image_id, 547 int normal_image_id,
532 int hot_image_id, 548 int hot_image_id,
533 int pushed_image_id, 549 int pushed_image_id,
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 893
878 int OpaqueBrowserFrameView::GetTopAreaHeight() const { 894 int OpaqueBrowserFrameView::GetTopAreaHeight() const {
879 gfx::ImageSkia* frame_image = GetFrameImage(); 895 gfx::ImageSkia* frame_image = GetFrameImage();
880 int top_area_height = frame_image->height(); 896 int top_area_height = frame_image->height();
881 if (browser_view()->IsTabStripVisible()) { 897 if (browser_view()->IsTabStripVisible()) {
882 top_area_height = std::max(top_area_height, 898 top_area_height = std::max(top_area_height,
883 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); 899 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom());
884 } 900 }
885 return top_area_height; 901 return top_area_height;
886 } 902 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698