browser_root_view.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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.
4
5#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_ROOT_VIEW_H_
6#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_ROOT_VIEW_H_
7
8#include "ui/views/widget/root_view.h"
9
10class BrowserView;
11class TabStrip;
12
13namespace ui {
14class OSExchangeData;
15}
16
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
21// TabStrip.
22class BrowserRootView : public views::internal::RootView {
23 public:
24  // Internal class name.
25  static const char kViewClassName[];
26
27  // You must call set_tabstrip before this class will accept drops.
28  BrowserRootView(BrowserView* browser_view, views::Widget* widget);
29
30  // Overridden from views::View:
31  virtual bool GetDropFormats(
32      int* formats,
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 std::string GetClassName() const OVERRIDE;
41  virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
42
43 private:
44  // Returns true if the event should be forwarded to the tabstrip.
45  bool ShouldForwardToTabStrip(const ui::DropTargetEvent& event);
46
47  // Converts the event from the hosts coordinate system to the tabstrips
48  // coordinate system.
49  ui::DropTargetEvent* MapEventToTabStrip(
50      const ui::DropTargetEvent& event,
51      const ui::OSExchangeData& data);
52
53  inline TabStrip* tabstrip() const;
54
55  // Returns true if |data| has string contents and the user can "paste and go".
56  // If |url| is non-NULL and the user can "paste and go", |url| is set to the
57  // desired destination.
58  bool GetPasteAndGoURL(const ui::OSExchangeData& data, GURL* url);
59
60  // The BrowserView.
61  BrowserView* browser_view_;
62
63  // In immersive mode, when the immersive-controller temporarily reveals the
64  // top views, it is necessary to redirect some of the SchedulePaint() calls
65  // from views in the non-client view (e.g. maximize/close button etc.) to the
66  // reveal-view so that they are painted correctly. This keeps track of when
67  // such redirection is done.
68  bool scheduling_immersive_reveal_painting_;
69
70  // If true, drag and drop events are being forwarded to the tab strip.
71  // This is used to determine when to send OnDragEntered and OnDragExited
72  // to the tab strip.
73  bool forwarding_to_tab_strip_;
74
75  DISALLOW_COPY_AND_ASSIGN(BrowserRootView);
76};
77
78#endif  // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_ROOT_VIEW_H_
79