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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_ROOT_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_ROOT_VIEW_H_
8 #include "ui/views/widget/root_view.h"
17 // RootView implementation used by BrowserFrame. This forwards drop events to
18 // the TabStrip. Visually the tabstrip extends to the top of the frame, but in
19 // actually it doesn't. The tabstrip is only as high as a tab. To enable
20 // dropping above the tabstrip BrowserRootView forwards drop events to the
22 class BrowserRootView
: public views::internal::RootView
{
24 // Internal class name.
25 static const char kViewClassName
[];
27 // You must call set_tabstrip before this class will accept drops.
28 BrowserRootView(BrowserView
* browser_view
, views::Widget
* widget
);
30 // Overridden from views::View:
31 virtual bool GetDropFormats(
33 std::set
<ui::OSExchangeData::CustomFormat
>* custom_formats
) OVERRIDE
;
34 virtual bool AreDropTypesRequired() OVERRIDE
;
35 virtual bool CanDrop(const ui::OSExchangeData
& data
) OVERRIDE
;
36 virtual void OnDragEntered(const ui::DropTargetEvent
& event
) OVERRIDE
;
37 virtual int OnDragUpdated(const ui::DropTargetEvent
& event
) OVERRIDE
;
38 virtual void OnDragExited() OVERRIDE
;
39 virtual int OnPerformDrop(const ui::DropTargetEvent
& event
) OVERRIDE
;
40 virtual const char* GetClassName() const OVERRIDE
;
41 virtual bool OnMouseWheel(const ui::MouseWheelEvent
& event
) OVERRIDE
;
43 // Overridden from internal::RootView:
44 virtual void DispatchGestureEvent(ui::GestureEvent
* event
) OVERRIDE
;
47 // Returns true if the event should be forwarded to the tabstrip.
48 bool ShouldForwardToTabStrip(const ui::DropTargetEvent
& event
);
50 // Converts the event from the hosts coordinate system to the tabstrips
52 ui::DropTargetEvent
* MapEventToTabStrip(
53 const ui::DropTargetEvent
& event
,
54 const ui::OSExchangeData
& data
);
56 inline TabStrip
* tabstrip() const;
58 // Returns true if |data| has string contents and the user can "paste and go".
59 // If |url| is non-NULL and the user can "paste and go", |url| is set to the
60 // desired destination.
61 bool GetPasteAndGoURL(const ui::OSExchangeData
& data
, GURL
* url
);
64 BrowserView
* browser_view_
;
66 // If true, drag and drop events are being forwarded to the tab strip.
67 // This is used to determine when to send OnDragEntered and OnDragExited
69 bool forwarding_to_tab_strip_
;
71 DISALLOW_COPY_AND_ASSIGN(BrowserRootView
);
74 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_ROOT_VIEW_H_