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

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

Issue 6692001: Add in DOMBrowserView and Frame related classes (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/themes/browser_theme_provider.h" 9 #include "chrome/browser/themes/browser_theme_provider.h"
10 #include "chrome/browser/ui/views/frame/browser_frame.h" 10 #include "chrome/browser/ui/views/frame/browser_frame.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 380 }
381 381
382 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const { 382 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const {
383 // If the point is outside the bounds of the client area, claim it. 383 // If the point is outside the bounds of the client area, claim it.
384 bool in_nonclient = NonClientFrameView::HitTest(l); 384 bool in_nonclient = NonClientFrameView::HitTest(l);
385 if (in_nonclient) 385 if (in_nonclient)
386 return in_nonclient; 386 return in_nonclient;
387 387
388 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. 388 // Otherwise claim it only if it's in a non-tab portion of the tabstrip.
389 bool vertical_tabs = browser_view_->UseVerticalTabs(); 389 bool vertical_tabs = browser_view_->UseVerticalTabs();
390 gfx::Rect tabstrip_bounds = browser_view_->tabstrip()->bounds(); 390 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip());
391 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 391 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
392 View::ConvertPointToView(frame_->GetWindow()->client_view(), 392 View::ConvertPointToView(frame_->GetWindow()->client_view(),
393 this, &tabstrip_origin); 393 this, &tabstrip_origin);
394 tabstrip_bounds.set_origin(tabstrip_origin); 394 tabstrip_bounds.set_origin(tabstrip_origin);
395 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) || 395 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) ||
396 (vertical_tabs && l.x() > tabstrip_bounds.right())) { 396 (vertical_tabs && l.x() > tabstrip_bounds.right())) {
397 return false; 397 return false;
398 } 398 }
399 399
400 // We convert from our parent's coordinates since we assume we fill its bounds 400 // We convert from our parent's coordinates since we assume we fill its bounds
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() { 440 SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() {
441 views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate(); 441 views::WindowDelegate* delegate = frame_->GetWindow()->window_delegate();
442 if (!delegate) { 442 if (!delegate) {
443 LOG(WARNING) << "delegate is NULL, returning safe default."; 443 LOG(WARNING) << "delegate is NULL, returning safe default.";
444 return SkBitmap(); 444 return SkBitmap();
445 } 445 }
446 return delegate->GetWindowIcon(); 446 return delegate->GetWindowIcon();
447 } 447 }
448 448
449 /////////////////////////////////////////////////////////////////////////////// 449 ///////////////////////////////////////////////////////////////////////////////
450 // OpaqueBrowserFrameView, protected:
451
452 void OpaqueBrowserFrameView::LayoutOTRAvatar() {
453 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
454 int otr_bottom, otr_restored_y;
455 if (browser_view_->UseVerticalTabs()) {
456 otr_bottom = NonClientTopBorderHeight(false, false) - kOTRBottomSpacing;
457 otr_restored_y = kFrameShadowThickness;
458 } else {
459 otr_bottom = GetHorizontalTabStripVerticalOffset(false) +
460 browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
461 otr_restored_y = otr_bottom - otr_avatar_icon.height();
462 }
463 int otr_y = frame_->GetWindow()->IsMaximized() ?
464 (NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) :
465 otr_restored_y;
466 otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing,
467 otr_y, otr_avatar_icon.width(),
468 browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0);
469 }
470
471 ///////////////////////////////////////////////////////////////////////////////
450 // OpaqueBrowserFrameView, private: 472 // OpaqueBrowserFrameView, private:
451 473
452 int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const { 474 int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const {
453 views::Window* window = frame_->GetWindow(); 475 views::Window* window = frame_->GetWindow();
454 return (!restored && (window->IsMaximized() || window->IsFullscreen())) ? 476 return (!restored && (window->IsMaximized() || window->IsFullscreen())) ?
455 0 : kFrameBorderThickness; 477 0 : kFrameBorderThickness;
456 } 478 }
457 479
458 int OpaqueBrowserFrameView::TopResizeHeight() const { 480 int OpaqueBrowserFrameView::TopResizeHeight() const {
459 return FrameBorderThickness(false) - kTopResizeAdjust; 481 return FrameBorderThickness(false) - kTopResizeAdjust;
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 // vertical midline rather than below. This compensates for how the icon is 1061 // vertical midline rather than below. This compensates for how the icon is
1040 // already biased downwards (see IconBounds()) and helps prevent descenders 1062 // already biased downwards (see IconBounds()) and helps prevent descenders
1041 // on the title from overlapping the 3D edge at the bottom of the titlebar. 1063 // on the title from overlapping the 3D edge at the bottom of the titlebar.
1042 title_bounds_.SetRect(title_x, 1064 title_bounds_.SetRect(title_x,
1043 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), 1065 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2),
1044 std::max(0, minimize_button_->x() - kTitleLogoSpacing - title_x), 1066 std::max(0, minimize_button_->x() - kTitleLogoSpacing - title_x),
1045 title_height); 1067 title_height);
1046 } 1068 }
1047 } 1069 }
1048 1070
1049 void OpaqueBrowserFrameView::LayoutOTRAvatar() {
1050 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
1051 int otr_bottom, otr_restored_y;
1052 if (browser_view_->UseVerticalTabs()) {
1053 otr_bottom = NonClientTopBorderHeight(false, false) - kOTRBottomSpacing;
1054 otr_restored_y = kFrameShadowThickness;
1055 } else {
1056 otr_bottom = GetHorizontalTabStripVerticalOffset(false) +
1057 browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
1058 otr_restored_y = otr_bottom - otr_avatar_icon.height();
1059 }
1060 int otr_y = frame_->GetWindow()->IsMaximized() ?
1061 (NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) :
1062 otr_restored_y;
1063 otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing,
1064 otr_y, otr_avatar_icon.width(),
1065 browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0);
1066 }
1067
1068 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, 1071 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
1069 int height) const { 1072 int height) const {
1070 int top_height = NonClientTopBorderHeight(false, false); 1073 int top_height = NonClientTopBorderHeight(false, false);
1071 int border_thickness = NonClientBorderThickness(); 1074 int border_thickness = NonClientBorderThickness();
1072 return gfx::Rect(border_thickness, top_height, 1075 return gfx::Rect(border_thickness, top_height,
1073 std::max(0, width - (2 * border_thickness)), 1076 std::max(0, width - (2 * border_thickness)),
1074 std::max(0, height - GetReservedHeight() - 1077 std::max(0, height - GetReservedHeight() -
1075 top_height - border_thickness)); 1078 top_height - border_thickness));
1076 } 1079 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698