browser_root_view.h revision 4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7
1// Copyright (c) 2009 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#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_ROOT_VIEW_H_ 6#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_ROOT_VIEW_H_ 7#pragma once 8 9#include "views/widget/root_view.h" 10 11class BrowserView; 12class OSExchangeData; 13class BaseTabStrip; 14 15// RootView implementation used by BrowserFrame. This forwards drop events to 16// the TabStrip. Visually the tabstrip extends to the top of the frame, but in 17// actually it doesn't. The tabstrip is only as high as a tab. To enable 18// dropping above the tabstrip BrowserRootView forwards drop events to the 19// TabStrip. 20class BrowserRootView : public views::RootView { 21 public: 22 // You must call set_tabstrip before this class will accept drops. 23 BrowserRootView(BrowserView* browser_view, views::Widget* widget); 24 25 virtual bool GetDropFormats( 26 int* formats, 27 std::set<OSExchangeData::CustomFormat>* custom_formats); 28 virtual bool AreDropTypesRequired(); 29 virtual bool CanDrop(const OSExchangeData& data); 30 virtual void OnDragEntered(const views::DropTargetEvent& event); 31 virtual int OnDragUpdated(const views::DropTargetEvent& event); 32 virtual void OnDragExited(); 33 virtual int OnPerformDrop(const views::DropTargetEvent& event); 34 35 private: 36 // Returns true if the event should be forwarded to the tabstrip. 37 bool ShouldForwardToTabStrip(const views::DropTargetEvent& event); 38 39 // Converts the event from the hosts coordinate system to the tabstrips 40 // coordinate system. 41 views::DropTargetEvent* MapEventToTabStrip( 42 const views::DropTargetEvent& event, 43 const OSExchangeData& data); 44 45 inline BaseTabStrip* tabstrip() const; 46 47 // Returns true if |data| has string contents and the user can "paste and go". 48 // If |url| is non-NULL and the user can "paste and go", |url| is set to the 49 // desired destination. 50 bool GetPasteAndGoURL(const OSExchangeData& data, GURL* url); 51 52 // The BrowserView. 53 BrowserView* browser_view_; 54 55 // If true, drag and drop events are being forwarded to the tab strip. 56 // This is used to determine when to send OnDragEntered and OnDragExited 57 // to the tab strip. 58 bool forwarding_to_tab_strip_; 59 60 DISALLOW_COPY_AND_ASSIGN(BrowserRootView); 61}; 62 63#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_ROOT_VIEW_H_ 64