OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/frame/browser_frame_view_chromeos.h" |
| 6 |
| 7 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 8 #include "grit/generated_resources.h" |
| 9 #include "grit/theme_resources.h" |
| 10 #include "grit/theme_resources_standard.h" |
| 11 #include "views/window/hit_test.h" |
| 12 #include "views/window/window.h" |
| 13 #include "ui/base/theme_provider.h" |
| 14 |
| 15 namespace { |
| 16 // Additional pixels of pad above the tabs. |
| 17 const int kTopPad = 4; |
| 18 // To align theme bitmaps correctly we return this offset. |
| 19 const int kThemeOffset = -5; |
| 20 } |
| 21 |
| 22 namespace chromeos { |
| 23 |
| 24 // BrowserFrameViewChromeos adds a few pixels of pad to the top of the tabstrip. |
| 25 // To enable this we have to grab mouse events in that area and forward them on |
| 26 // to the NonClientView. We do this by overriding HitTest(), NonClientHitTest() |
| 27 // and GetEventHandlerForPoint(). |
| 28 BrowserFrameViewChromeos::BrowserFrameViewChromeos( |
| 29 BrowserFrame* frame, BrowserView* browser_view) |
| 30 : OpaqueBrowserFrameView(frame, browser_view) { |
| 31 } |
| 32 |
| 33 BrowserFrameViewChromeos::~BrowserFrameViewChromeos() { |
| 34 } |
| 35 |
| 36 int BrowserFrameViewChromeos::NonClientHitTest(const gfx::Point& point) { |
| 37 if (point.y() < kTopPad) |
| 38 return HTNOWHERE; |
| 39 return OpaqueBrowserFrameView::NonClientHitTest(point); |
| 40 } |
| 41 |
| 42 bool BrowserFrameViewChromeos::HitTest(const gfx::Point& l) const { |
| 43 if (l.y() < kTopPad) |
| 44 return true; |
| 45 return OpaqueBrowserFrameView::HitTest(l); |
| 46 } |
| 47 |
| 48 views::View* BrowserFrameViewChromeos::GetEventHandlerForPoint( |
| 49 const gfx::Point& point) { |
| 50 if (point.y() < kTopPad) { |
| 51 gfx::Point nc_point(point.x(), kTopPad); |
| 52 views::NonClientView* nc_view = frame()->GetWindow()->non_client_view(); |
| 53 View::ConvertPointToView(this, nc_view, &nc_point); |
| 54 return nc_view->GetEventHandlerForPoint(nc_point); |
| 55 } |
| 56 return OpaqueBrowserFrameView::GetEventHandlerForPoint(point); |
| 57 } |
| 58 |
| 59 int BrowserFrameViewChromeos::GetHorizontalTabStripVerticalOffset( |
| 60 bool restored) const { |
| 61 return NonClientTopBorderHeight(restored, true) + kTopPad; |
| 62 } |
| 63 |
| 64 void BrowserFrameViewChromeos::ModifyMaximizedFramePainting( |
| 65 int* top_offset, SkBitmap** left_corner, SkBitmap** right_corner) { |
| 66 *top_offset = kThemeOffset; |
| 67 ui::ThemeProvider* tp = GetThemeProvider(); |
| 68 if (tp->HasCustomImage(IDR_THEME_FRAME)) |
| 69 return; |
| 70 if (browser_view()->IsOffTheRecord()) { |
| 71 *left_corner = tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO_LEFT); |
| 72 *right_corner = tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO_RIGHT); |
| 73 } else { |
| 74 *left_corner = tp->GetBitmapNamed(IDR_THEME_FRAME_LEFT); |
| 75 *right_corner = tp->GetBitmapNamed(IDR_THEME_FRAME_RIGHT); |
| 76 } |
| 77 } |
| 78 |
| 79 } // namespace chromeos |
OLD | NEW |