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